Date: Fri, 17 Aug 2007 20:10:24 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 125276 for review Message-ID: <200708172010.l7HKAO4D088852@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125276 Change 125276 by zec@zec_tpx32 on 2007/08/17 20:10:08 Restore support for RFC1724-style addressing of interfaces (where 0.0.0.0/8 is interpreted as interface index) in our IPv4 multicast API (well, at least in some code paths). Without this neither RIP nor OSPF can work with quagga, neither on a clean kernel nor with options VIMAGE builds - strange that I'm the only one who has been hit by this? Affected files ... .. //depot/projects/vimage/src/sys/netinet/in_mcast.c#5 edit Differences ... ==== //depot/projects/vimage/src/sys/netinet/in_mcast.c#5 (text+ko) ==== @@ -120,6 +120,8 @@ 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. @@ -1032,9 +1034,9 @@ * If all of these conditions fail, return EADDRNOTAVAIL, and * reject the IPv4 multicast join. */ - if (mreqs.imr_interface.s_addr != INADDR_ANY) { - INADDR_TO_IFP(mreqs.imr_interface, ifp); - } else { + if (mreqs.imr_interface.s_addr != INADDR_ANY) + ifp = ip_multicast_if(&mreqs.imr_interface); + else { struct route ro; ro.ro_rt = NULL; @@ -1414,7 +1416,6 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt) { INIT_VNET_NET(curvnet); - INIT_VNET_INET(curvnet); struct in_addr addr; struct ip_mreqn mreqn; struct ifnet *ifp; @@ -1453,7 +1454,7 @@ if (addr.s_addr == INADDR_ANY) { ifp = NULL; } else { - INADDR_TO_IFP(addr, ifp); + ifp = ip_multicast_if(&addr); if (ifp == NULL) return (EADDRNOTAVAIL); } @@ -1839,3 +1840,25 @@ 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) +{ + INIT_VNET_NET(curvnet); + INIT_VNET_INET(curvnet); + int ifindex; + struct ifnet *ifp; + + if (ntohl(a->s_addr) >> 24 == 0) { + ifindex = ntohl(a->s_addr) & 0xffffff; + if (ifindex < 0 || V_if_index < ifindex) + return NULL; + ifp = ifnet_byindex(ifindex); + } else + INADDR_TO_IFP(*a, ifp); + return ifp; +} +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708172010.l7HKAO4D088852>