dhcp: Send option 121 if the default gateway is not on the assigned subnet
This enables CirrOS with udhcpc to set up a route to a gateway that's not on the assigned subnet, together with: https://bugs.launchpad.net/cirros/+bug/1190372 Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
7eb155ab8f
commit
e1c94637ad
1 changed files with 11 additions and 0 deletions
11
dhcp.c
11
dhcp.c
|
@ -308,6 +308,17 @@ int dhcp(struct ctx *c, struct ethhdr *eh, size_t len)
|
|||
*(unsigned long *)opts[3].s = c->gw4;
|
||||
*(unsigned long *)opts[54].s = c->gw4;
|
||||
|
||||
/* If the gateway is not on the assigned subnet, send an option 121
|
||||
* (Classless Static Routing) adding a dummy route to it.
|
||||
*/
|
||||
if ((c->addr4 & c->mask4) != (c->gw4 & c->mask4)) {
|
||||
/* a.b.c.d/32:0.0.0.0, 0:a.b.c.d */
|
||||
opts[121].slen = 14;
|
||||
opts[121].s[0] = 32;
|
||||
*(unsigned long *)&opts[121].s[1] = c->gw4;
|
||||
*(unsigned long *)&opts[121].s[10] = c->gw4;
|
||||
}
|
||||
|
||||
if (c->mtu) {
|
||||
opts[26].slen = 2;
|
||||
opts[26].s[0] = c->mtu / 256;
|
||||
|
|
Loading…
Reference in a new issue