[Pkg-sysvinit-devel] Bug#606565: sysvinit: Shut down network interfaces correctly on BSDs

Guillem Jover guillem at debian.org
Fri Dec 10 05:40:32 UTC 2010


Package: sysvinit
Version: 2.88dsf-13
Severity: normal
Tags: patch
User: debian-bsd at lists.debian.org
Usertags: kfreebsd

Hi!

On BSDs (and particularly on GNU/kFreeBSD) the halt code to shut down
network interfaces is buggy. The problem stems from the fact that
SIOCGIFCONF has some portability issues.

On Linux the buffer returned is a list of consecutive ifreq structs,
each of the same size. On the BSDs the ifreq structs can have
different sizes, depending on the sockaddr length, but always with at
least a size of ifreq. So the next ifreq struct has to be computed
dynamically. I'm using _SIZEOF_ADDR_IFREQ because at least the BSDs
provide that macro, so it might avoid the need to define it at all.

Because the package does not have any kind of configure support I've
hardcoded a list of systems that have the sa_len member in struct
sockaddr, those same that have variable ifreq structs returned from
SIOCGIFCONF.

The patch also fixes few more things:

* The loopback interface on BSDs can be named as something like lo0,
  so check only the first two characters.
* On the BSDs the ifr_flags is split into two shorts, and to properly
  change its value, it needs to be composed from both ifr_flags and
  ifr_flagshigh, we use a temporary for that now.

This shows up on GNU/kFreeBSD as extremely ugly errors on halt/reboot as
the interface name is garbage, the SIOCGIFFLAGS fails and then prints
that garbage string stating that it's not a known device or file. It's
also confusing the fact that the error messages are prefixed with
"ifdown" which might incorrectly point people to ifupdown. This might
be worth changing too, though.

Patch attached.

thanks,
guillem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sysvinit_ifdown_bsd.patch
Type: text/x-diff
Size: 3348 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20101210/43a4a42c/attachment.patch>


More information about the Pkg-sysvinit-devel mailing list