From swp@uni-altai.ru  Sat Mar 29 06:42:33 2008
Return-Path: <swp@uni-altai.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6D8A8106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 29 Mar 2008 06:42:33 +0000 (UTC)
	(envelope-from swp@uni-altai.ru)
Received: from mx1-ttk.uni-altai.ru (mx1-ttk.uni-altai.ru [81.1.237.194])
	by mx1.freebsd.org (Postfix) with ESMTP id 955F78FC1A
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 29 Mar 2008 06:42:32 +0000 (UTC)
	(envelope-from swp@uni-altai.ru)
Received: from main.uni-altai.ru (localhost [127.0.0.1])
	by mx1-ttk.uni-altai.ru (8.14.2/8.14.2) with ESMTP id m2T6G4BW097007
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 29 Mar 2008 12:16:05 +0600 (NOVT)
	(envelope-from swp@main.uni-altai.ru)
Received: (from root@localhost)
	by main.uni-altai.ru (8.14.2/8.14.2/Submit) id m2T6G3Rd097006;
	Sat, 29 Mar 2008 12:16:03 +0600 (NOVT)
	(envelope-from swp)
Message-Id: <200803290616.m2T6G3Rd097006@main.uni-altai.ru>
Date: Sat, 29 Mar 2008 12:16:03 +0600 (NOVT)
From: User & <swp@uni-altai.ru>
Reply-To: User & <swp@uni-altai.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: mrouted do not see all network interfaces for me
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         122223
>Category:       ports
>Synopsis:       [patch] net/mrouted do not see all network interfaces for me
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bms
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 29 06:50:00 UTC 2008
>Closed-Date:    Mon Mar 31 10:13:52 UTC 2008
>Last-Modified:  Mon Mar 31 10:20:06 UTC 2008
>Originator:     User &
>Release:        FreeBSD 6.3-STABLE i386
>Organization:
Barnaul State Pedagogical University
>Environment:
System: FreeBSD main.uni-altai.ru 6.3-STABLE FreeBSD 6.3-STABLE #1: Sun Feb 3 18:52:21 NOVT 2008 swp@main.uni-altai.ru:/usr/obj/usr/src/sys/fc_kernel i386


	
>Description:
	
mrouted gets list of interfaces by ioctl SIOCGIFCONF.  Default buffer is
short for my case.  Logic for resize buffer anf restart ioctl is wrong for me.

>How-To-Repeat:
	

/usr/include > ifconfig
xl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        options=9<RXCSUM,VLAN_MTU>
        ether 00:04:76:92:65:a8
        media: Ethernet autoselect (none)
        status: no carrier
xl1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        options=8<VLAN_MTU>
        ether 00:60:08:46:d3:b0
        media: Ethernet autoselect (none)
        status: no carrier
xl2: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        options=8<VLAN_MTU>
        ether 00:60:08:76:52:99
        media: Ethernet autoselect (none)
        status: no carrier
rl0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        options=8<VLAN_MTU>
        ether 00:40:f4:76:90:5c
        media: Ethernet autoselect
        status: no carrier
em0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        options=1b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING>
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet 127.0.0.1 netmask 0xff000000 
        inet 10.250.2.11 netmask 0xffffffff 
        inet 82.179.19.65 netmask 0xffffffff 
        inet 82.179.19.68 netmask 0xffffffff 
        inet 82.179.19.67 netmask 0xffffffff 
        inet 83.246.160.193 netmask 0xffffffff 
        inet 10.250.1.20 netmask 0xffffffff 
        inet 10.250.6.1 netmask 0xffffffff 
        inet 81.1.237.193 netmask 0xffffffff 
        inet 10.250.8.1 netmask 0xffffffff 
        inet 10.250.4.1 netmask 0xffffffff 
        inet 10.250.1.1 netmask 0xffffffff 
        inet 83.246.136.145 netmask 0xffffffff 
        inet 83.246.136.159 netmask 0xffffffff 
        inet 10.250.3.1 netmask 0xffffffff 
        inet 10.250.1.101 netmask 0xffffffff 
        inet 10.250.0.1 netmask 0xffffffff 
        inet 10.250.7.20 netmask 0xffffffff 
        inet 10.250.7.21 netmask 0xffffffff 
        inet 10.250.7.22 netmask 0xffffffff 
        inet 10.250.7.23 netmask 0xffffffff 
        inet 10.250.7.24 netmask 0xffffffff 
        inet 10.250.7.25 netmask 0xffffffff 
        inet 10.250.1.10 netmask 0xffffffff 
        inet 81.1.237.194 netmask 0xffffffff 
        inet 83.246.160.196 netmask 0xffffffff
        inet 10.250.1.100 netmask 0xffffffff
        inet 10.250.1.11 netmask 0xffffffff
        inet 10.250.1.65 netmask 0xffffffff
