dhcpc does not handle local subnet routes correctly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
CirrOS |
Confirmed
|
Medium
|
Unassigned |
Bug Description
Long summary:
When Cirros gets a local subnet route from the dhcp server, it does not properly add the route to the route table.
To reproduce:
1. Add option 121 (classless-
2. Run udhcpc within cirros
3. Profit
Output:
$ /sbin/ifdown -a; /sbin/ifup -a
udhcpc (v1.20.1) started
Sending discover...
Sending select for 10.29.103.106...
Lease of 10.29.103.106 obtained, lease time 1200
deleting routers
adding dns 171.70.168.183
adding dns 173.36.131.10
adding dns 173.37.87.157
adding net 169.254.0.0/16 with router 0.0.0.0
route: SIOCADDRT: Invalid argument
WARN: failed: route add -net "169.254.0.0/16" gw "0.0.0.0"
Proposed patch to /usr/share/
References:
RFC 3442
Classless Static Route Option for DHCPv4
December 2002
Page 3-4
Local Subnet Routes
In some cases more than one IP subnet may be configured on a link.
In such cases, a host whose IP address is in one IP subnet in the
link could communicate directly with a host whose IP address is in a
different IP subnet on the same link. In cases where a client is
being assigned an IP address on an IP subnet on such a link, for each
IP subnet in the link other than the IP subnet on which the client
has been assigned the DHCP server MAY be configured to specify a
router IP address of 0.0.0.0.
For example, consider the case where there are three IP subnets
configured on a link: 10.0.0/24, 192.168.0/24, 10.0.21/24. If the
client is assigned an IP address of 10.0.21.17, then the server could
include a route with a destination of 10.0.0/24 and a router address
of 0.0.0.0, and also a route with a destination of 192.168.0/24 and a
router address of 0.0.0.0.
A DHCP client whose underlying TCP/IP stack does not provide this
capability MUST ignore routes in the Classless Static Routes option
whose router IP address is 0.0.0.0. Please note that the behavior
described here only applies to the Classless Static Routes option,
not to the Static Routes option nor the Router option.
Related branches
Changed in cirros: | |
status: | New → Confirmed |
Changed in cirros: | |
importance: | Undecided → Medium |
# Bazaar merge directive format 2 (Bazaar 0.90) vm-stevpier- 20141208033149- h5g3ylznt0y1p9w v //bazaar. launchpad. net/%2Bbranch/ cirros/ 6b8f5d119c8320b 569e6c7140 cirros- dhcpc' cirros- dhcpc 2014-09-05 16:51:59 +0000 cirros- dhcpc 2014-12-08 03:31:49 +0000 ="$1"
net=" $1"
router= "$2"
shift 2 || {
error "apply_ static_ routes: failed shift 2. odd number of args?"
return 1;
done
# revision_id: stevpier@
# target_branch: bzr+ssh:
# testament_sha1: 4c3a9c8dfd4accb
# timestamp: 2014-12-07 21:34:26 -0600
# base_revision_id: <email address hidden>
#
# Begin patch
=== modified file 'src/sbin/
--- src/sbin/
+++ src/sbin/
@@ -20,15 +20,25 @@
# routes are pairs of network and gateway
# 169.254.169.254/32 10.65.0.128
local net="" router="" err=0
+ local_interface
+ shift 1
while [ $# -ne 0 ]; do
- [ -n "$net" ] || continue
- debug 1 "adding net $net with router $router"
- route add -net "$net" gw "$router" || {
- error "WARN: failed: route add -net \"$net\" gw \"$router\""
- err=$(($err+1));
- }
+ if [ "$router" == "0.0.0.0" ] ; then
+ debug 1 "adding net $net to $interface"
+ route add -net "$net" dev "$interface" || {
+ error "WARN: failed: route add -net \"$net\" dev \"$interface\""
+ err=$(($err+1));
+ }
+ else
+ debug 1 "adding net $net with router $router"
+ route add -net "$net" gw "$router" || {
+ [ -n "$net" ] || continue
+ error "WARN: failed: route add -net \"$net\" gw \"$router\""
+ err=$(($err+1));
+ }
+ fi
@@ -128,7 +138,7 @@
} > "$RESOLV_CONF"
- apply_static_routes $staticroutes
+ apply_static_routes $interface $staticroutes
}
case "$1" in
# Begin bundle 2aXNpb24gYnVuZG xlIHY0CiMKQlpoO TFBWSZTWdvIGj0A Ae3fgEAwVGv/ /3IB +UAR9cSe7eXme3t 3Y0OCUQmk9U9MUe pp6I2Qm1MaJkAAb SGgyiMjEyp7Qp7U ZIDNJoaBo D1GaA0mBHqep6CM CRSU9pJ5RtR7UJh PSAaG1NAAGgAkkT CCmZMIU3k1JspoA A n5OO7xcxlP4wywT ++LgIT9/ uy4yQac1WFWCHRk y5HTwyvdFPLTvO3 houKC9gj V6oql07FNw0axdC wjBXIOv0dzwvs3Y 2GMDMGf3c6HzR2k eHsxXpko+ JPK6VHCks8yJz VJvvZpWTlqamug1 7GVFFFVkkwMBb+ RxhRUFVFYbhlspa SDsZEZ+ BwB4nZQ/ SlOw D6YR4tUbwPLogwx OdtKLNuuR6gi7Hi Lf5sySEdONwoikX R0fmMIvCfqTEwNq o 3XDDJCNziKc5g6U Z2pkbyxpCeqMwmp LtAmy6OTBaqs+ BXt6RLJTL5dZPGw bga M9tkEwwxKyTVlEQ qWOy9TURhIWzUlG dZHqE6q4uTUCvSy BBdfzJOJxAo5m2O x qWvgF4CLBfWDlvN i9MnozIZrstNCMS sOcBEC0I4KA4NSU ht4eyQkHLIQQJ3X v WPNbTiyVAtJSv2E 8isqqpYy5arlmst LFDIslgSBt5CNq2 k/iL24dCwWctVlh H XEDk+5x8jhGNmra GnV2PNLUwK4ZUVV 8VvRWIZ50KCaaIC w4PPTZUuv42QIXu N FoSAs8ILxahxp15 BUB6FRDdRcvPBc2 0CbHObFWNAQhFk8 J1VG...
IyBCYXphYXIgcmV
EI6////
AAAlBCBMTQ0p71S
AaBowRBIY0wbQ2N
HY4pYegT/
wILlNEQtrx5G+
SGFl9CvrvonIEX6
maxV/EPExyY223m
ivlALIITCyM32ko
YUU52vZ3zxrIJN8
hVQ/DRKkFrrkEpd
0+7QS4keqopvqbc
Am2VBcboMGqtfcN