From owner-p4-projects@FreeBSD.ORG Fri Aug 17 20:10:25 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D174416A41B; Fri, 17 Aug 2007 20:10:24 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AAA6C16A417 for ; Fri, 17 Aug 2007 20:10:24 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 5629713C49D for ; Fri, 17 Aug 2007 20:10:24 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7HKAOs9088855 for ; Fri, 17 Aug 2007 20:10:24 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7HKAO4D088852 for perforce@freebsd.org; Fri, 17 Aug 2007 20:10:24 GMT (envelope-from zec@FreeBSD.org) Date: Fri, 17 Aug 2007 20:10:24 GMT Message-Id: <200708172010.l7HKAO4D088852@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 125276 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2007 20:10:25 -0000 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; +} +