From: Roy Marples Date: Wed, 11 Mar 2009 11:53:11 +0000 (+0000) Subject: We shouldn't need to flush arp entires ourself on BSD platforms. X-Git-Tag: v5.0.0~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4f6339ebd949920e432f814d5bb3304113daaea;p=thirdparty%2Fdhcpcd.git We shouldn't need to flush arp entires ourself on BSD platforms. --- diff --git a/configure.c b/configure.c index f8120503..d41b03ed 100644 --- a/configure.c +++ b/configure.c @@ -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) diff --git a/if-bsd.c b/if-bsd.c index d5681487..542ed6c6 100644 --- 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) { diff --git a/if-linux.c b/if-linux.c index 2bb1854d..0f4a3ab4 100644 --- a/if-linux.c +++ b/if-linux.c @@ -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 19abb91d..cbac54b5 100644 --- 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 *);