From: Roy Marples Date: Tue, 19 Feb 2019 23:15:43 +0000 (+0000) Subject: DHCP: Dont close ARP gratuitously X-Git-Tag: v7.2.0~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ad201b5d86a3738e7a1cbb458bbf6939e548b7a;p=thirdparty%2Fdhcpcd.git DHCP: Dont close ARP gratuitously Note we may wish to handle ACD for DHCP in the future. --- diff --git a/src/arp.c b/src/arp.c index 4e1e114a..cbcefa8d 100644 --- a/src/arp.c +++ b/src/arp.c @@ -175,17 +175,18 @@ arp_packet(struct interface *ifp, uint8_t *data, size_t len) } } -void +static void arp_close(struct interface *ifp) { struct iarp_state *state; - if ((state = ARP_STATE(ifp)) != NULL && state->bpf_fd != -1) { - eloop_event_delete(ifp->ctx->eloop, state->bpf_fd); - bpf_close(ifp, state->bpf_fd); - state->bpf_fd = -1; - state->bpf_flags |= BPF_EOF; - } + if ((state = ARP_STATE(ifp)) == NULL || state->bpf_fd == -1) + return; + + eloop_event_delete(ifp->ctx->eloop, state->bpf_fd); + bpf_close(ifp, state->bpf_fd); + state->bpf_fd = -1; + state->bpf_flags |= BPF_EOF; } static void diff --git a/src/arp.h b/src/arp.h index d5e8c468..1c0be043 100644 --- a/src/arp.h +++ b/src/arp.h @@ -90,7 +90,6 @@ struct iarp_state { 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 *); 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 *); diff --git a/src/dhcp.c b/src/dhcp.c index 29e27dc4..d0f9a453 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -2062,11 +2062,6 @@ dhcp_arp_probed(struct arp_state *astate) return; } arp_free(astate); -#ifdef KERNEL_RFC5227 - /* As arping is finished, close the ARP socket. - * The kernel will handle ACD from here. */ - arp_close(ifp); -#endif dhcpcd_startinterface(ifp); return; } @@ -2144,11 +2139,6 @@ dhcp_arp_conflicted(struct arp_state *astate, const struct arp_msg *amsg) return; } arp_free(astate); -#ifdef KERNEL_RFC5227 - /* As arping is finished, close the ARP socket. - * The kernel will handle ACD from here. */ - arp_close(ifp); -#endif eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); dhcpcd_startinterface(ifp); return; @@ -2208,8 +2198,10 @@ static void dhcp_arp_announced(struct arp_state *state) { - /* Free the ARP state as we currently don't care about ACD for DHCP. */ +// TODO: DHCP addresses handle ACD? +//#ifdef KERNEL_RFC5227 arp_free(state); +//#endif } #endif