[uClibc-cvs] uClibc/libc/inet if_nametoindex.c,1.2,1.3
Erik Andersen,,,
andersen at uclibc.org
Sat Jun 12 08:41:20 UTC 2004
Update of /var/cvs/uClibc/libc/inet
In directory nail:/tmp/cvs-serv3705
Modified Files:
if_nametoindex.c
Log Message:
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
Index: if_nametoindex.c
===================================================================
RCS file: /var/cvs/uClibc/libc/inet/if_nametoindex.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/if_nametoindex.c 4 Dec 2002 18:27:15 -0000 1.2
+++ b/if_nametoindex.c 12 Jun 2004 08:41:18 -0000 1.3
@@ -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
}
More information about the uClibc-cvs
mailing list