* Question about SIOCGIFCONF @ 2010-05-28 3:02 Jeffrey Merkey 2010-05-28 4:57 ` Eric Dumazet 0 siblings, 1 reply; 8+ messages in thread From: Jeffrey Merkey @ 2010-05-28 3:02 UTC (permalink / raw) To: linux-kernel Why is SIOGICONF only instrumented to return a single interface lo for example. I noticed that ifconfig always uses /proc/net/dev but the older SIOCGIFCONF ioctl seems to be busted. Anyone have an explanation or is this just how the shit is these days or is the fucking thing broken (seems to be). ? Jeff ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question about SIOCGIFCONF 2010-05-28 3:02 Question about SIOCGIFCONF Jeffrey Merkey @ 2010-05-28 4:57 ` Eric Dumazet 2010-05-28 9:22 ` Steven Whitehouse 2010-05-28 18:31 ` Jeffrey Merkey 0 siblings, 2 replies; 8+ messages in thread From: Eric Dumazet @ 2010-05-28 4:57 UTC (permalink / raw) To: Jeffrey Merkey; +Cc: linux-kernel Le jeudi 27 mai 2010 à 21:02 -0600, Jeffrey Merkey a écrit : > Why is SIOGICONF only instrumented to return a single interface lo for > example. I noticed that ifconfig always uses /proc/net/dev but the > older SIOCGIFCONF ioctl seems to be busted. Anyone have an > explanation or is this just how the shit is these days or is the > fucking thing broken (seems to be). ? Shit comes from you eyes maybe ? Correction : Shit comes from your eyes, definitely. Proof : # strace -o /tmp/STRACE ifconfig -a # grep SIOCGIFCONF /tmp/STRACE ioctl(4, SIOCGIFCONF, {120, {{"lo", {AF_INET, inet_addr("127.0.0.1")}}, {"wlan0", {AF_INET, inet_addr("192.168.1.21")}}, {"ppp0", {AF_INET, inet_addr("10.150.51.210")}}}}) = 0 Part of ifconfig : ifc.ifc_buf = NULL; for (;;) { ifc.ifc_len = sizeof(struct ifreq) * numreqs; ifc.ifc_buf = xrealloc(ifc.ifc_buf, ifc.ifc_len); if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) { perror("SIOCGIFCONF"); goto out; } if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) { /* assume it overflowed and try again */ numreqs += 10; continue; } break; } maybe numreqs should be firt initialized to 64, then doubled each round... ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question about SIOCGIFCONF 2010-05-28 4:57 ` Eric Dumazet @ 2010-05-28 9:22 ` Steven Whitehouse 2010-05-28 18:31 ` Jeffrey Merkey 1 sibling, 0 replies; 8+ messages in thread From: Steven Whitehouse @ 2010-05-28 9:22 UTC (permalink / raw) To: Eric Dumazet; +Cc: Jeffrey Merkey, linux-kernel Hi, On Fri, 2010-05-28 at 06:57 +0200, Eric Dumazet wrote: > Le jeudi 27 mai 2010 à 21:02 -0600, Jeffrey Merkey a écrit : > > Why is SIOGICONF only instrumented to return a single interface lo for > > example. I noticed that ifconfig always uses /proc/net/dev but the > > older SIOCGIFCONF ioctl seems to be busted. Anyone have an > > explanation or is this just how the shit is these days or is the > > fucking thing broken (seems to be). ? > > Shit comes from you eyes maybe ? > > Correction : Shit comes from your eyes, definitely. > > Proof : > > # strace -o /tmp/STRACE ifconfig -a > # grep SIOCGIFCONF /tmp/STRACE > ioctl(4, SIOCGIFCONF, {120, {{"lo", {AF_INET, inet_addr("127.0.0.1")}}, > {"wlan0", {AF_INET, inet_addr("192.168.1.21")}}, {"ppp0", {AF_INET, > inet_addr("10.150.51.210")}}}}) = 0 > > > Part of ifconfig : > > ifc.ifc_buf = NULL; > for (;;) { > ifc.ifc_len = sizeof(struct ifreq) * numreqs; > ifc.ifc_buf = xrealloc(ifc.ifc_buf, ifc.ifc_len); > > if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) { > perror("SIOCGIFCONF"); > goto out; > } > if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) { > /* assume it overflowed and try again */ > numreqs += 10; > continue; > } > break; > } > > maybe numreqs should be firt initialized to 64, then doubled each > round... > Yes, except that this will fail if you add a protocol that is not known about by ifconfig and it has a struct sockaddr which is larger than the 16 bytes allowed for in the ifreq. There used to be a DECnet implementation of this ioctl() but we had to get rid of it because it broke every single SIOCGFICONF using program (including ifconfig) on the system for that reason. This is partly historical. Some systems have a struct sockaddr which includes a length parameter which means that you can always parse the returned values, even if they are larger than 16 bytes and the protocol is unknown. Linux does not have this length field, so you have to know in advance a full list of all protocols which have sockaddr's greater than 16 bytes in length in order to parse the results. The upshot of all that is that it is much better to use rtnetlink, as per iproute2 instead of this ioctl which is obsolete for most purposes. A quick grep through the code suggests that ipv4 is the only protocol which implements this ioctl currently, Steve. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question about SIOCGIFCONF 2010-05-28 4:57 ` Eric Dumazet 2010-05-28 9:22 ` Steven Whitehouse @ 2010-05-28 18:31 ` Jeffrey Merkey 2010-05-28 19:02 ` Jeffrey Merkey 1 sibling, 1 reply; 8+ messages in thread From: Jeffrey Merkey @ 2010-05-28 18:31 UTC (permalink / raw) To: Eric Dumazet, linux-kernel Actually, I verified last night it only returns interfaces which have been bound to an IP address. It does not return any interfaces which are active but for which an IP address has not been bound. So what I said is accurate. it's fucking busted. /proc/net/dev returns ALL interfaces. this ioctl does not. Jeff On Thu, May 27, 2010 at 10:57 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote: > Le jeudi 27 mai 2010 à 21:02 -0600, Jeffrey Merkey a écrit : >> Why is SIOGICONF only instrumented to return a single interface lo for >> example. I noticed that ifconfig always uses /proc/net/dev but the >> older SIOCGIFCONF ioctl seems to be busted. Anyone have an >> explanation or is this just how the shit is these days or is the >> fucking thing broken (seems to be). ? > > Shit comes from you eyes maybe ? > > Correction : Shit comes from your eyes, definitely. > > Proof : > > # strace -o /tmp/STRACE ifconfig -a > # grep SIOCGIFCONF /tmp/STRACE > ioctl(4, SIOCGIFCONF, {120, {{"lo", {AF_INET, inet_addr("127.0.0.1")}}, > {"wlan0", {AF_INET, inet_addr("192.168.1.21")}}, {"ppp0", {AF_INET, > inet_addr("10.150.51.210")}}}}) = 0 > > > Part of ifconfig : > > ifc.ifc_buf = NULL; > for (;;) { > ifc.ifc_len = sizeof(struct ifreq) * numreqs; > ifc.ifc_buf = xrealloc(ifc.ifc_buf, ifc.ifc_len); > > if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) { > perror("SIOCGIFCONF"); > goto out; > } > if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) { > /* assume it overflowed and try again */ > numreqs += 10; > continue; > } > break; > } > > maybe numreqs should be firt initialized to 64, then doubled each > round... > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question about SIOCGIFCONF 2010-05-28 18:31 ` Jeffrey Merkey @ 2010-05-28 19:02 ` Jeffrey Merkey 2010-05-28 19:05 ` Jeffrey Merkey 0 siblings, 1 reply; 8+ messages in thread From: Jeffrey Merkey @ 2010-05-28 19:02 UTC (permalink / raw) To: Eric Dumazet, linux-kernel Review of the net-tools source code for IFCONFIG indicates that when /proc is not loaded and/or /proc/net/dev is not available, IFCONFIG will attempt to use this ioctl to determine which interfaces are present in the system. Since the ioctl will not report unbound interfaces which are active, IFCONFIG will not properly report or detect network adapters which are unbound. This seems to be a hole, although most of the time I assume /proc will always be mounted. Someone should review this and make a decision as to whether or not this could be a problem. At any rate, it does not work as advertised. Jeff On Fri, May 28, 2010 at 12:31 PM, Jeffrey Merkey <jeffmerkey@gmail.com> wrote: > Actually, I verified last night it only returns interfaces which have > been bound to an IP address. It does not return any interfaces which > are active but for which an IP address has not been bound. So what I > said is accurate. it's fucking busted. > > /proc/net/dev returns ALL interfaces. this ioctl does not. > > Jeff > > On Thu, May 27, 2010 at 10:57 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote: >> Le jeudi 27 mai 2010 à 21:02 -0600, Jeffrey Merkey a écrit : >>> Why is SIOGICONF only instrumented to return a single interface lo for >>> example. I noticed that ifconfig always uses /proc/net/dev but the >>> older SIOCGIFCONF ioctl seems to be busted. Anyone have an >>> explanation or is this just how the shit is these days or is the >>> fucking thing broken (seems to be). ? >> >> Shit comes from you eyes maybe ? >> >> Correction : Shit comes from your eyes, definitely. >> >> Proof : >> >> # strace -o /tmp/STRACE ifconfig -a >> # grep SIOCGIFCONF /tmp/STRACE >> ioctl(4, SIOCGIFCONF, {120, {{"lo", {AF_INET, inet_addr("127.0.0.1")}}, >> {"wlan0", {AF_INET, inet_addr("192.168.1.21")}}, {"ppp0", {AF_INET, >> inet_addr("10.150.51.210")}}}}) = 0 >> >> >> Part of ifconfig : >> >> ifc.ifc_buf = NULL; >> for (;;) { >> ifc.ifc_len = sizeof(struct ifreq) * numreqs; >> ifc.ifc_buf = xrealloc(ifc.ifc_buf, ifc.ifc_len); >> >> if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) { >> perror("SIOCGIFCONF"); >> goto out; >> } >> if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) { >> /* assume it overflowed and try again */ >> numreqs += 10; >> continue; >> } >> break; >> } >> >> maybe numreqs should be firt initialized to 64, then doubled each >> round... >> >> >> > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question about SIOCGIFCONF 2010-05-28 19:02 ` Jeffrey Merkey @ 2010-05-28 19:05 ` Jeffrey Merkey 2010-05-28 20:06 ` Eric Dumazet 0 siblings, 1 reply; 8+ messages in thread From: Jeffrey Merkey @ 2010-05-28 19:05 UTC (permalink / raw) To: Eric Dumazet, linux-kernel The code in question is net-tools/lib/interface.c function if_readproc() and associated routines. Looks like a hole. Jeff On Fri, May 28, 2010 at 1:02 PM, Jeffrey Merkey <jeffmerkey@gmail.com> wrote: > Review of the net-tools source code for IFCONFIG indicates that when > /proc is not loaded and/or /proc/net/dev is not available, IFCONFIG > will attempt to use this ioctl to determine which interfaces are > present in the system. Since the ioctl will not report unbound > interfaces which are active, IFCONFIG will not properly report or > detect network adapters which are unbound. This seems to be a hole, > although most of the time I assume /proc will always be mounted. > Someone should review this and make a decision as to whether or not > this could be a problem. At any rate, it does not work as advertised. > > Jeff > > On Fri, May 28, 2010 at 12:31 PM, Jeffrey Merkey <jeffmerkey@gmail.com> wrote: >> Actually, I verified last night it only returns interfaces which have >> been bound to an IP address. It does not return any interfaces which >> are active but for which an IP address has not been bound. So what I >> said is accurate. it's fucking busted. >> >> /proc/net/dev returns ALL interfaces. this ioctl does not. >> >> Jeff >> >> On Thu, May 27, 2010 at 10:57 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote: >>> Le jeudi 27 mai 2010 à 21:02 -0600, Jeffrey Merkey a écrit : >>>> Why is SIOGICONF only instrumented to return a single interface lo for >>>> example. I noticed that ifconfig always uses /proc/net/dev but the >>>> older SIOCGIFCONF ioctl seems to be busted. Anyone have an >>>> explanation or is this just how the shit is these days or is the >>>> fucking thing broken (seems to be). ? >>> >>> Shit comes from you eyes maybe ? >>> >>> Correction : Shit comes from your eyes, definitely. >>> >>> Proof : >>> >>> # strace -o /tmp/STRACE ifconfig -a >>> # grep SIOCGIFCONF /tmp/STRACE >>> ioctl(4, SIOCGIFCONF, {120, {{"lo", {AF_INET, inet_addr("127.0.0.1")}}, >>> {"wlan0", {AF_INET, inet_addr("192.168.1.21")}}, {"ppp0", {AF_INET, >>> inet_addr("10.150.51.210")}}}}) = 0 >>> >>> >>> Part of ifconfig : >>> >>> ifc.ifc_buf = NULL; >>> for (;;) { >>> ifc.ifc_len = sizeof(struct ifreq) * numreqs; >>> ifc.ifc_buf = xrealloc(ifc.ifc_buf, ifc.ifc_len); >>> >>> if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) { >>> perror("SIOCGIFCONF"); >>> goto out; >>> } >>> if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) { >>> /* assume it overflowed and try again */ >>> numreqs += 10; >>> continue; >>> } >>> break; >>> } >>> >>> maybe numreqs should be firt initialized to 64, then doubled each >>> round... >>> >>> >>> >> > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question about SIOCGIFCONF 2010-05-28 19:05 ` Jeffrey Merkey @ 2010-05-28 20:06 ` Eric Dumazet [not found] ` <AANLkTimg3iNFVcV7AWSc0MPoW7UwunwSdH4NNIxl_w-P@mail.gmail.com> 0 siblings, 1 reply; 8+ messages in thread From: Eric Dumazet @ 2010-05-28 20:06 UTC (permalink / raw) To: Jeffrey Merkey; +Cc: linux-kernel Le vendredi 28 mai 2010 à 13:05 -0600, Jeffrey Merkey a écrit : > The code in question is net-tools/lib/interface.c function > if_readproc() and associated routines. Looks like a hole. > > Jeff > > On Fri, May 28, 2010 at 1:02 PM, Jeffrey Merkey <jeffmerkey@gmail.com> wrote: > > Review of the net-tools source code for IFCONFIG indicates that when > > /proc is not loaded and/or /proc/net/dev is not available, IFCONFIG > > will attempt to use this ioctl to determine which interfaces are > > present in the system. Since the ioctl will not report unbound > > interfaces which are active, IFCONFIG will not properly report or > > detect network adapters which are unbound. This seems to be a hole, > > although most of the time I assume /proc will always be mounted. > > Someone should review this and make a decision as to whether or not > > this could be a problem. At any rate, it does not work as advertised. > > Maybe you could forget about a 20 years old legacy program and use the real thing : ip ip link ip addr ... Alternatively, you could rewrite ifconfig to use modern API. (Not depending on /proc , at all) ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <AANLkTimg3iNFVcV7AWSc0MPoW7UwunwSdH4NNIxl_w-P@mail.gmail.com>]
* Fwd: Question about SIOCGIFCONF [not found] ` <AANLkTimg3iNFVcV7AWSc0MPoW7UwunwSdH4NNIxl_w-P@mail.gmail.com> @ 2010-05-28 22:00 ` Jeffrey Merkey 0 siblings, 0 replies; 8+ messages in thread From: Jeffrey Merkey @ 2010-05-28 22:00 UTC (permalink / raw) To: linux-kernel ---------- Forwarded message ---------- From: Jeffrey Merkey <jeffmerkey@gmail.com> Date: Fri, May 28, 2010 at 3:57 PM Subject: Re: Question about SIOCGIFCONF To: Eric Dumazet <eric.dumazet@gmail.com> Not a bad suggestion, however, redhat and all the major distros still use ifconfig. Do you think this should be fixed or is it a non-issue? Jeff On Fri, May 28, 2010 at 2:06 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote: > Le vendredi 28 mai 2010 à 13:05 -0600, Jeffrey Merkey a écrit : >> The code in question is net-tools/lib/interface.c function >> if_readproc() and associated routines. Looks like a hole. >> >> Jeff >> >> On Fri, May 28, 2010 at 1:02 PM, Jeffrey Merkey <jeffmerkey@gmail.com> wrote: >> > Review of the net-tools source code for IFCONFIG indicates that when >> > /proc is not loaded and/or /proc/net/dev is not available, IFCONFIG >> > will attempt to use this ioctl to determine which interfaces are >> > present in the system. Since the ioctl will not report unbound >> > interfaces which are active, IFCONFIG will not properly report or >> > detect network adapters which are unbound. This seems to be a hole, >> > although most of the time I assume /proc will always be mounted. >> > Someone should review this and make a decision as to whether or not >> > this could be a problem. At any rate, it does not work as advertised. >> > > > Maybe you could forget about a 20 years old legacy program and use the > real thing : ip > > ip link > ip addr > ... > > Alternatively, you could rewrite ifconfig to use modern API. > > (Not depending on /proc , at all) > > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-05-28 22:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-28 3:02 Question about SIOCGIFCONF Jeffrey Merkey
2010-05-28 4:57 ` Eric Dumazet
2010-05-28 9:22 ` Steven Whitehouse
2010-05-28 18:31 ` Jeffrey Merkey
2010-05-28 19:02 ` Jeffrey Merkey
2010-05-28 19:05 ` Jeffrey Merkey
2010-05-28 20:06 ` Eric Dumazet
[not found] ` <AANLkTimg3iNFVcV7AWSc0MPoW7UwunwSdH4NNIxl_w-P@mail.gmail.com>
2010-05-28 22:00 ` Fwd: " Jeffrey Merkey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox