aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-08-26 14:34:24 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-09-01 17:00:27 +0200
commite1c94637ad50164292fe7e76a990b5e18b7de776 (patch)
tree8ec40c713bfc45836f4dfe243173d3ff48fe7c37
parent7eb155ab8f9d27e500ab91fbe8f3cef777e131fe (diff)
downloadpasst-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>
-rw-r--r--dhcp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/dhcp.c b/dhcp.c
index 04b04af..4969eec 100644
--- a/dhcp.c
+++ b/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;