All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bridge] Little problem with 1.x versions (if_indextoname)
@ 2004-06-03  7:37 Harald Küthe
  2004-06-03 17:41 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Harald Küthe @ 2004-06-03  7:37 UTC (permalink / raw)
  To: bridge

Hi, 
I have used bridge-utils 0.9.6 so far in a kernel 2.4.26, uClibc and ppc environment.

When I use version 1.0.3 I have the problem that I do not see the brige with the 'brctl show' command if it is not fully set up. It was working with 0.9.6.
I tracked the problem down to an 'incompatibility' in bridge/uClibc/kernel.

0.9.6 uses its own if_indextoname function which uses the SIOCGIFNAME ioctl which works with the kernel.
Version 1.x uses the libc if_indextoname (here uClibc) which uses the SIOCGIFCONF ioctl and scans the if list to resolv the name for an if_index. 
The kernel will not send back interfaces which do not have an ip address (or exactly only for protocol family inet or decnet). 
So if the bridge does not have an ip address the name resolution fails and old_foreach_bridge() fails as well.

I'm not sure who has the problem now (kernel, uClibc, bridge) , but I think I will insert if_indextoname() back to the bridge.

I hope that this information is useful.

Regards
Harald Küthe



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Bridge] Little problem with 1.x versions (if_indextoname)
  2004-06-03  7:37 [Bridge] Little problem with 1.x versions (if_indextoname) Harald Küthe
@ 2004-06-03 17:41 ` Stephen Hemminger
  2004-06-12  8:42   ` [uClibc] " Erik Andersen
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2004-06-03 17:41 UTC (permalink / raw)
  To: "Harald =?ISO-8859-1?B?S/x0aGUi?= <Harald.Kuethe; +Cc: uclibc, bridge

On Thu, 03 Jun 2004 09:37:34 +0200
"Harald Küthe" <Harald.Kuethe@controlware.de> wrote:

> Hi, 
> I have used bridge-utils 0.9.6 so far in a kernel 2.4.26, uClibc and ppc environment.
> 
> When I use version 1.0.3 I have the problem that I do not see the brige with the 'brctl show' command if it is not fully set up. It was working with 0.9.6.
> I tracked the problem down to an 'incompatibility' in bridge/uClibc/kernel.
> 
> 0.9.6 uses its own if_indextoname function which uses the SIOCGIFNAME ioctl which works with the kernel.
> Version 1.x uses the libc if_indextoname (here uClibc) which uses the SIOCGIFCONF ioctl and scans the if list to resolv the name for an if_index. 
> The kernel will not send back interfaces which do not have an ip address (or exactly only for protocol family inet or decnet). 
> So if the bridge does not have an ip address the name resolution fails and old_foreach_bridge() fails as well.
> 
> I'm not sure who has the problem now (kernel, uClibc, bridge) , but I think I will insert if_indextoname() back to the bridge.
> 
> I hope that this information is useful.
> 
> Regards
> Harald Küthe

Rather than copy more code back into the bridge-utilities, how about applying this
change to uClibc?  I hate when packages get cluttered for workarounds for other
incompatibilities.

The problem is that SIOCGIFCONF only lists interfaces that have IP addresses, so it
doesn't find the other interfaces that are being used for bridging. It could be fixed
in the kernel to return all interfaces, but then something else might break; and still
it mean a kernel update for the 2.4 users. 

The whole use of ifindex in the bridge API is a bad idea. But we probably have to live
with it for compatibility.

Patch against uClibc 0.9.26
------------------------------------------------------------
--- if_nametoindex.c.orig	2002-12-04 10:27:15.000000000 -0800
+++ if_nametoindex.c	2004-06-03 10:31:34.732707064 -0700
@@ -148,6 +148,27 @@
 
 char * if_indextoname (unsigned int ifindex, char *ifname)
 {
+#ifdef SIOCGIFNAME
+  /* Use ioctl to avoid searching the list. */
+  struct ifreq ifr;
+  int fd, saved_errno;
+
+  fd = __opensock ();
+  
+  if (fd < 0)
+      return NULL;
+
+  ifr.ifr_ifindex = ifindex;
+  if (ioctl (fd, SIOCGIFNAME, &ifr) < 0) {
+      saved_errno = errno;
+      close (fd);
+      __set_errno (saved_errno);
+      return NULL;
+  }
+  close (fd);
+
+  return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
+#else
     struct if_nameindex *idx;
     struct if_nameindex *p;
     char *result = NULL;
@@ -163,5 +184,6 @@
 	if_freenameindex (idx);
     }
     return result;
+#endif
 }
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [uClibc] Re: [Bridge] Little problem with 1.x versions (if_indextoname)
  2004-06-03 17:41 ` Stephen Hemminger
@ 2004-06-12  8:42   ` Erik Andersen
  0 siblings, 0 replies; 3+ messages in thread
From: Erik Andersen @ 2004-06-12  8:42 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: uclibc, "Harald =?ISO-8859-1?B?S/x0aGUi?= <Harald.Kuethe,
	bridge

On Thu Jun 03, 2004 at 10:41:00AM -0700, Stephen Hemminger wrote:
> Rather than copy more code back into the bridge-utilities, how
> about applying this change to uClibc?  I hate when packages get
> cluttered for workarounds for other incompatibilities.
> 
> The problem is that SIOCGIFCONF only lists interfaces that have
> IP addresses, so it doesn't find the other interfaces that are
> being used for bridging. It could be fixed in the kernel to
> return all interfaces, but then something else might break; and
> still it mean a kernel update for the 2.4 users. 
> 
> The whole use of ifindex in the bridge API is a bad idea. But
> we probably have to live with it for compatibility.

Thanks.  Patch applied,

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-06-12  8:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-03  7:37 [Bridge] Little problem with 1.x versions (if_indextoname) Harald Küthe
2004-06-03 17:41 ` Stephen Hemminger
2004-06-12  8:42   ` [uClibc] " Erik Andersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.