summary refs log tree commit diff
path: root/pkgs/tools/networking/dhcp/flush-if.patch
blob: a6d914231ee4cf8535239c73f30343f43c8b91ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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