summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-06-12 08:41:18 +0000
committerEric Andersen <andersen@codepoet.org>2004-06-12 08:41:18 +0000
commit0de70f2020c1820d6c46e993fd8a5c4c309c8648 (patch)
tree8d233dc09a4e7f43d2fff7d1a088467ab62fc6f8
parent018f4ef5f8b9c7fb3e0fa3574bfd2c17f24b4253 (diff)
Stephen Hemminger from osdl dot org writes:
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
-rw-r--r--libc/inet/if_nametoindex.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libc/inet/if_nametoindex.c b/libc/inet/if_nametoindex.c
index a697419b6..45b319f97 100644
--- a/libc/inet/if_nametoindex.c
+++ b/libc/inet/if_nametoindex.c
@@ -148,6 +148,27 @@ struct if_nameindex * if_nameindex (void)
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 @@ char * if_indextoname (unsigned int ifindex, char *ifname)
if_freenameindex (idx);
}
return result;
+#endif
}