Bug 122223 - [patch] net/mrouted do not see all network interfaces for me
Summary: [patch] net/mrouted do not see all network interfaces for me
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Bruce M Simpson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-29 06:50 UTC by User &
Modified: 2008-03-31 11:20 UTC (History)
0 users

See Also:


Attachments
patch-cfparse.y (4.34 KB, text/plain; charset=us-ascii)
2008-03-30 15:04 UTC, mitrohin a.s.
no flags Details
patch-config.c (5.27 KB, text/x-csrc; charset=us-ascii)
2008-03-30 15:04 UTC, mitrohin a.s.
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description User & 2008-03-29 06:50:00 UTC
	
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.

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);
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
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2008-03-29 06:56:15 UTC
Responsible Changed
From-To: freebsd-ports-bugs->bms

Fix up synopsis and assign.
Comment 2 Bruce M Simpson freebsd_committer freebsd_triage 2008-03-29 12:46:38 UTC
State Changed
From-To: open->feedback

feedback requested
Comment 3 mitrohin a.s. 2008-03-30 13:14:14 UTC
hi.

RELENG_6 has mrouted in base system with more better fix.

/swp
Comment 4 mitrohin a.s. 2008-03-30 15:04:19 UTC
Two patches for net/mrouted (from RELENG_6).

Comment 5 Bruce M Simpson freebsd_committer freebsd_triage 2008-03-31 11:13:41 UTC
State Changed
From-To: feedback->closed

committed, thanks!
Comment 6 dfilter service freebsd_committer freebsd_triage 2008-03-31 11:13:41 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"