]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
We shouldn't need to flush arp entires ourself on BSD platforms.
authorRoy Marples <roy@marples.name>
Wed, 11 Mar 2009 11:53:11 +0000 (11:53 +0000)
committerRoy Marples <roy@marples.name>
Wed, 11 Mar 2009 11:53:11 +0000 (11:53 +0000)
configure.c
if-bsd.c
if-linux.c
net.h

index f8120503e8512cf24736cb260e2618acbc7322b7..d41b03ed01552e20780783cf604ca26019bf53cf 100644 (file)
@@ -446,8 +446,9 @@ c_route(struct rt *ort, struct rt *nrt, const struct interface *iface)
                return -1;
 
        desc_route("changing", nrt, iface->name);
-       /* We don't call change_route because it doesn't work when something
-        * has already used it. */
+       /* 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. */
        del_route(ort->iface, &ort->dest, &ort->net, &ort->gate,
            ort->iface->metric);
        if (!add_route(iface, &nrt->dest, &nrt->net, &nrt->gate,
@@ -658,8 +659,6 @@ configure(struct interface *iface)
        }
 
        build_routes();
-       if (arp_flush() == -1)
-               syslog(LOG_ERR, "arp_flush: %m");
        if (!iface->state->lease.frominfo &&
            !(iface->state->options->options & DHCPCD_INFORM))
                if (write_lease(iface, dhcp) == -1)
index d56814872f26a26acca25e31bd029d4726c76441..542ed6c658e7eda6e06b052b36051304ed08cc39 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -255,43 +255,6 @@ if_route(const struct interface *iface, const struct in_addr *dest,
        return retval;
 }
 
-int
-arp_flush(void)
-{
-       int mib[6], retval = 0;
-       size_t buffer_len = 0;
-       char *buffer, *e, *p;
-       struct rt_msghdr *rtm;
-
-       mib[0] = CTL_NET;
-       mib[1] = PF_ROUTE;
-       mib[2] = 0;
-       mib[3] = AF_INET;
-       mib[4] = NET_RT_FLAGS;
-       mib[5] = RTF_LLINFO;
-       if (sysctl(mib, 6, NULL, &buffer_len, NULL, 0) == -1)
-               return -1;
-       if (buffer_len == 0)
-               return 0;
-       buffer = xmalloc(buffer_len);
-       if (sysctl(mib, 6, buffer, &buffer_len, NULL, 0) == -1)
-               return -1;
-       e = buffer + buffer_len;
-       for (p = buffer; p < e; p += rtm->rtm_msglen) {
-               rtm = (struct rt_msghdr *)(void *)p;
-               /* Don't delete manually added entries. */
-               if (rtm->rtm_flags & RTF_STATIC)
-                       continue;
-               rtm->rtm_type = RTM_DELETE;
-               if (write(r_fd, rtm, rtm->rtm_msglen) == -1) {
-                       retval = -1;
-                       break;
-               }
-       }
-       free(buffer);
-       return retval;
-}
-
 int
 open_link_socket(void)
 {
index 2bb1854d9f6c6bd8113fc25383a3443ef760c0d1..0f4a3ab4fc94dff2f10b2a71a9b15eb389006241 100644 (file)
@@ -472,13 +472,6 @@ if_route(const struct interface *iface,
        return retval;
 }
 
-/* No need to explicity flush arp on Linux */
-int
-arp_flush(void)
-{
-       return 0;
-}
-
 struct interface *
 discover_interfaces(int argc, char * const *argv)
 {
diff --git a/net.h b/net.h
index 19abb91da408dac4e767643456c9bf65dea17d5f..cbac54b568744fe9ba288db8f607f3ccb20c69b9 100644 (file)
--- a/net.h
+++ b/net.h
@@ -129,7 +129,6 @@ int if_route(const struct interface *, const struct in_addr *,
        if_route(iface, dest, mask, gate, metric, -1)
 #define del_src_route(iface, dest, mask, gate, metric)                 \
        if_route(iface, dest, mask, gate, metric, -2)
-int arp_flush(void);
 void free_routes(struct rt *);
 
 int open_udp_socket(struct interface *);