]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Move the Is The Route a Host Route check to when we extract the static routes
authorRoy Marples <roy@marples.name>
Sat, 23 May 2015 08:26:15 +0000 (08:26 +0000)
committerRoy Marples <roy@marples.name>
Sat, 23 May 2015 08:26:15 +0000 (08:26 +0000)
instead of checking all derived routes.
Fixes [0d526c8558].

dhcp.c
ipv4.c

diff --git a/dhcp.c b/dhcp.c
index afcef4fb41239fa84c442382d502e014421a33ed..ae98791570e69c79e7aeecd5640513266c5f29b1 100644 (file)
--- 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 ee994337e827139251452ee9ca1e0618ce01d76c..82e36c3058e49923fbeb581763ecd6ddc450b056 100644 (file)
--- 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);