From: Roy Marples Date: Sat, 23 May 2015 08:26:15 +0000 (+0000) Subject: Move the Is The Route a Host Route check to when we extract the static routes X-Git-Tag: v6.9.1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce546f162e89c721e77e0e4f606d81da077d5a0c;p=thirdparty%2Fdhcpcd.git Move the Is The Route a Host Route check to when we extract the static routes instead of checking all derived routes. Fixes [0d526c8558]. --- diff --git a/dhcp.c b/dhcp.c index afcef4fb..ae987915 100644 --- a/dhcp.c +++ b/dhcp.c @@ -644,6 +644,14 @@ get_option_routes(struct interface *ifp, const struct dhcp_message *dhcp) free(route); continue; } + /* A host route is normally set by having the + * gateway match the destination or assigned address */ + if (route->gate.s_addr == route->dest.s_addr || + route->gate.s_addr == dhcp->yiaddr) + { + route->gate.s_addr = htonl(INADDR_ANY); + route->net.s_addr = htonl(INADDR_BROADCAST); + } route->net.s_addr = route_netmask(route->dest.s_addr); TAILQ_INSERT_TAIL(routes, route, next); } diff --git a/ipv4.c b/ipv4.c index ee994337..82e36c30 100644 --- a/ipv4.c +++ b/ipv4.c @@ -512,28 +512,6 @@ get_routes(struct interface *ifp) return get_option_routes(ifp, D_STATE(ifp)->new); } -/* Some DHCP servers add set host routes by setting the gateway - * to the assigned IP address or the destination address. - * We need to change this. */ -static struct rt_head * -massage_host_routes(struct rt_head *rt, const struct interface *ifp) -{ - struct rt *r; - - if (rt) { - TAILQ_FOREACH(r, rt, next) { - if (r->gate.s_addr == D_CSTATE(ifp)->addr.s_addr || - r->gate.s_addr == r->dest.s_addr) - { - r->gate.s_addr = htonl(INADDR_ANY); - r->net.s_addr = htonl(INADDR_BROADCAST); - } - } - } - return rt; -} - - static struct rt_head * add_destination_route(struct rt_head *rt, const struct interface *ifp) { @@ -654,7 +632,6 @@ ipv4_buildroutes(struct dhcpcd_ctx *ctx) if (state == NULL || state->new == NULL || !state->added) continue; dnr = get_routes(ifp); - dnr = massage_host_routes(dnr, ifp); dnr = add_subnet_route(dnr, ifp); #ifdef IPV4_LOOPBACK_ROUTE dnr = add_loopback_route(dnr, ifp);