* SIOCGIFCOUNT
@ 2007-04-20 22:04 Andi Kleen
2007-04-20 22:41 ` SIOCGIFCOUNT David Miller
0 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2007-04-20 22:04 UTC (permalink / raw)
To: netdev
Hi,
A recent 32bit jdk spews these messages on x86-64
ioctl32(java:3877): Unknown cmd fd(3) cmd(00008938){00} arg(bfa4c844) on socket:[4470216]
..
0x8938 is SIOCGIFCOUNT. As far as I can see it is only defined in sockios.h, but not
implemented?
Should it be removed from the include file or implemented?
I probably will add a dummy compat ioctl entry to shut the JDK up at least.
-Andi
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: SIOCGIFCOUNT 2007-04-20 22:04 SIOCGIFCOUNT Andi Kleen @ 2007-04-20 22:41 ` David Miller 2007-04-21 9:48 ` SIOCGIFCOUNT Andi Kleen 0 siblings, 1 reply; 7+ messages in thread From: David Miller @ 2007-04-20 22:41 UTC (permalink / raw) To: ak; +Cc: netdev From: Andi Kleen <ak@suse.de> Date: Sat, 21 Apr 2007 00:04:51 +0200 > 0x8938 is SIOCGIFCOUNT. As far as I can see it is only defined in > sockios.h, but not implemented? > > Should it be removed from the include file or implemented? Unless we can be %100 certain not one build will break by removing it, we should keep it around. > I probably will add a dummy compat ioctl entry to shut the JDK up at least. Yes, but please do this generically so that the warning gets quieted on all compat platforms that might hit this. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: SIOCGIFCOUNT 2007-04-20 22:41 ` SIOCGIFCOUNT David Miller @ 2007-04-21 9:48 ` Andi Kleen 2007-04-21 17:40 ` SIOCGIFCOUNT David Miller 0 siblings, 1 reply; 7+ messages in thread From: Andi Kleen @ 2007-04-21 9:48 UTC (permalink / raw) To: David Miller; +Cc: netdev On Saturday 21 April 2007 00:41:33 David Miller wrote: > From: Andi Kleen <ak@suse.de> > Date: Sat, 21 Apr 2007 00:04:51 +0200 > > > 0x8938 is SIOCGIFCOUNT. As far as I can see it is only defined in > > sockios.h, but not implemented? > > > > Should it be removed from the include file or implemented? > > Unless we can be %100 certain not one build will break by removing it, > we should keep it around. Ok, but should it not be implemented for the non compat case too? I assume java has some reason to call it. -Andi ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: SIOCGIFCOUNT 2007-04-21 9:48 ` SIOCGIFCOUNT Andi Kleen @ 2007-04-21 17:40 ` David Miller 2007-04-23 21:12 ` [RFC] SIOCGIFCOUNT implementation Stephen Hemminger 0 siblings, 1 reply; 7+ messages in thread From: David Miller @ 2007-04-21 17:40 UTC (permalink / raw) To: ak; +Cc: netdev From: Andi Kleen <ak@suse.de> Date: Sat, 21 Apr 2007 11:48:52 +0200 > On Saturday 21 April 2007 00:41:33 David Miller wrote: > > From: Andi Kleen <ak@suse.de> > > Date: Sat, 21 Apr 2007 00:04:51 +0200 > > > > > 0x8938 is SIOCGIFCOUNT. As far as I can see it is only defined in > > > sockios.h, but not implemented? > > > > > > Should it be removed from the include file or implemented? > > > > Unless we can be %100 certain not one build will break by removing it, > > we should keep it around. > > Ok, but should it not be implemented for the non compat case too? > I assume java has some reason to call it. It probably just is one of those silly: #ifdef SIOCGIFCOUNT ret = try_to_use_SIOCGIFCOUNT(); #endif type code blocks that we find in just about every wonky source tree out there. There is no reason to add an implementation of it, and the compat layer should just return the same error code that the non-compat code will. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC] SIOCGIFCOUNT implementation 2007-04-21 17:40 ` SIOCGIFCOUNT David Miller @ 2007-04-23 21:12 ` Stephen Hemminger 2007-04-23 21:26 ` David Miller 0 siblings, 1 reply; 7+ messages in thread From: Stephen Hemminger @ 2007-04-23 21:12 UTC (permalink / raw) To: David Miller; +Cc: ak, netdev Trivial implementation of SIOCGIFCOUNT. If you search the archives, this was suggested and rejected 6 years ago. But there maybe legacy Unix applications that could actually use it. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> --- net/core/dev.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 40 insertions(+), 10 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 4dc93cc..6779aa4 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1987,7 +1987,7 @@ int register_gifconf(unsigned int family, gifconf_func_t * gifconf) * match. --pb */ -static int dev_ifname(struct ifreq __user *arg) +static int dev_ifname(void __user *arg) { struct net_device *dev; struct ifreq ifr; @@ -2020,7 +2020,7 @@ static int dev_ifname(struct ifreq __user *arg) * Thus we will need a 'compatibility mode'. */ -static int dev_ifconf(char __user *arg) +static int dev_ifconf(void __user *arg) { struct ifconf ifc; struct net_device *dev; @@ -2071,6 +2071,32 @@ static int dev_ifconf(char __user *arg) return copy_to_user(arg, &ifc, sizeof(struct ifconf)) ? -EFAULT : 0; } +/* + * Perform SIOCGIFCONF give estimate of number of interfaces. + * This show the poor design of Berkeley ioctl interface because number + * of interfaces can change at any time. + */ +static int dev_ifcount(char __user *arg) +{ + struct ifconf ifc; + struct net_device *dev; + int i, total = 0; + + for (dev = dev_base; dev; dev = dev->next) + for (i = 0; i < NPROTO; i++) + if (gifconf_list[i]) { + int done = gifconf_list[i](dev, NULL, 0); + if (done > 0) + total += done; + + } + + memset(&ifc, 0, sizeof(ifc)); + ifc.ifc_len = total; + return copy_to_user(arg, &ifc, sizeof(struct ifconf)) ? -EFAULT : 0; +} + + #ifdef CONFIG_PROC_FS /* * This is invoked by the /proc filesystem handler to display a device @@ -2643,19 +2669,23 @@ int dev_ioctl(unsigned int cmd, void __user *arg) int ret; char *colon; - /* One special case: SIOCGIFCONF takes ifconf argument - and requires shared lock, because it sleeps writing - to user space. - */ + /* Special case ioctl's that don't relate to a specific device */ + switch(cmd) { + case SIOCGIFCONF: + rtnl_lock(); + ret = dev_ifconf(arg); + rtnl_unlock(); + return ret; - if (cmd == SIOCGIFCONF) { + case SIOCGIFCOUNT: rtnl_lock(); - ret = dev_ifconf((char __user *) arg); + ret = dev_ifcount(arg); rtnl_unlock(); return ret; + + case SIOCGIFNAME: + return dev_ifname(arg); } - if (cmd == SIOCGIFNAME) - return dev_ifname((struct ifreq __user *)arg); if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) return -EFAULT; -- 1.5.0.6 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC] SIOCGIFCOUNT implementation 2007-04-23 21:12 ` [RFC] SIOCGIFCOUNT implementation Stephen Hemminger @ 2007-04-23 21:26 ` David Miller 2007-04-23 21:30 ` Andi Kleen 0 siblings, 1 reply; 7+ messages in thread From: David Miller @ 2007-04-23 21:26 UTC (permalink / raw) To: shemminger; +Cc: ak, netdev From: Stephen Hemminger <shemminger@linux-foundation.org> Date: Mon, 23 Apr 2007 14:12:26 -0700 > Trivial implementation of SIOCGIFCOUNT. > If you search the archives, this was suggested and rejected > 6 years ago. But there maybe legacy Unix applications that > could actually use it. > > Signed-off-by: Stephen Hemminger <shemminger@osdl.org> It makes no sense given that you can get this information with SIOCGIFCONF by supplying a NULL ifc.ifc_buf buffer. The equivalent of SIOCGIFCOUNT can be obtained by dividing ifc.ifc_len by the size of one interface entry. Please also tell me what legacy application could actually use this thing when BSD itself doesn't even implement it? A google code search for SIOCGIFCOUNT is fun too. In fact SIOCGIFCOUNT aparently got removed in 2.2.x, so let's keep it that way. There is no reason to add support for this, truly. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC] SIOCGIFCOUNT implementation 2007-04-23 21:26 ` David Miller @ 2007-04-23 21:30 ` Andi Kleen 0 siblings, 0 replies; 7+ messages in thread From: Andi Kleen @ 2007-04-23 21:30 UTC (permalink / raw) To: David Miller; +Cc: shemminger, netdev > Please also tell me what legacy application could actually > use this thing when BSD itself doesn't even implement it? Some version of java seems to. I see a lot of: ioctl32(java:30851): Unknown cmd fd(3) cmd(00008938){00} arg(bfbb87c4) on socket:[334628709] But just rejecting it is probably ok. -Andi ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-04-23 21:31 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-04-20 22:04 SIOCGIFCOUNT Andi Kleen 2007-04-20 22:41 ` SIOCGIFCOUNT David Miller 2007-04-21 9:48 ` SIOCGIFCOUNT Andi Kleen 2007-04-21 17:40 ` SIOCGIFCOUNT David Miller 2007-04-23 21:12 ` [RFC] SIOCGIFCOUNT implementation Stephen Hemminger 2007-04-23 21:26 ` David Miller 2007-04-23 21:30 ` Andi Kleen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).