]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Rationalise last patch
authorRoy Marples <roy@marples.name>
Thu, 23 May 2013 16:28:10 +0000 (16:28 +0000)
committerRoy Marples <roy@marples.name>
Thu, 23 May 2013 16:28:10 +0000 (16:28 +0000)
ipv4.c

diff --git a/ipv4.c b/ipv4.c
index cc7e2a45e41b2585b7637e6c68e329016c66d707..7692b385b44e427f6930c3fd38bd2cb5439d47da 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -253,36 +253,19 @@ ipv4_routedeleted(const struct rt *rt)
        return 1;
 }
 
+#define n_route(a)      nc_route(1, a, a)
+#define c_route(a, b)   nc_route(0, a, b)
 static int
-n_route(struct rt *rt)
+nc_route(int add, struct rt *ort, struct rt *nrt)
 {
-       const struct dhcp_state *s;
-
-       /* Don't set default routes if not asked to */
-       if (rt->dest.s_addr == 0 &&
-           rt->net.s_addr == 0 &&
-           !(rt->iface->options->options & DHCPCD_GATEWAY))
-               return -1;
-
-       /* 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;
-       syslog(LOG_ERR, "%s: ipv4_addroute: %m", rt->iface->name);
-       return -1;
-}
 
-static int
-c_route(struct rt *ort, struct rt *nrt)
-{
        /* Don't set default routes if not asked to */
        if (nrt->dest.s_addr == 0 &&
            nrt->net.s_addr == 0 &&
            !(nrt->iface->options->options & DHCPCD_GATEWAY))
                return -1;
 
-       desc_route("changing", nrt);
+       desc_route(add ? "adding" : "changing", nrt);
        /* We delete and add the route so that we can change metric.
         * This also has the nice side effect of flushing ARP entries so
         * we don't have to do that manually. */