sw0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        inet 10.250.5.1 netmask 0xffffff00 broadcast 10.250.5.255
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 5 parent interface: em0
bb0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        inet 10.250.10.1 netmask 0xffffff00 broadcast 10.250.10.255
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 10 parent interface: em0
ttk0: flags=8a43<UP,BROADCAST,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        inet 82.200.46.14 netmask 0xfffffffc broadcast 82.200.46.15
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 16 parent interface: em0
ksd0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        inet 10.1.3.1 netmask 0xffffff00 broadcast 10.1.3.255
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 20 parent interface: em0
asu0: flags=8a43<UP,BROADCAST,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        inet 82.179.18.10 netmask 0xfffffffc broadcast 82.179.18.11
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 34 parent interface: em0
frl0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        inet 10.1.0.1 netmask 0xffffff00 broadcast 10.1.0.255
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 70 parent interface: em0
leo0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        inet 10.8.0.5 netmask 0xfffffe00 broadcast 10.8.1.255
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 80 parent interface: em0
itb0: flags=8a43<UP,BROADCAST,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        inet 83.246.140.137 netmask 0xffffffc0 broadcast 83.246.140.191
        ether 00:07:e9:2a:fd:f4
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 105 parent interface: em0
br0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether 96:9c:24:ae:b3:4d
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto stp maxaddr 100 timeout 1200
        root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
        member: xl0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33208

>Fix:
Dirty fix:

+++ config.c    2008-03-28 09:14:09.000000000 +0600dir  8Delete 9Menu   10Quit 
@@ -18,6 +18,7 @@
 config.c,v 3.8.4.10 1998/01/06 01:57:41 fenner Exp $";
 #endif
 
+
 struct ifconf ifc;
 
 /*
@@ -33,33 +34,24 @@
     int n;
     u_int32 addr, mask, subnet;
     short flags;
-    int num_ifreq = 32;
 
-    ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
-    ifc.ifc_buf = malloc(ifc.ifc_len);
-    while (ifc.ifc_buf) {
-       if (ioctl(udp_socket, SIOCGIFCONF, (char *)&ifc) < 0)
+    do {
+       char *b;
+
+       b = sbrk(0x10000);
+       if (!b)
+           log(LOG_ERR, errno, "sbrk(0x10000");
+
+       ifc.ifc_len = 0x10000;
+       ifc.ifc_buf = b;
+
+       if (ioctl(udp_socket, SIOCGIFCONF, &ifc) < 0)
            log(LOG_ERR, errno, "ioctl SIOCGIFCONF");
 
-       /*
-        * If the buffer was large enough to hold all the addresses
-        * then break out, otherwise increase the buffer size and
-        * try again.
-        *
-        * The only way to know that we definitely had enough space
-        * is to know that there was enough space for at least one
-        * more struct ifreq. ???
-        */
-       if ((num_ifreq * sizeof(struct ifreq)) >=
-            ifc.ifc_len + sizeof(struct ifreq))
-            break;
-
-       num_ifreq *= 2;
-       ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
-       ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
-    }
-    if (ifc.ifc_buf == NULL)
-       log(LOG_ERR, 0, "config_vifs_from_kernel: ran out of memory");
+        b += ifc.ifc_len;
+       if (brk(b) < 0)
+           log(LOG_ERR, errno, "brk()");
+    } while (0);
 
     ifrp = (struct ifreq *)ifc.ifc_buf;
     ifend = (struct ifreq *)(ifc.ifc_buf + ifc.ifc_len);

	
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->bms 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Mar 29 06:56:15 UTC 2008 
Responsible-Changed-Why:  
Fix up synopsis and assign. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122223 
State-Changed-From-To: open->feedback 
State-Changed-By: bms 
State-Changed-When: Sat 29 Mar 2008 12:46:38 UTC 
State-Changed-Why:  
feedback requested 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122223 

