diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-07-26 13:22:04 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-07-26 13:22:04 +0000 |
commit | dd01f2ceafefe1148ae83519b7bf3f4b14bd8027 (patch) | |
tree | 289f06874d000c78257ec10e2d9350a88cf82565 | |
parent | e297f1de5ed6502569434bc46a2388b3d9e1f6e7 (diff) |
Fix add_default_route() so -iface routes are actually
created when gateway == interface address.
-rw-r--r-- | sbin/dhclient/kroute.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index b7b700cea8d..409a425cc0d 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.118 2017/07/24 18:13:19 krw Exp $ */ +/* $OpenBSD: kroute.c,v 1.119 2017/07/26 13:22:03 krw Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -282,18 +282,16 @@ add_default_route(struct in_addr gateway, struct in_addr addr) memset(&netmask, 0, sizeof(netmask)); memset(&dest, 0, sizeof(dest)); - addrs = RTA_DST | RTA_NETMASK; - flags = 0; + addrs = RTA_DST | RTA_NETMASK | RTA_GATEWAY | RTA_IFA; + flags = RTF_GATEWAY | RTF_STATIC; /* * When 'addr' and 'gateway' are identical the desired behaviour is - * to emulate the '-iface' variant of 'route'. This is done by - * claiming there is no gateway address to use. + * to emulate the '-iface' variant of 'route'. i.e. do *NOT* set + * the RTF_GATEWAY flag for the default route. */ - if (memcmp(&gateway, &addr, sizeof(addr)) != 0) { - addrs |= RTA_GATEWAY | RTA_IFA; - flags |= RTF_GATEWAY | RTF_STATIC; - } + if (memcmp(&gateway, &addr, sizeof(addr)) == 0) + flags &= ~RTF_GATEWAY; add_route(dest, netmask, gateway, addr, addrs, flags); } |