Bug#327031: ifdown routine only works on Linux

Robert Millan rmh at aybabtu.com
Thu Sep 15 12:03:05 UTC 2005


On Thu, Sep 15, 2005 at 12:40:42PM +0200, Petter Reinholdtsen wrote:
> [Robert Millan]
> > This works, but only if you replace "ifr_flags" with
> > "ifr_flagshigh".  It seems the system declaration is different, and
> > kFreeBSD defines different macros for the high and low 16-bits of
> > the flags int.
> 
> Oh, strange.  I'll have to consult the Stevens books and the POSIX
> standard to figure out what the standard-compilant way to do this is.

Please let us know if you find out :)

> > The attached patch (mostly like yours but with a pre-processor
> > check) fixes the problem.
> 
> There is no pre-processor check in the patch you sent.  Was it
> incomplete?

Uh, looks like I sent the wrong patch.

Please use the one I'm attaching instead.

-- 
Robert Millan
-------------- next part --------------
--- sysvinit-2.86.ds1.old/src/ifdown.c	1998-06-02 22:41:47.000000000 +0200
+++ sysvinit-2.86.ds1/src/ifdown.c	2005-09-15 12:41:55.000000000 +0200
@@ -61,10 +61,18 @@
 				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);
+
+#ifdef ifr_flagshigh
+#define FLAGS ifr_flagshigh
+#else
+#define FLAGS ifr_flags
+#endif
+			if (ifr[i].FLAGS & IFF_UP) {
+				ifr[i].FLAGS &= ~(IFF_UP);
+				if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) {
+					fprintf(stderr, "ifdown: shutdown ");
+					perror(ifr[i].ifr_name);
+				}
 			}
 		}
 	}


More information about the Glibc-bsd-devel mailing list