From: "mitrohin a.s." <swp@swp.pp.ru>
To: bug-followup@FreeBSD.org, swp@uni-altai.ru
Cc:  
Subject: Re: ports/122223: [patch] net/mrouted do not see all network
	interfaces for me
Date: Sun, 30 Mar 2008 19:14:14 +0700

 hi.
 
 RELENG_6 has mrouted in base system with more better fix.
 
 /swp

From: "mitrohin a.s." <swp@swp.pp.ru>
To: bug-followup@FreeBSD.org, swp@uni-altai.ru
Cc:  
Subject: Re: ports/122223: [patch] net/mrouted do not see all network
	interfaces for me
Date: Sun, 30 Mar 2008 21:04:19 +0700

 --/04w6evG8XlLl3ft
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Two patches for net/mrouted (from RELENG_6).
 
 
 
 --/04w6evG8XlLl3ft
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="patch-cfparse.y"
 
 --- cfparse.y.orig	1998-03-01 07:48:58.000000000 +0600
 +++ cfparse.y	2008-03-30 20:52:40.000000000 +0700
 @@ -4,6 +4,7 @@
   *
   * Written by Bill Fenner, NRL, 1994
   *
 + * $FreeBSD: src/usr.sbin/mrouted/cfparse.y,v 1.13.8.1 2006/07/16 06:53:26 maxim Exp $
   * cfparse.y,v 3.8.4.30 1998/03/01 01:48:58 fenner Exp
   */
  #include <stdio.h>
 @@ -14,17 +15,18 @@
  #endif
  #include "defs.h"
  #include <netdb.h>
 +#include <ifaddrs.h>
  
  /*
   * Local function declarations
   */
 -static void		fatal __P((char *fmt, ...));
 -static void		warn __P((char *fmt, ...));
 +static void		fatal __P((char *fmt, ...)) __printflike(1, 2);
 +static void		warn __P((char *fmt, ...)) __printflike(1, 2);
  static void		yyerror __P((char *s));
  static char *		next_word __P((void));
  static int		yylex __P((void));
  static u_int32		valid_if __P((char *s));
 -static struct ifreq *	ifconfaddr __P((struct ifconf *ifcp, u_int32 a));
 +static const char *	ifconfaddr(u_int32_t a);
  int			yyparse __P((void));
  
  static FILE *f;
 @@ -34,9 +36,6 @@
  extern int cache_lifetime;
  extern int prune_lifetime;
  
 -/* imported from config.c, with slight memory leak */
 -extern struct ifconf ifc;
 -
  int allow_black_holes = 0;
  
  static int lineno;
 @@ -127,15 +126,14 @@
  					}
  		ifmods
  	| TUNNEL interface addrname	{
 -
 -			struct ifreq *ifr;
 +			const char *ifname;
  			struct ifreq ffr;
  			vifi_t vifi;
  
  			order++;
  
 -			ifr = ifconfaddr(&ifc, $2);
 -			if (ifr == 0)
 +			ifname = ifconfaddr($2);
 +			if (ifname == 0)
  			    fatal("Tunnel local address %s is not mine",
  				inet_fmt($2, s1));
  
 @@ -144,7 +142,7 @@
  			    fatal("Tunnel local address %s is a loopback address",
  				inet_fmt($2, s1));
  
 -			if (ifconfaddr(&ifc, $3) != 0)
 +			if (ifconfaddr($3) != 0)
  			    fatal("Tunnel remote address %s is one of mine",
  				inet_fmt($3, s1));
  
 @@ -164,7 +162,7 @@
  			if (numvifs == MAXVIFS)
  			    fatal("too many vifs");
  
 -			strncpy(ffr.ifr_name, ifr->ifr_name, IFNAMSIZ);
 +			strlcpy(ffr.ifr_name, ifname, sizeof(ffr.ifr_name));
  			if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ffr)<0)
  			    fatal("ioctl SIOCGIFFLAGS on %s", ffr.ifr_name);
  
 @@ -175,7 +173,7 @@
  			v->uv_lcl_addr	= $2;
  			v->uv_rmt_addr	= $3;
  			v->uv_dst_addr	= $3;
 -			strncpy(v->uv_name, ffr.ifr_name, IFNAMSIZ);
 +			strlcpy(v->uv_name, ffr.ifr_name, sizeof(v->uv_name));
  
  			if (!(ffr.ifr_flags & IFF_UP)) {
  			    v->uv_flags |= VIFF_DOWN;
 @@ -577,7 +575,8 @@
  addrname	: ADDR		{ $$ = $1; }
  	| STRING		{ struct hostent *hp;
  
 -				  if ((hp = gethostbyname($1)) == NULL)
 +				  if ((hp = gethostbyname($1)) == NULL ||
 +					hp->h_length != sizeof($$))
  				    fatal("No such host %s", $1);
  
  				  if (hp->h_addr_list[1])
 @@ -655,7 +654,7 @@
  fatal(char *fmt, ...)
  {
  	va_list ap;
 -	char buf[200];
 +	char buf[MAXHOSTNAMELEN + 100];
  
  	va_start(ap, fmt);
  #else
 @@ -666,11 +665,11 @@
  va_dcl
  {
  	va_list ap;
 -	char buf[200];
 +	char buf[MAXHOSTNAMELEN + 100];
  
  	va_start(ap);
  #endif
 -	vsprintf(buf, fmt, ap);
 +	vsnprintf(buf, sizeof(buf), fmt, ap);
  	va_end(ap);
  
  	log(LOG_ERR,0,"%s: %s near line %d", configfilename, buf, lineno);
 @@ -696,7 +695,7 @@
  
  	va_start(ap);
  #endif
 -	vsprintf(buf, fmt, ap);
 +	vsnprintf(buf, sizeof(buf), fmt, ap);
  	va_end(ap);
  
  	log(LOG_WARNING,0,"%s: %s near line %d", configfilename, buf, lineno);
 @@ -902,28 +901,24 @@
  	return 0;
  }
  
 -static struct ifreq *
 -ifconfaddr(ifcp, a)
 -    struct ifconf *ifcp;
 -    u_int32 a;
 -{
 -    int n;
 -    struct ifreq *ifrp = (struct ifreq *)ifcp->ifc_buf;
 -    struct ifreq *ifend = (struct ifreq *)((char *)ifrp + ifcp->ifc_len);
 -
 -    while (ifrp < ifend) {
 -	    if (ifrp->ifr_addr.sa_family == AF_INET &&
 -		((struct sockaddr_in *)&ifrp->ifr_addr)->sin_addr.s_addr == a)
 -		    return (ifrp);
 -#ifdef HAVE_SA_LEN
 -		n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
 -		if (n < sizeof(*ifrp))
 -			++ifrp;
 -		else
 -			ifrp = (struct ifreq *)((char *)ifrp + n);
 -#else
 -		++ifrp;
 -#endif
 +static const char *
 +ifconfaddr(u_int32_t a)
 +{
 +    static char ifname[IFNAMSIZ];
 +    struct ifaddrs *ifap, *ifa;
 +
 +    if (getifaddrs(&ifap) != 0)
 +	return (NULL);
 +
 +    for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
 +	if (ifa->ifa_addr->sa_family == AF_INET &&
 +	    ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr == a) {
 +	    strlcpy(ifname, ifa->ifa_name, sizeof(ifname));
 +	    freeifaddrs(ifap);
 +	    return (ifname);
 +	}
      }
 -    return (0);
 +
 +    freeifaddrs(ifap);
 +    return (NULL);
  }
 
 --/04w6evG8XlLl3ft
 Content-Type: text/x-csrc; charset=us-ascii
 Content-Disposition: attachment; filename="patch-config.c"
 
 --- config.c.orig	1998-01-06 07:57:41.000000000 +0600
 +++ config.c	2008-03-30 20:39:31.000000000 +0700
 @@ -10,15 +10,13 @@
   * config.c,v 3.8.4.10 1998/01/06 01:57:41 fenner Exp
   */
  
 -
 -#include "defs.h"
 -
  #ifndef lint
 -static char rcsid[] = "@(#) $Id: \
 -config.c,v 3.8.4.10 1998/01/06 01:57:41 fenner Exp $";
 -#endif
 +static const char rcsid[] =
 +  "$FreeBSD: src/usr.sbin/mrouted/config.c,v 1.15.14.1 2006/07/16 06:53:26 maxim Exp $";
 +#endif /* not lint */
  
 -struct ifconf ifc;
 +#include "defs.h"
 +#include <ifaddrs.h>
  
  /*
   * Query the kernel to find network interfaces that are multicast-capable
 @@ -27,94 +25,47 @@
  void
  config_vifs_from_kernel()
  {
 -    struct ifreq *ifrp, *ifend;
 +    struct ifaddrs *ifa, *ifap;
      register struct uvif *v;
      register vifi_t vifi;
 -    int n;
      u_int32 addr, mask, subnet;
 -    short flags;
 -    int num_ifreq = 32;
 -
 -    ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
 -    ifc.ifc_buf = malloc(ifc.ifc_len);
 -    while (ifc.ifc_buf) {
 -	if (ioctl(udp_socket, SIOCGIFCONF, (char *)&ifc) < 0)
 -	    log(LOG_ERR, errno, "ioctl SIOCGIFCONF");
 -
 -	/*
 -	 * If the buffer was large enough to hold all the addresses
 -	 * then break out, otherwise increase the buffer size and
 -	 * try again.
 -	 *
 -	 * The only way to know that we definitely had enough space
 -	 * is to know that there was enough space for at least one
 -	 * more struct ifreq. ???
 -	 */
 -	if ((num_ifreq * sizeof(struct ifreq)) >=
 -	     ifc.ifc_len + sizeof(struct ifreq))
 -	     break;
 -
 -	num_ifreq *= 2;
 -	ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
 -	ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
 -    }
 -    if (ifc.ifc_buf == NULL)
 -	log(LOG_ERR, 0, "config_vifs_from_kernel: ran out of memory");
 +    int flags;
  
 -    ifrp = (struct ifreq *)ifc.ifc_buf;
 -    ifend = (struct ifreq *)(ifc.ifc_buf + ifc.ifc_len);
 +    if (getifaddrs(&ifap) < 0)
 +	log(LOG_ERR, errno, "getifaddrs");
      /*
       * Loop through all of the interfaces.
       */
 -    for (; ifrp < ifend; ifrp = (struct ifreq *)((char *)ifrp + n)) {
 -	struct ifreq ifr;
 -#ifdef HAVE_SA_LEN
 -	n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
 -	if (n < sizeof(*ifrp))
 -	    n = sizeof(*ifrp);
 -#else
 -	n = sizeof(*ifrp);
 -#endif
 +    for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
  	/*
  	 * Ignore any interface for an address family other than IP.
  	 */
 -	if (ifrp->ifr_addr.sa_family != AF_INET)
 +	if (ifa->ifa_addr->sa_family != AF_INET)
  	    continue;
  
 -	addr = ((struct sockaddr_in *)&ifrp->ifr_addr)->sin_addr.s_addr;
 -
 -	/*
 -	 * Need a template to preserve address info that is
 -	 * used below to locate the next entry.  (Otherwise,
 -	 * SIOCGIFFLAGS stomps over it because the requests
 -	 * are returned in a union.)
 -	 */
 -	bcopy(ifrp->ifr_name, ifr.ifr_name, sizeof(ifr.ifr_name));
 +	addr = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
  
  	/*
  	 * Ignore loopback interfaces and interfaces that do not support
  	 * multicast.
  	 */
 -	if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ifr) < 0)
 -	    log(LOG_ERR, errno, "ioctl SIOCGIFFLAGS for %s", ifr.ifr_name);
 -	flags = ifr.ifr_flags;
 -	if ((flags & (IFF_LOOPBACK|IFF_MULTICAST)) != IFF_MULTICAST) continue;
 +	flags = ifa->ifa_flags;
 +	if ((flags & (IFF_LOOPBACK|IFF_MULTICAST)) != IFF_MULTICAST)
 +	    continue;
  
  	/*
  	 * Ignore any interface whose address and mask do not define a
  	 * valid subnet number, or whose address is of the form {subnet,0}
  	 * or {subnet,-1}.
  	 */
 -	if (ioctl(udp_socket, SIOCGIFNETMASK, (char *)&ifr) < 0)
 -	    log(LOG_ERR, errno, "ioctl SIOCGIFNETMASK for %s", ifr.ifr_name);
 -	mask = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
 +	mask = ((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr.s_addr;
  	subnet = addr & mask;
  	if (!inet_valid_subnet(subnet, mask) ||
  	    addr == subnet ||
  	    addr == (subnet | ~mask)) {
  	    log(LOG_WARNING, 0,
  		"ignoring %s, has invalid address (%s) and/or mask (%s)",
 -		ifr.ifr_name, inet_fmt(addr, s1), inet_fmt(mask, s2));
 +		ifa->ifa_name, inet_fmt(addr, s1), inet_fmt(mask, s2));
  	    continue;
  	}
  
 @@ -123,7 +74,7 @@
  	 * one already installed in the uvifs array.
  	 */
  	for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
 -	    if (strcmp(v->uv_name, ifr.ifr_name) == 0) {
 +	    if (strcmp(v->uv_name, ifa->ifa_name) == 0) {
  		log(LOG_DEBUG, 0, "skipping %s (%s on subnet %s) (alias for vif#%u?)",
  			v->uv_name, inet_fmt(addr, s1),
  			inet_fmts(subnet, mask, s2), vifi);
 @@ -132,7 +83,7 @@
  	    if ((addr & v->uv_subnetmask) == v->uv_subnet ||
  		(v->uv_subnet & mask) == subnet) {
  		log(LOG_WARNING, 0, "ignoring %s, same subnet as %s",
 -					ifr.ifr_name, v->uv_name);
 +		    ifa->ifa_name, v->uv_name);
  		break;
  	    }
  	}
 @@ -142,7 +93,7 @@
  	 * If there is room in the uvifs array, install this interface.
  	 */
  	if (numvifs == MAXVIFS) {
 -	    log(LOG_WARNING, 0, "too many vifs, ignoring %s", ifr.ifr_name);
 +	    log(LOG_WARNING, 0, "too many vifs, ignoring %s", ifa->ifa_name);
  	    continue;
  	}
  	v  = &uvifs[numvifs];
 @@ -151,7 +102,7 @@
  	v->uv_subnet      = subnet;
  	v->uv_subnetmask  = mask;
  	v->uv_subnetbcast = subnet | ~mask;
 -	strncpy(v->uv_name, ifr.ifr_name, IFNAMSIZ);
 +	strlcpy(v->uv_name, ifa->ifa_name, sizeof(v->uv_name));
  
  	if (flags & IFF_POINTOPOINT)
  	    v->uv_flags |= VIFF_REXMIT_PRUNES;
 @@ -171,4 +122,6 @@
  	    vifs_down = TRUE;
  	}
      }
 +
 +    freeifaddrs(ifap);
  }
 
 --/04w6evG8XlLl3ft--
State-Changed-From-To: feedback->closed 
State-Changed-By: bms 
State-Changed-When: Mon 31 Mar 2008 10:13:41 UTC 
State-Changed-Why:  
committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122223 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/122223: commit references a PR
Date: Mon, 31 Mar 2008 10:13:41 +0000 (UTC)

 bms         2008-03-31 10:13:37 UTC
 
   FreeBSD ports repository (src committer)
 
   Modified files:
     net/mrouted          Makefile 
   Added files:
     net/mrouted/files    patch-cfparse.y patch-config.c 
   Log:
   Pick up patches which were in FreeBSD base before mrouted got de-orbitted.
   
   PR:             122223
   Submitted by:   swp at swp dot pp dot ru
   
   Revision  Changes    Path
   1.2       +1 -0      ports/net/mrouted/Makefile
   1.1       +178 -0    ports/net/mrouted/files/patch-cfparse.y (new)
   1.1       +173 -0    ports/net/mrouted/files/patch-config.c (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
