From owner-freebsd-current@FreeBSD.ORG Wed Nov 7 21:45:31 2007 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A3FA16A417; Wed, 7 Nov 2007 21:45:31 +0000 (UTC) (envelope-from zec@icir.org) Received: from zec2.tel.fer.hr (zec2.tel.fer.hr [161.53.19.79]) by mx1.freebsd.org (Postfix) with ESMTP id ED7D313C4A5; Wed, 7 Nov 2007 21:45:30 +0000 (UTC) (envelope-from zec@icir.org) Received: from localhost (localhost [127.0.0.1]) by zec2.tel.fer.hr (8.14.1/8.14.1) with ESMTP id lA7Mj65w001220; Wed, 7 Nov 2007 22:45:06 GMT (envelope-from zec@icir.org) From: Marko Zec To: freebsd-current@freebsd.org Date: Wed, 7 Nov 2007 22:45:04 +0000 User-Agent: KMail/1.9.7 References: <4732110D.3090808@interactive-net.de> In-Reply-To: <4732110D.3090808@interactive-net.de> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_x/jMHfp8V78I2pA" Message-Id: <200711072245.05430.zec@icir.org> X-Mailman-Approved-At: Wed, 07 Nov 2007 21:53:39 +0000 Cc: Robert Watson , bms@freebsd.org, Reinhard Haller Subject: Re: 7.0-BETA2 routed and multicast registration X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Nov 2007 21:45:31 -0000 --Boundary-00=_x/jMHfp8V78I2pA Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wednesday 07 November 2007 19:25:01 Reinhard Haller wrote: > Hi, > > routed has problems with setsockopt registering itself for multicast. > The trace contains the following messages: > > IP_ADD_MEMBERSHIP ALLROUTERS: Can't assign requested address > turn on RIP > setsockopt(IP_ADD_MEMBERSHIP RIP): Can't assign requested address > setsockopt(rdisc_sock,IP_MULTICAST_IF): Can't assign requested > address > > Any suggestions? Perhaps the attached kernel patch could help? Cheers, Marko --Boundary-00=_x/jMHfp8V78I2pA Content-Type: text/x-diff; charset="iso-8859-15"; name="in_mcast.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="in_mcast.diff" --- sys/netinet/in_mcast.c.org 2007-11-07 22:36:23.000000000 +0000 +++ sys/netinet/in_mcast.c 2007-11-07 22:37:16.000000000 +0000 @@ -113,6 +113,8 @@ static int inp_join_group(struct inpcb * static int inp_leave_group(struct inpcb *, struct sockopt *); static int inp_set_multicast_if(struct inpcb *, struct sockopt *); static int inp_set_source_filters(struct inpcb *, struct sockopt *); +static struct ifnet * + ip_multicast_if(struct in_addr *a); /* * Resize the ip_moptions vector to the next power-of-two minus 1. @@ -1019,7 +1021,7 @@ inp_join_group(struct inpcb *inp, struct * reject the IPv4 multicast join. */ if (mreqs.imr_interface.s_addr != INADDR_ANY) - INADDR_TO_IFP(mreqs.imr_interface, ifp); + ifp = ip_multicast_if(&mreqs.imr_interface); else { struct route ro; @@ -1435,7 +1437,7 @@ inp_set_multicast_if(struct inpcb *inp, if (addr.s_addr == INADDR_ANY) { ifp = NULL; } else { - INADDR_TO_IFP(addr, ifp); + ifp = ip_multicast_if(&addr); if (ifp == NULL) return (EADDRNOTAVAIL); } @@ -1820,3 +1822,23 @@ inp_setmoptions(struct inpcb *inp, struc return (error); } + +/* + * following RFC1724 section 3.3, 0.0.0.0/8 is interpreted as interface index. + */ +static struct ifnet * +ip_multicast_if(struct in_addr *a) +{ + int ifindex; + struct ifnet *ifp; + + if (ntohl(a->s_addr) >> 24 == 0) { + ifindex = ntohl(a->s_addr) & 0xffffff; + if (ifindex < 0 || if_index < ifindex) + return NULL; + ifp = ifnet_byindex(ifindex); + } else + INADDR_TO_IFP(*a, ifp); + return ifp; +} + --Boundary-00=_x/jMHfp8V78I2pA--