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

Lucas Nussbaum lucas at lucas-nussbaum.net
Wed Apr 16 09:06:14 UTC 2008


On 06/03/08 at 17:53 +0100, Lucas Nussbaum wrote:
> 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.

OK, I took a second look at this, since my WOL broke again after I
upgraded my system to current sid, and I'm now 200 km away from the
system without any possibility to wake it up remotely.

The problem is simple: the freebsd patch is wrong. You can't test the
value of ifr[i].FLAGS without doing a SIOCGIFFLAGS first. It works
without the freebsd patch because it just sets the interface down,
overriding all flags.

I would suggest to change the code so that it does:
/* 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
+                      /* Read interface flags */
+                      if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) < 0) {
+                              fprintf(stderr, "ifdown: shutdown ");
+                              perror(ifr[i].ifr_name);
+                      }
                       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 above is untested)
Robert, can you have a look, or do you want me to write a proper patch?
Or someone else from debian-bsd@? (I wouldn't be able to test it on kfreebsd)
-- 
| Lucas Nussbaum
| lucas at lucas-nussbaum.net   http://www.lucas-nussbaum.net/ |
| jabber: lucas at nussbaum.fr             GPG: 1024D/023B3F4F |





More information about the Pkg-sysvinit-devel mailing list