Bug#327031: ifdown routine only works on Linux
Petter Reinholdtsen
pere at hungry.com
Mon Sep 12 21:41:43 UTC 2005
[Robert Millan]
> It seems on kFreeBSD, some interfaces are "phantom" ones. They
> exist, and are detected by the numif assignment in ifdown.c, but
> their ifr_name component only contains trash (on my system, there
> are 2 normal interfaces, and 8 "phantom" ones).
Are these interfaces up? Perhaps this patch solve the problem, by
limiting the 'ifconfig down' to the interfaces currently up?
Index: src/ifdown.c
===================================================================
--- src/ifdown.c (revisjon 70)
+++ src/ifdown.c (arbeidskopi)
@@ -61,10 +61,12 @@
continue;
if (strchr(ifr[i].ifr_name, ':') != NULL)
continue;
- ifr[i].ifr_flags &= ~(IFF_UP);
- if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) {
- fprintf(stderr, "ifdown: shutdown ");
- perror(ifr[i].ifr_name);
+ if (ifr[i].ifr_flags & IFF_UP) {
+ ifr[i].ifr_flags &= ~(IFF_UP);
+ if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) {
+ fprintf(stderr, "ifdown: shutdown ");
+ perror(ifr[i].ifr_name);
+ }
}
}
}
The patch is completely untested, and written based on the info I
found in one of the stevens books.
More information about the Glibc-bsd-devel
mailing list