Package: ifupdown Version: 0.6.10 Severity: wishlist Tags: patch User: debian-bsd@lists.debian.org Usertags: kfreebsd
Debian GNU/kFreeBSD provides two route implementations, /lib/freebsd/route which is the FreeBSD version of route, and /sbin/route which is a shell wrapper that attempts to provide a Linux-like CLI. As the /sbin/route wrapper is very incomplete / unreliable, and applications tend to expect /sbin/route to provide FreeBSD CLI more often than not, in the near future we're going to install FreeBSD route into /sbin/route (and remove the wrapper or put it elsewhere). See: http://lists.debian.org/debian-bsd/2011/10/msg00242.html Attached patch adjusts ifupdown to use FreeBSD route CLI when running on GNU/kFreeBSD, and to use /lib/freebsd/route instead of /sbin/route. The latter is meant to be temporary and allow us to do this switch without causing any breakage. -- System Information: Debian Release: 6.0.3 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable') Architecture: kfreebsd-amd64 (x86_64) Kernel: kFreeBSD 8.1-1-amd64 Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages ifupdown depends on: ii freebsd-net-tools [net- 8.1-5 FreeBSD networking tools ii libc0.1 2.11.2-10 Embedded GNU C Library: Shared lib ii lsb-base 3.2-23.2squeeze1 Linux Standard Base 3.2 init scrip ifupdown recommends no packages. Versions of packages ifupdown suggests: pn iproute <none> (no description available) ii isc-dhcp-client [dh 4.1.1-P1-15+squeeze3 ISC DHCP client pn ppp <none> (no description available) -- no debconf information
=== modified file 'ifupdown.nw' --- ifupdown.nw 2011-10-22 21:18:54 +0000 +++ ifupdown.nw 2011-10-22 21:49:51 +0000 @@ -107,13 +107,13 @@ We shall begin with the template for the <<Makefile>>= <<make options>> -CFILES := addrfam.c execute.c config.c main.c archlinux.c -HFILES := header.h archlinux.h +CFILES := addrfam.c execute.c config.c main.c archlinux.c archkfreebsd.c +HFILES := header.h archlinux.h archkfreebsd.h PERLFILES := defn2c.pl defn2man.pl DEFNFILES := inet.defn ipx.defn inet6.defn OBJ := main.o addrfam.o execute.o config.o \ - $(patsubst %.defn,%.o,$(DEFNFILES)) archlinux.o + $(patsubst %.defn,%.o,$(DEFNFILES)) archlinux.o archkfreebsd.o MAN := $(patsubst %.defn,%.man,$(DEFNFILES)) @@ -3818,6 +3818,7 @@ interfaces up and down. unsigned int mylinuxver(); unsigned int mylinux(int,int,int); int execable(char *); +int islinux(); @ <<archlinux.c>>= @@ -3863,6 +3864,30 @@ int execable(char *program) { } return 0; } + +int islinux() { +#ifdef __linux__ + return 1; +#else + return 0; +#endif +} +@ + +<<archkfreebsd.h>>= +int iskfreebsd(); +@ + +<<archkfreebsd.c>>= +#include "archkfreebsd.h" + +int iskfreebsd() { +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + return 1; +#else + return 0; +#endif +} @ \subsection{IPv4 Address Family} @@ -3878,6 +3903,7 @@ extern address_family addr_inet; <<inet.defn>>= address_family inet architecture linux +architecture kfreebsd <<inet methods>> @ @@ -3925,10 +3951,17 @@ method static up route add -net %network% \ if ( mylinuxver() < mylinux(2,1,100) ) - [[ route add default gw %gateway% [[metric %metric%]] %iface% ]] + [[ /lib/freebsd/route add default %gateway% ]] \ + if ( iskfreebsd() ) + [[ route add default gw %gateway% [[metric %metric%]] %iface% ]] \ + elsif ( 1 ) + down - [[ route del default gw %gateway% [[metric %metric%]] %iface% ]] + [[ /lib/freebsd/route del default %gateway% ]] \ + if ( iskfreebsd() ) + [[ route del default gw %gateway% [[metric %metric%]] %iface% ]] \ + elsif ( 1 ) ifconfig %iface% down @ @@ -4058,6 +4091,7 @@ extern address_family addr_inet6; <<inet6.defn>>= address_family inet6 architecture linux +architecture kfreebsd method loopback description @@ -4086,7 +4120,10 @@ method static modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure. ifconfig %iface% [[media %media%]] [[hw %hwaddress%]] [[mtu %mtu%]] up ifconfig %iface% add %address%/%netmask% - [[ route -A inet6 add ::/0 gw %gateway% %iface% ]] + [[ /lib/freebsd/route add -inet6 ::/0 %gateway% ]] \ + if ( iskfreebsd() ) + [[ route -A inet6 add ::/0 gw %gateway% %iface% ]] \ + elsif ( 1 ) down ifconfig %iface% down