diff options
author | 2013-12-04 22:14:33 +0000 | |
---|---|---|
committer | 2013-12-04 22:14:33 +0000 | |
commit | d33b8e7c262201ca437bd5877d99695274045342 (patch) | |
tree | 305e677c97c416146fb974a818b2131a750ed86d | |
parent | Defer spooling of the install log output mail until we are up and (diff) | |
download | wireguard-openbsd-d33b8e7c262201ca437bd5877d99695274045342.tar.xz wireguard-openbsd-d33b8e7c262201ca437bd5877d99695274045342.zip |
When we receive a /32 IP address assignment, mimick ISC DHCP by adding
a direct route for the default gateway IP with equivalent to
route add -net $gw -netmask 255.255.255.255 -cloning -iface $myip
so that the subsequent
route add default $gw
can succeed.
Magic route(8) incantation thanks to claudio.
Tested successfully on Compute Engine.
Committing now so additional testing/discussion can happen in-tree.
Discussed with deraadt, krw, claudio.
-rw-r--r-- | sbin/dhclient/dhclient.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 307ff59a629..b503756ee74 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.271 2013/12/04 19:44:41 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.272 2013/12/04 22:14:33 matthew Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -881,6 +881,21 @@ bind_lease(void) /* XXX Only use FIRST router address for now. */ memcpy(&gateway.s_addr, options[DHO_ROUTERS].data, sizeof(gateway.s_addr)); + + /* + * If we were given a /32 IP assignment, then make sure + * the gateway address is routable with equivalent of + * + * route add -net $gw -netmask 255.255.255.255 \ + * -cloning -iface $addr + */ + if (mask.s_addr == INADDR_BROADCAST) { + add_route(ifi->rdomain, gateway, mask, + client->new->address, + RTA_DST | RTA_NETMASK | RTA_GATEWAY, + RTF_CLONING | RTF_STATIC); + } + add_default_route(ifi->rdomain, client->new->address, gateway); } |