]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Remove RTM_GET code as we now read all kernel routes before building our own.
authorRoy Marples <roy@marples.name>
Tue, 3 Mar 2015 17:38:35 +0000 (17:38 +0000)
committerRoy Marples <roy@marples.name>
Tue, 3 Mar 2015 17:38:35 +0000 (17:38 +0000)
if-bsd.c
if.h
ipv4.c
ipv6.c

index 268e6b3e38e80f7f79a21b94994d02762a3c1080..7f1d6720b449cc33ea44f6000d02fab5f3a3298a 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -538,7 +538,7 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct rt_msghdr *rtm)
 }
 
 int
-if_route(unsigned char cmd, const struct rt *rt, struct rt *srt)
+if_route(unsigned char cmd, const struct rt *rt)
 {
        const struct dhcp_state *state;
        union sockunion {
@@ -632,9 +632,8 @@ if_route(unsigned char cmd, const struct rt *rt, struct rt *srt)
                if (rtm.hdr.rtm_flags & RTF_STATIC)
                        rtm.hdr.rtm_flags |= RTF_GATEWAY;
        }
-       if (((cmd == RTM_ADD || cmd == RTM_CHANGE) &&
-           !(rtm.hdr.rtm_flags & RTF_GATEWAY)) ||
-           cmd == RTM_GET)
+       if ((cmd == RTM_ADD || cmd == RTM_CHANGE) &&
+           !(rtm.hdr.rtm_flags & RTF_GATEWAY))
                rtm.hdr.rtm_addrs |= RTA_IFA | RTA_IFP;
 
        ADDADDR(&rt->dest);
@@ -674,16 +673,6 @@ if_route(unsigned char cmd, const struct rt *rt, struct rt *srt)
 
        rtm.hdr.rtm_msglen = (unsigned short)(bp - (char *)&rtm);
        retval = write(s, &rtm, rtm.hdr.rtm_msglen) == -1 ? -1 : 0;
-
-       if (cmd == RTM_GET && retval == 0) {
-               retval = read(s, &rtm, sizeof(rtm));
-               if (retval < (int)sizeof(struct rt_msghdr) ||
-                   retval < rtm.hdr.rtm_msglen)
-                       retval = -1;
-               else
-                       retval = if_copyrt(rt->iface->ctx, srt, &rtm.hdr);
-       }
-
        close(s);
        return retval;
 }
@@ -905,7 +894,7 @@ if_copyrt6(struct dhcpcd_ctx *ctx, struct rt6 *rt, struct rt_msghdr *rtm)
 }
 
 int
