diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-08-26 14:34:24 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-09-01 17:00:27 +0200 |
commit | e1c94637ad50164292fe7e76a990b5e18b7de776 (patch) | |
tree | 8ec40c713bfc45836f4dfe243173d3ff48fe7c37 /dhcp.c | |
parent | 7eb155ab8f9d27e500ab91fbe8f3cef777e131fe (diff) | |
download | passt-e1c94637ad50164292fe7e76a990b5e18b7de776.tar passt-e1c94637ad50164292fe7e76a990b5e18b7de776.tar.gz passt-e1c94637ad50164292fe7e76a990b5e18b7de776.tar.bz2 passt-e1c94637ad50164292fe7e76a990b5e18b7de776.tar.lz passt-e1c94637ad50164292fe7e76a990b5e18b7de776.tar.xz passt-e1c94637ad50164292fe7e76a990b5e18b7de776.tar.zst passt-e1c94637ad50164292fe7e76a990b5e18b7de776.zip |
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>
Diffstat (limited to 'dhcp.c')
-rw-r--r-- | dhcp.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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; |