]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Control requested ivp4 routes and ignore pre-existing static ones.
authorRoy Marples <roy@marples.name>
Thu, 23 May 2013 16:22:51 +0000 (16:22 +0000)
committerRoy Marples <roy@marples.name>
Thu, 23 May 2013 16:22:51 +0000 (16:22 +0000)
ipv4.c

diff --git a/ipv4.c b/ipv4.c
index d57c9321c7f59846412eeab4f9e82fffe4663b1a..cc7e2a45e41b2585b7637e6c68e329016c66d707 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -264,23 +264,11 @@ n_route(struct rt *rt)
            !(rt->iface->options->options & DHCPCD_GATEWAY))
                return -1;
 
-       desc_route("adding", rt);
-       if (!ipv4_addroute(rt))
+       /* Delete the route first as it could exist prior to dhcpcd running
+        * and we need to ensure it leaves via our preffered interface */
+       ipv4_deleteroute(rt);
+       if (ipv4_addroute(rt) == 0)
                return 0;
-       if (errno == EEXIST) {
-               s = D_CSTATE(rt->iface);
-               /* Pretend we added the subnet route */
-               if (rt->dest.s_addr == (s->addr.s_addr & s->net.s_addr) &&
-                   rt->net.s_addr == s->net.s_addr &&
-                   rt->gate.s_addr == 0)
-                       return 0;
-               else {
-                       syslog(LOG_DEBUG,
-                           "%s: route exists but not in dhcpcd control",
-                           rt->iface->name);
-                       return -1;
-               }
-       }
        syslog(LOG_ERR, "%s: ipv4_addroute: %m", rt->iface->name);
        return -1;
 }