From: Roy Marples Date: Fri, 15 Sep 2017 11:56:09 +0000 (+0100) Subject: arp: RFC5227 kernels need to send ARP too X-Git-Tag: v7.0.0-rc2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0f8b27884ee11d679fe39ee1372019be05fe980;p=thirdparty%2Fdhcpcd.git arp: RFC5227 kernels need to send ARP too Now that IP address sharing is handled with ARP announcements. This fixes the issue where RFC5227 kernels would fail to compile if not compiled for ARPING as well. --- diff --git a/src/arp.c b/src/arp.c index c35e00d1..6e68bbb6 100644 --- a/src/arp.c +++ b/src/arp.c @@ -52,7 +52,7 @@ #include "ipv4ll.h" #include "logerr.h" -#if defined(ARP) && (!defined(KERNEL_RFC5227) || defined(ARPING)) +#if defined(ARP) #define ARP_LEN \ (sizeof(struct arphdr) + (2 * sizeof(uint32_t)) + (2 * HWADDR_LEN)) @@ -281,8 +281,6 @@ arp_probe(struct arp_state *astate) astate->iface->name, inet_ntoa(astate->addr)); arp_probe1(astate); } -#else /* !ARP */ -#define arp_close(ifp) {} #endif /* ARP */ static void diff --git a/src/arp.h b/src/arp.h index db9ee950..c1b06cda 100644 --- a/src/arp.h +++ b/src/arp.h @@ -85,14 +85,11 @@ struct iarp_state { #define ARP_CSTATE(ifp) \ ((const struct iarp_state *)(ifp)->if_data[IF_DATA_ARP]) -#if defined(ARP) && (!defined(KERNEL_RFC5227) || defined(ARPING)) +#ifdef ARP int arp_open(struct interface *); ssize_t arp_request(const struct interface *, in_addr_t, in_addr_t); void arp_probe(struct arp_state *); void arp_close(struct interface *); -#endif - -#ifdef ARP void arp_report_conflicted(const struct arp_state *, const struct arp_msg *); struct arp_state *arp_new(struct interface *, const struct in_addr *); struct arp_state *arp_find(struct interface *, const struct in_addr *); @@ -104,7 +101,5 @@ void arp_free_but(struct arp_state *); void arp_drop(struct interface *); void arp_handleifa(int, struct ipv4_addr *); -#else -#define arp_drop(a) {} -#endif -#endif +#endif /* ARP */ +#endif /* ARP_H */ diff --git a/src/dhcp.c b/src/dhcp.c index 789c9aa3..959d58f4 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -1893,7 +1893,7 @@ dhcp_expire(void *arg) dhcp_expire1(ifp); } -#ifdef ARP +#if defined(ARP) || defined(IN_IFF_DUPLICATED) static void dhcp_decline(struct interface *ifp) { @@ -2086,9 +2086,11 @@ dhcp_arp_conflicted(struct arp_state *astate, const struct arp_msg *amsg) astate->failed = astate->addr; arp_report_conflicted(astate, amsg); unlink(state->leasefile); +#ifdef ARP if (!(ifp->options->options & DHCPCD_STATIC) && !state->lease.frominfo) dhcp_decline(ifp); +#endif #ifdef IN_IFF_DUPLICATED if ((ia = ipv4_iffindaddr(ifp, &astate->addr, NULL)) != NULL) ipv4_deladdr(ia, 1); @@ -2959,7 +2961,9 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len, case 0: LOGDHCP(logwarnx, "IPv4LL disabled from"); ipv4ll_drop(ifp); +#ifdef ARP arp_drop(ifp); +#endif break; case 1: LOGDHCP(logwarnx, "IPv4LL enabled from"); @@ -3359,7 +3363,9 @@ dhcp_free(struct interface *ifp) struct dhcpcd_ctx *ctx; dhcp_close(ifp); +#ifdef ARP arp_drop(ifp); +#endif if (state) { state->state = DHS_NONE; free(state->old); @@ -3747,10 +3753,10 @@ dhcp_start(struct interface *ifp) void dhcp_abort(struct interface *ifp) { -#ifdef ARPING struct dhcp_state *state; state = D_STATE(ifp); +#ifdef ARPING if (state != NULL) state->arping_index = -1; #endif diff --git a/src/dhcpcd.c b/src/dhcpcd.c index f134b718..8b3ac1b5 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -368,7 +368,9 @@ dhcpcd_drop(struct interface *ifp, int stop) ipv6_drop(ifp); ipv4ll_drop(ifp); dhcp_drop(ifp, stop ? "STOP" : "EXPIRE"); +#ifdef ARP arp_drop(ifp); +#endif } static void @@ -719,7 +721,9 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags, ifp->carrier = LINK_DOWN; script_runreason(ifp, "NOCARRIER"); #ifdef NOCARRIER_PRESERVE_IP +#ifdef ARP arp_drop(ifp); +#endif dhcp_abort(ifp); ipv6nd_expire(ifp, 0); #else