]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
arp: RFC5227 kernels need to send ARP too
authorRoy Marples <roy@marples.name>
Fri, 15 Sep 2017 11:56:09 +0000 (12:56 +0100)
committerRoy Marples <roy@marples.name>
Fri, 15 Sep 2017 11:56:09 +0000 (12:56 +0100)
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.

src/arp.c
src/arp.h
src/dhcp.c
src/dhcpcd.c

index c35e00d1c2f2e98cfb018504d4beaf0a4b1acdac..6e68bbb66af072de2e63374c8428aa01bf39545a 100644 (file)
--- 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
index db9ee95082e13339c9f5c645d04ca610c5274127..c1b06cda479c3cc8b44e438c34ae9588c7c5e701 100644 (file)
--- 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 */
index 789c9aa3f5dd226e04d227fc3716a6ab4997ad16..959d58f4ac5c6e6f5259bd7a9ac5ca09e8dbd1ab 100644 (file)
@@ -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
index f134b7186d632197d85b67fcf6b9aab9bfc84a55..8b3ac1b5baacc2605ca30da6c6ddd56248a97c80 100644 (file)
@@ -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