[Pkg-sysvinit-devel] Bug#405870: more information on WOL and sysvinit

Lucas Nussbaum lucas at lucas-nussbaum.net
Thu Mar 6 16:53:19 UTC 2008


Hi,

I actually have the opposite problem with my r8169:
- if the interface is left up during shutdown, WOL works.
- if the interface is down during shutdown, WOL doesn't work.
But that's a driver problem, of course.

After commenting out the ifdown call in /etc/init.d/networking, the
interface wasn't shut down anymore during shutdown. Which is strange,
because halt should have shut it down. So WOL worked for me, while it
shouldn't!

The reason for that is 21_ifdown_kfreebsd.dpatch, a debian-specific
patch (which explains why recompiling by hand "fixes" the problem).

The patch does this:
    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);
            }
    }

The problem is that ifr[i].FLAGS doesn't include IFF_UP, even if the interface
is still UP, as seen by ifconfig. So the ioctl is never performed.

I don't understand why that's the case. Maybe SIOCGIFCONF has strange semantics? (I haven't checked)

Simple solution: revert to pre-patch behaviour, ie simply remove the
  if (ifr[i].FLAGS & IFF_UP) {
So the ioctl is done even if IFF_UP is not set.

Attached is my hacked-up dirty patch to understand the problem.
-- 
| Lucas Nussbaum
| lucas at lucas-nussbaum.net   http://www.lucas-nussbaum.net/ |
| jabber: lucas at nussbaum.fr             GPG: 1024D/023B3F4F |
-------------- next part --------------
#! /bin/sh /usr/share/dpatch/dpatch-run
## 22_ifdown_kfreebsd.dpatch mostly by Robert Millan
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Get ifdown working on kFreeBSD. (Closes: #327031)

@DPATCH@
diff -urNad sysvinit-2.86.ds1~/src/ifdown.c sysvinit-2.86.ds1/src/ifdown.c
--- sysvinit-2.86.ds1~/src/ifdown.c	2008-03-06 17:29:50.000000000 +0100
+++ sysvinit-2.86.ds1/src/ifdown.c	2008-03-06 17:32:59.000000000 +0100
@@ -50,9 +50,12 @@
 		return -1;
 	}
 	numif = ifc.ifc_len / sizeof(struct ifreq);
+	printf("numif: %d\n", numif);
+	sleep(3);
 
 	for (shaper = 1; shaper >= 0; shaper--) {
 		for (i = 0; i < numif; i++) {
+			printf("Considering %s\n", ifr[i].ifr_name);
 			if ((strncmp(ifr[i].ifr_name, "shaper", 6) == 0)
 			    != shaper) continue;
 
@@ -60,11 +63,26 @@
 				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);
+/* Expected in <net/if.h> according to "UNIX Network Programming". */
+#ifdef ifr_flags
+#define FLAGS ifr_flags
+#else
+/* Present on kFreeBSD, fixes bug #327031. */
+#define FLAGS ifr_flagshigh
+#endif
+			printf("before: %x\n", ifr[i].FLAGS);
+			printf("before: %x\n", ifr[i].ifr_flags);
+			system("ifconfig eth0");
+			printf("iff_up: %x\n", IFF_UP);
+			if (ifr[i].FLAGS & IFF_UP) {
+				ifr[i].FLAGS &= ~(IFF_UP);
+				printf("after: %x\n", ifr[i].FLAGS);
+				if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) {
+					fprintf(stderr, "ifdown: shutdown ");
+					perror(ifr[i].ifr_name);
+				}
 			}
+			sleep(3);
 		}
 	}
 	close(fd);


More information about the Pkg-sysvinit-devel mailing list