diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-09-29 16:14:33 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-09-29 16:14:33 +0000 |
commit | 0a7708ff56d83c096447759ffeeeb678e60a8c32 (patch) | |
tree | b58e0a404ba1dfaf8d71f05cff288260c9e430ef | |
parent | e2b05ffd3a827bfa80480da184fb866222dee857 (diff) | |
download | nixlib-0a7708ff56d83c096447759ffeeeb678e60a8c32.tar nixlib-0a7708ff56d83c096447759ffeeeb678e60a8c32.tar.gz nixlib-0a7708ff56d83c096447759ffeeeb678e60a8c32.tar.bz2 nixlib-0a7708ff56d83c096447759ffeeeb678e60a8c32.tar.lz nixlib-0a7708ff56d83c096447759ffeeeb678e60a8c32.tar.xz nixlib-0a7708ff56d83c096447759ffeeeb678e60a8c32.tar.zst nixlib-0a7708ff56d83c096447759ffeeeb678e60a8c32.zip |
* dhcp: don't bring down an interface to delete old addresses / route
/ ARP cache information, but just flush those using the ip command. Bringing down wireless interfaces causes wpa_supplicant to fail and never recover ("wpa_supplicant: l2_packet_receive - recvfrom: Network is down"). This made associating with a wireless network rather unreliable and timing-dependant. It seems to work a lot better now. svn path=/nixpkgs/trunk/; revision=17514
-rw-r--r-- | pkgs/tools/networking/dhcp/default.nix | 12 | ||||
-rw-r--r-- | pkgs/tools/networking/dhcp/flush-if.patch | 76 |
2 files changed, 86 insertions, 2 deletions
diff --git a/pkgs/tools/networking/dhcp/default.nix b/pkgs/tools/networking/dhcp/default.nix index 15d06e9d42d3..de6e08df7b67 100644 --- a/pkgs/tools/networking/dhcp/default.nix +++ b/pkgs/tools/networking/dhcp/default.nix @@ -8,6 +8,13 @@ stdenv.mkDerivation rec { sha256 = "0il966bcls7nfd93qfqrgvd2apkm0kv7pk35lnl1nvbm7fyrik7z"; }; + patches = + [ # Don't bring down interfaces, because wpa_supplicant doesn't + # recover when the wlan interface goes down. Instead just flush + # all addresses, routes and neighbours of the interface. + ./flush-if.patch + ]; + # Fixes "socket.c:591: error: invalid application of 'sizeof' to # incomplete type 'struct in6_pktinfo'". See # http://www.mail-archive.com/blfs-book@linuxfromscratch.org/msg13013.html @@ -24,10 +31,11 @@ stdenv.mkDerivation rec { "${nettools}/bin:${nettools}/sbin:${iputils}/bin:${stdenv.coreutils}/bin:${stdenv.gnused}/bin" ''; - preConfigure = '' + preConfigure = + '' sed -i "includes/dhcpd.h" \ -"es|^ *#define \+_PATH_DHCLIENT_SCRIPT.*$|#define _PATH_DHCLIENT_SCRIPT \"$out/sbin/dhclient-script\"|g" - ''; + ''; meta = { description = "Dynamic Host Configuration Protocol (DHCP) tools"; diff --git a/pkgs/tools/networking/dhcp/flush-if.patch b/pkgs/tools/networking/dhcp/flush-if.patch new file mode 100644 index 000000000000..a6d914231ee4 --- /dev/null +++ b/pkgs/tools/networking/dhcp/flush-if.patch @@ -0,0 +1,76 @@ +diff --exclude '*~' -rc dhcp-4.1.0p1-orig/client/scripts/linux dhcp-4.1.0p1/client/scripts/linux +*** dhcp-4.1.0p1-orig/client/scripts/linux 2008-05-23 15:56:07.000000000 +0200 +--- dhcp-4.1.0p1/client/scripts/linux 2009-09-29 17:56:57.000000000 +0200 +*************** +*** 67,72 **** +--- 67,80 ---- + exit $exit_status + } + ++ # Delete the old addresses, routes and ARP information for this ++ # interface. ++ flush_if() { ++ ${ip} address flush dev $interface ++ ${ip} route flush dev $interface ++ ${ip} neighbour flush dev $interface ++ } ++ + # Invoke the local dhcp client enter hooks, if they exist. + if [ -f /etc/dhclient-enter-hooks ]; then + exit_status=0 +*************** +*** 150,159 **** + ifconfig $interface:0- inet 0 + fi + if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then +! # IP address changed. Bringing down the interface will delete all routes, +! # and clear the ARP cache. +! ifconfig $interface inet 0 down +! + fi + if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ + [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then +--- 158,165 ---- + ifconfig $interface:0- inet 0 + fi + if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then +! # IP address changed. +! flush_if + fi + if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ + [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then +*************** +*** 189,196 **** + ifconfig $interface:0- inet 0 + fi + if [ x$old_ip_address != x ]; then +! # Shut down interface, which will delete routes and clear arp cache. +! ifconfig $interface inet 0 down + fi + if [ x$alias_ip_address != x ]; then + ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg +--- 195,201 ---- + ifconfig $interface:0- inet 0 + fi + if [ x$old_ip_address != x ]; then +! flush_if + fi + if [ x$alias_ip_address != x ]; then + ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg +*************** +*** 225,231 **** + make_resolv_conf + exit_with_hooks 0 + fi +! ifconfig $interface inet 0 down + exit_with_hooks 1 + fi + +--- 230,236 ---- + make_resolv_conf + exit_with_hooks 0 + fi +! flush_if + exit_with_hooks 1 + fi + |