From: Roy Marples Date: Fri, 29 Apr 2016 22:42:48 +0000 (+0000) Subject: Allow arp_open to be called publically. X-Git-Tag: v6.11.0~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea3c0d5105dd94522a4a2a8d16fdfeb17859621f;p=thirdparty%2Fdhcpcd.git Allow arp_open to be called publically. --- diff --git a/arp.c b/arp.c index 5dec96b2..20fcd7ae 100644 --- a/arp.c +++ b/arp.c @@ -172,8 +172,13 @@ arp_packet(void *arg) memcmp(hw_s, ifn->hwaddr, ifn->hwlen) == 0) break; } - if (ifn) + if (ifn) { +#if 0 + logger(ifp->ctx, LOG_DEBUG, + "%s: ignoring ARP from self", ifp->name); +#endif continue; + } /* Copy out the HW and IP addresses */ memcpy(&arm.sha, hw_s, ar.ar_hln); memcpy(&arm.sip.s_addr, hw_s + ar.ar_hln, ar.ar_pln); @@ -188,7 +193,7 @@ arp_packet(void *arg) } } -static void +int arp_open(struct interface *ifp) { struct iarp_state *state; @@ -199,10 +204,11 @@ arp_open(struct interface *ifp) if (state->fd == -1) { logger(ifp->ctx, LOG_ERR, "%s: %s: %m", __func__, ifp->name); - return; + return -1; } eloop_event_add(ifp->ctx->eloop, state->fd, arp_packet, ifp); } + return state->fd; } static void @@ -246,7 +252,11 @@ void arp_announce(struct arp_state *astate) { - arp_open(astate->iface); + if (arp_open(astate->iface) == -1) { + logger(astate->iface->ctx, LOG_ERR, + "%s: %s: %m", __func__, astate->iface->name); + return; + } astate->claims = 0; arp_announce1(astate); } @@ -290,7 +300,11 @@ void arp_probe(struct arp_state *astate) { - arp_open(astate->iface); + if (arp_open(astate->iface) == -1) { + logger(astate->iface->ctx, LOG_ERR, + "%s: %s: %m", __func__, astate->iface->name); + return; + } astate->probes = 0; logger(astate->iface->ctx, LOG_DEBUG, "%s: probing for %s", astate->iface->name, inet_ntoa(astate->addr)); diff --git a/arp.h b/arp.h index c63cc730..b9636662 100644 --- a/arp.h +++ b/arp.h @@ -77,6 +77,7 @@ struct iarp_state { ((const struct iarp_state *)(ifp)->if_data[IF_DATA_ARP]) #ifdef INET +int arp_open(struct interface *); ssize_t arp_request(const struct interface *, in_addr_t, in_addr_t); void arp_report_conflicted(const struct arp_state *, const struct arp_msg *); void arp_announce(struct arp_state *);