-if_route6(unsigned char cmd, const struct rt6 *rt, struct rt6 *srt)
+if_route6(unsigned char cmd, const struct rt6 *rt)
 {
        union sockunion {
                struct sockaddr sa;
@@ -964,8 +953,7 @@ if_route6(unsigned char cmd, const struct rt6 *rt, struct rt6 *srt)
 
        if (cmd == RTM_ADD)
                rtm.hdr.rtm_addrs |= RTA_GATEWAY;
-       if (cmd == RTM_GET ||
-           (cmd == RTM_ADD && !(rtm.hdr.rtm_flags & RTF_REJECT)))
+       if (cmd == RTM_ADD && !(rtm.hdr.rtm_flags & RTF_REJECT))
                rtm.hdr.rtm_addrs |= RTA_IFP | RTA_IFA;
 
        ADDADDR(&rt->dest);
@@ -1010,16 +998,6 @@ if_route6(unsigned char cmd, const struct rt6 *rt, struct rt6 *srt)
 
        rtm.hdr.rtm_msglen = (unsigned short)(bp - (char *)&rtm);
        retval = write(s, &rtm, rtm.hdr.rtm_msglen) == -1 ? -1 : 0;
-
-       if (cmd == RTM_GET && retval == 0) {
-               retval = read(s, &rtm, sizeof(rtm));
-               if (retval < (int)sizeof(struct rt_msghdr) ||
-                   retval < rtm.hdr.rtm_msglen)
-                       retval = -1;
-               else
-                       retval = if_copyrt6(rt->iface->ctx, srt, &rtm.hdr);
-       }
-
        close(s);
        return retval;
 }
diff --git a/if.h b/if.h
index e105a0cc29b710707a472063f589cd1c7d5c8458..fb2aa19cb25987debd40defc872ae0a5a012b980 100644 (file)
--- a/if.h
+++ b/if.h
@@ -124,7 +124,7 @@ int if_address(const struct interface *,
 #define if_deladdress(ifp, addr, net)          \
        if_address(ifp, addr, net, NULL, -1)
 
-int if_route(unsigned char, const struct rt *rt, struct rt *);
+int if_route(unsigned char, const struct rt *rt);
 int if_initrt(struct interface *);
 #endif
 
@@ -145,7 +145,7 @@ int if_address6(const struct ipv6_addr *, int);
 int if_addrflags6(const struct in6_addr *, const struct interface *);
 int if_getlifetime6(struct ipv6_addr *);
 
-int if_route6(unsigned char, const struct rt6 *rt, struct rt6 *);
+int if_route6(unsigned char, const struct rt6 *rt);
 int if_initrt6(struct interface *);
 #else
 #define if_checkipv6(a, b, c) (-1)
diff --git a/ipv4.c b/ipv4.c
index 3fd3b5701e1a7f2633164b28dda9d4172f76438f..de7e1e4a6ccfb56d94ed887f325619c9ef6ad07c 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -436,17 +436,17 @@ nc_route(struct rt *ort, struct rt *nrt)
 #ifdef HAVE_ROUTE_METRIC
        /* With route metrics, we can safely add the new route before
         * deleting the old route. */
-       if ((retval = if_route(RTM_ADD, nrt, NULL))  == -1)
+       if ((retval = if_route(RTM_ADD, nrt))  == -1)
                syslog(LOG_ERR, "if_route (ADD): %m");
-       if (ort && if_route(RTM_DELETE, ort, NULL) == -1 && errno != ESRCH)
+       if (ort && if_route(RTM_DELETE, ort) == -1 && errno != ESRCH)
                syslog(LOG_ERR, "if_route (DEL): %m");
        return retval;
 #else
        /* No route metrics, we need to delete the old route before
         * adding the new one. */
-       if (ort && if_route(RTM_DELETE, ort, NULL) == -1 && errno != ESRCH)
+       if (ort && if_route(RTM_DELETE, ort) == -1 && errno != ESRCH)
                syslog(LOG_ERR, "if_route (DEL): %m");
-       if (if_route(RTM_ADD, nrt, NULL) == 0)
+       if (if_route(RTM_ADD, nrt) == 0)
                return 0;
        syslog(LOG_ERR, "if_route (ADD): %m");
        return -1;
@@ -459,7 +459,7 @@ d_route(struct rt *rt)
        int retval;
 
        desc_route("deleting", rt);
-       retval = if_route(RTM_DELETE, rt, NULL);
+       retval = if_route(RTM_DELETE, rt);
        if (retval != 0 && errno != ENOENT && errno != ESRCH)
                syslog(LOG_ERR,"%s: if_delroute: %m", rt->iface->name);
        return retval;
diff --git a/ipv6.c b/ipv6.c
index 0aa3b694f3263695c8c290f2f913ca8566674002..8bf8ec35e6afee7df1ada8edddab897309222489 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -1829,18 +1829,18 @@ nc_route(struct rt6 *ort, struct rt6 *nrt)
 #ifdef HAVE_ROUTE_METRIC
        /* With route metrics, we can safely add the new route before
         * deleting the old route. */
-       if ((retval = if_route6(RTM_ADD, nrt, NULL)) == -1)
+       if ((retval = if_route6(RTM_ADD, nrt)) == -1)
                syslog(LOG_ERR, "if_route6 (ADD): %m");
-       if (ort && if_route6(RTM_DELETE, ort, NULL) == -1 &&
+       if (ort && if_route6(RTM_DELETE, ort) == -1 &&
            errno != ESRCH)
                syslog(LOG_ERR, "if_route6 (DEL): %m");
        return retval;
 #else
        /* No route metrics, we need to delete the old route before
         * adding the new one. */
-       if (ort && if_route6(RTM_DELETE, ort, NULL) == -1 && errno != ESRCH)
+       if (ort && if_route6(RTM_DELETE, ort) == -1 && errno != ESRCH)
                syslog(LOG_ERR, "if_route6: %m");
-       if (if_route6(RTM_ADD, nrt, NULL) == 0)
+       if (if_route6(RTM_ADD, nrt) == 0)
                return 0;
        syslog(LOG_ERR, "if_route6 (ADD): %m");
        return -1;
@@ -1853,7 +1853,7 @@ d_route(struct rt6 *rt)
        int retval;
 
        desc_route("deleting", rt);
-       retval = if_route6(RTM_DELETE, rt, NULL);
+       retval = if_route6(RTM_DELETE, rt);
        if (retval != 0 && errno != ENOENT && errno != ESRCH)
                syslog(LOG_ERR,"%s: if_delroute6: %m", rt->iface->name);
        return retval;