Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Found this patch here: |
| 2 | https://lists.isc.org/pipermail/dhcp-users/2011-January/012910.html |
| 3 | |
| 4 | and made some adjustments/updates to make it work with this version. |
| 5 | Wasn't able to find that why this patch was not accepted by ISC DHCP developers. |
| 6 | |
| 7 | Upstream-Status: Pending |
| 8 | |
| 9 | Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com> |
| 10 | |
| 11 | --- dhcp-4.2.5-P1/client/scripts/linux.orig 2013-09-04 12:22:55.000000000 +0500 |
| 12 | +++ dhcp-4.2.5-P1/client/scripts/linux 2013-09-04 12:52:19.068761518 +0500 |
| 13 | @@ -103,17 +103,11 @@ |
| 14 | if [ x$old_broadcast_address != x ]; then |
| 15 | old_broadcast_arg="broadcast $old_broadcast_address" |
| 16 | fi |
| 17 | -if [ x$new_subnet_mask != x ]; then |
| 18 | - new_subnet_arg="netmask $new_subnet_mask" |
| 19 | -fi |
| 20 | -if [ x$old_subnet_mask != x ]; then |
| 21 | - old_subnet_arg="netmask $old_subnet_mask" |
| 22 | -fi |
| 23 | -if [ x$alias_subnet_mask != x ]; then |
| 24 | - alias_subnet_arg="netmask $alias_subnet_mask" |
| 25 | +if [ -n "$new_subnet_mask" ]; then |
| 26 | + new_mask="/$new_subnet_mask" |
| 27 | fi |
| 28 | -if [ x$new_interface_mtu != x ]; then |
| 29 | - mtu_arg="mtu $new_interface_mtu" |
| 30 | +if [ -n "$alias_subnet_mask" ]; then |
| 31 | + alias_mask="/$alias_subnet_mask" |
| 32 | fi |
| 33 | if [ x$IF_METRIC != x ]; then |
| 34 | metric_arg="metric $IF_METRIC" |
| 35 | @@ -127,9 +121,9 @@ |
| 36 | if [ x$reason = xPREINIT ]; then |
| 37 | if [ x$alias_ip_address != x ]; then |
| 38 | # Bring down alias interface. Its routes will disappear too. |
| 39 | - ifconfig $interface:0- inet 0 |
| 40 | + ${ip} -4 addr flush dev ${interface} label ${interface}:0 |
| 41 | fi |
| 42 | - ifconfig $interface 0 up |
| 43 | + ${ip} link set dev ${interface} up |
| 44 | |
| 45 | # We need to give the kernel some time to get the interface up. |
| 46 | sleep 1 |
| 47 | @@ -156,25 +150,30 @@ |
| 48 | if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ |
| 49 | [ x$alias_ip_address != x$old_ip_address ]; then |
| 50 | # Possible new alias. Remove old alias. |
| 51 | - ifconfig $interface:0- inet 0 |
| 52 | + ${ip} -4 addr flush dev ${interface} label ${interface}:0 |
| 53 | fi |
| 54 | if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then |
| 55 | # IP address changed. Bringing down the interface will delete all routes, |
| 56 | # and clear the ARP cache. |
| 57 | - ifconfig $interface inet 0 down |
| 58 | + ${ip} -4 addr flush dev ${interface} label ${interface} |
| 59 | |
| 60 | fi |
| 61 | if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ |
| 62 | [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then |
| 63 | |
| 64 | - ifconfig $interface inet $new_ip_address $new_subnet_arg \ |
| 65 | - $new_broadcast_arg $mtu_arg |
| 66 | + ${ip} -4 addr add ${new_ip_address}${new_mask} ${new_broadcast_arg} \ |
| 67 | + dev ${interface} label ${interface} |
| 68 | + if [ -n "$new_interface_mtu" ]; then |
| 69 | + # set MTU |
| 70 | + ${ip} link set dev ${interface} mtu ${new_interface_mtu} |
| 71 | + fi |
| 72 | # Add a network route to the computed network address. |
| 73 | for router in $new_routers; do |
| 74 | if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
| 75 | - route add -host $router dev $interface |
| 76 | + ${ip} -4 route add ${router} dev $interface >/dev/null 2>&1 |
| 77 | fi |
| 78 | - route add default gw $router $metric_arg dev $interface |
| 79 | + ${ip} -4 route add default via ${router} dev ${interface} \ |
| 80 | + ${metric_arg} >/dev/null 2>&1 |
| 81 | done |
| 82 | else |
| 83 | # we haven't changed the address, have we changed other options |
| 84 | @@ -182,21 +181,23 @@ |
| 85 | if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then |
| 86 | # if we've changed routers delete the old and add the new. |
| 87 | for router in $old_routers; do |
| 88 | - route del default gw $router |
| 89 | + ${ip} -4 route delete default via ${router} |
| 90 | done |
| 91 | for router in $new_routers; do |
| 92 | if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
| 93 | - route add -host $router dev $interface |
| 94 | - fi |
| 95 | - route add default gw $router $metric_arg dev $interface |
| 96 | + ${ip} -4 route add ${router} dev $interface >/dev/null 2>&1 |
| 97 | + fi |
| 98 | + ${ip} -4 route add default via ${router} dev ${interface} \ |
| 99 | + ${metric_arg} >/dev/null 2>&1 |
| 100 | done |
| 101 | fi |
| 102 | fi |
| 103 | if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; |
| 104 | then |
| 105 | - ifconfig $interface:0- inet 0 |
| 106 | - ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg |
| 107 | - route add -host $alias_ip_address $interface:0 |
| 108 | + ${ip} -4 addr flush dev ${interface} label ${interface}:0 |
| 109 | + ${ip} -4 addr add ${alias_ip_address}${alias_mask} \ |
| 110 | + dev ${interface} label ${interface}:0 |
| 111 | + ${ip} -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1 |
| 112 | fi |
| 113 | make_resolv_conf |
| 114 | exit_with_hooks 0 |
| 115 | @@ -206,42 +207,49 @@ |
| 116 | || [ x$reason = xSTOP ]; then |
| 117 | if [ x$alias_ip_address != x ]; then |
| 118 | # Turn off alias interface. |
| 119 | - ifconfig $interface:0- inet 0 |
| 120 | + ${ip} -4 addr flush dev ${interface} label ${interface}:0 |
| 121 | fi |
| 122 | if [ x$old_ip_address != x ]; then |
| 123 | # Shut down interface, which will delete routes and clear arp cache. |
| 124 | - ifconfig $interface inet 0 down |
| 125 | + ${ip} -4 addr flush dev ${interface} label ${interface} |
| 126 | fi |
| 127 | if [ x$alias_ip_address != x ]; then |
| 128 | - ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg |
| 129 | - route add -host $alias_ip_address $interface:0 |
| 130 | + ${ip} -4 addr add ${alias_ip_address}${alias_network_arg} \ |
| 131 | + dev ${interface} label ${interface}:0 |
| 132 | + ${ip} -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1 |
| 133 | fi |
| 134 | exit_with_hooks 0 |
| 135 | fi |
| 136 | |
| 137 | if [ x$reason = xTIMEOUT ]; then |
| 138 | if [ x$alias_ip_address != x ]; then |
| 139 | - ifconfig $interface:0- inet 0 |
| 140 | + ${ip} -4 addr flush dev ${interface} label ${interface}:0 |
| 141 | + fi |
| 142 | + ${ip} -4 addr add ${new_ip_address}${new_mask} ${new_broadcast_arg} \ |
| 143 | + dev ${interface} label ${interface} |
| 144 | + if [ -n "$new_interface_mtu" ]; then |
| 145 | + # set MTU |
| 146 | + ip link set dev ${interface} mtu ${new_interface_mtu} |
| 147 | fi |
| 148 | - ifconfig $interface inet $new_ip_address $new_subnet_arg \ |
| 149 | - $new_broadcast_arg $mtu_arg |
| 150 | set $new_routers |
| 151 | if ping -q -c 1 $1; then |
| 152 | if [ x$new_ip_address != x$alias_ip_address ] && \ |
| 153 | [ x$alias_ip_address != x ]; then |
| 154 | - ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg |
| 155 | - route add -host $alias_ip_address dev $interface:0 |
| 156 | + ${ip} -4 addr add ${alias_ip_address}${alias_mask} \ |
| 157 | + dev ${interface} label ${interface}:0 |
| 158 | + ${ip} -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1 |
| 159 | fi |
| 160 | for router in $new_routers; do |
| 161 | if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
| 162 | - route add -host $router dev $interface |
| 163 | + ${ip} -4 route add ${router} dev $interface >/dev/null 2>&1 |
| 164 | fi |
| 165 | - route add default gw $router $metric_arg dev $interface |
| 166 | + ${ip} -4 route add default via ${router} dev ${interface} \ |
| 167 | + ${metric_arg} >/dev/null 2>&1 |
| 168 | done |
| 169 | make_resolv_conf |
| 170 | exit_with_hooks 0 |
| 171 | fi |
| 172 | - ifconfig $interface inet 0 down |
| 173 | + ${ip} -4 addr flush dev ${interface} |
| 174 | exit_with_hooks 1 |
| 175 | fi |
| 176 | |