diff options
author | Fahad Usman <fahad.usman@gmail.com> | 2014-08-19 23:39:57 +0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-08-23 09:26:10 +0100 |
commit | 87c748ca96c1127b9dcf8bf3990d77ab74d776a5 (patch) | |
tree | 3d42ce8d3dc7bf4699cfe91e18d5706360dfb3d6 /meta/recipes-connectivity | |
parent | 35318696ad06644f3b5e10c9512a78b639f50757 (diff) | |
download | poky-87c748ca96c1127b9dcf8bf3990d77ab74d776a5.tar.gz |
dhcp: do not use ifconfig/route in dhclient-script
The original patch was submitted on ISC's mailing list but it didn't get merged
for some reason, it can be found here;
https://lists.isc.org/pipermail/dhcp-users/2011-January/012910.html
"The ISC DHCP's dhclient-script for Linux still uses the legacy commands
'ifconfig' & 'route' to manage IPv4 network addresses & routes,
while it uses iproute2's new "ip" command to manage IPv6 network data.
This requires users & distributions to have both types of commands installed
The attached patch tries to improve the situation by replacing the
old "ifconfig" resp. "route" commands with their "ip" counterparts.
It even improves the logic a bit by only flushing the IPv4 addresses
instead of taking down the whole interface, which may still have active IPv6
connections."
(From OE-Core rev: afcaccd283e590294335f38d86635cf99db39e3f)
Signed-off-by: Fahad Usman <fahad.usman@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-connectivity')
-rw-r--r-- | meta/recipes-connectivity/dhcp/dhcp/replace-ifconfig-route.patch | 176 | ||||
-rw-r--r-- | meta/recipes-connectivity/dhcp/dhcp_4.3.0.bb | 1 |
2 files changed, 177 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/dhcp/dhcp/replace-ifconfig-route.patch b/meta/recipes-connectivity/dhcp/dhcp/replace-ifconfig-route.patch new file mode 100644 index 0000000000..61dd6a7186 --- /dev/null +++ b/meta/recipes-connectivity/dhcp/dhcp/replace-ifconfig-route.patch | |||
@@ -0,0 +1,176 @@ | |||
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 | |||
diff --git a/meta/recipes-connectivity/dhcp/dhcp_4.3.0.bb b/meta/recipes-connectivity/dhcp/dhcp_4.3.0.bb index 6da28faf50..13bcceb5a8 100644 --- a/meta/recipes-connectivity/dhcp/dhcp_4.3.0.bb +++ b/meta/recipes-connectivity/dhcp/dhcp_4.3.0.bb | |||
@@ -5,6 +5,7 @@ SRC_URI += "file://dhcp-3.0.3-dhclient-dbus.patch;striplevel=0 \ | |||
5 | file://link-with-lcrypto.patch \ | 5 | file://link-with-lcrypto.patch \ |
6 | file://fixsepbuild.patch \ | 6 | file://fixsepbuild.patch \ |
7 | file://dhclient-script-drop-resolv.conf.dhclient.patch \ | 7 | file://dhclient-script-drop-resolv.conf.dhclient.patch \ |
8 | file://replace-ifconfig-route.patch \ | ||
8 | " | 9 | " |
9 | 10 | ||
10 | SRC_URI[md5sum] = "1020d77e1a4c1f01b76279caff9beb80" | 11 | SRC_URI[md5sum] = "1020d77e1a4c1f01b76279caff9beb80" |