]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Remove the arp_state argument to dhcp_bind
authorRoy Marples <roy@marples.name>
Fri, 26 Jun 2015 13:21:38 +0000 (13:21 +0000)
committerRoy Marples <roy@marples.name>
Fri, 26 Jun 2015 13:21:38 +0000 (13:21 +0000)
dhcp.c
dhcp.h
ipv4.c

diff --git a/dhcp.c b/dhcp.c
index e3cfa758cf65571ba5d03b8daa3d77fd1e357921..a8da8190c510c4c40981be995448924f44b303c7 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -1914,7 +1914,7 @@ dhcp_arp_probed(struct arp_state *astate)
        ipv4_finaliseaddr(astate->iface);
        arp_close(astate->iface);
 #else
-       dhcp_bind(astate->iface, astate);
+       dhcp_bind(astate->iface);
 #endif
 
        /* Stop IPv4LL now we have a working DHCP address */
@@ -1991,11 +1991,12 @@ dhcp_arp_conflicted(struct arp_state *astate, const struct arp_msg *amsg)
 }
 
 void
-dhcp_bind(struct interface *ifp, struct arp_state *astate)
+dhcp_bind(struct interface *ifp)
 {
        struct dhcp_state *state = D_STATE(ifp);
        struct if_options *ifo = ifp->options;
        struct dhcp_lease *lease = &state->lease;
+       struct arp_state *astate;
 
        if (state->state == DHS_BOUND)
                goto applyaddr;
@@ -2110,9 +2111,8 @@ dhcp_bind(struct interface *ifp, struct arp_state *astate)
 
 applyaddr:
 #ifdef IN_IFF_TENTATIVE
-       if (astate == NULL) {
-               astate = arp_new(ifp, &lease->addr);
-               if (astate) {
+       if ((astate = arp_find(ifp, &lease->addr)) == NULL) {
+               if ((astate = arp_new(ifp, &lease->addr)) != NULL) {
                        astate->probed_cb = dhcp_arp_probed;
                        astate->conflicted_cb = dhcp_arp_conflicted;
                }
@@ -2151,7 +2151,7 @@ dhcp_timeout(void *arg)
        struct interface *ifp = arg;
        struct dhcp_state *state = D_STATE(ifp);
 
-       dhcp_bind(ifp, NULL);
+       dhcp_bind(ifp);
        state->interval = 0;
        dhcp_discover(ifp);
 }
@@ -2198,7 +2198,7 @@ dhcp_static(struct interface *ifp)
        state->offer = dhcp_message_new(&ifo->req_addr, &ifo->req_mask);
        if (state->offer) {
                eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
-               dhcp_bind(ifp, NULL);
+               dhcp_bind(ifp);
        }
 }
 
@@ -2234,7 +2234,7 @@ dhcp_inform(struct interface *ifp)
                            dhcp_message_new(&ifo->req_addr, &ifo->req_mask);
                if (state->offer) {
                        ifo->options |= DHCPCD_STATIC;
-                       dhcp_bind(ifp, NULL);
+                       dhcp_bind(ifp);
                        ifo->options &= ~DHCPCD_STATIC;
                }
        }
@@ -2487,7 +2487,6 @@ dhcp_handledhcp(struct interface *ifp, struct dhcp_message **dhcpp,
        unsigned int i;
        size_t auth_len;
        char *msg;
-       struct arp_state *astate;
        struct ipv4_addr *ia;
 
        /* We may have found a BOOTP server */
@@ -2777,7 +2776,6 @@ dhcp_handledhcp(struct interface *ifp, struct dhcp_message **dhcpp,
 
        lease->frominfo = 0;
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
-       astate = NULL;
 
 #ifndef IN_IFF_TENTATIVE
        if (ifo->options & DHCPCD_ARP
@@ -2788,6 +2786,8 @@ dhcp_handledhcp(struct interface *ifp, struct dhcp_message **dhcpp,
                 * then we can't ARP for duplicate detection. */
                ia = ipv4_findaddr(ifp->ctx, &addr);
                if (ia == NULL) {
+                       struct arp_state *astate;
+
                        astate = arp_new(ifp, &addr);
                        if (astate) {
                                astate->probed_cb = dhcp_arp_probed;
@@ -2799,7 +2799,7 @@ dhcp_handledhcp(struct interface *ifp, struct dhcp_message **dhcpp,
        }
 #endif
 
-       dhcp_bind(ifp, astate);
+       dhcp_bind(ifp);
 }
 
 static size_t
diff --git a/dhcp.h b/dhcp.h
index b23badf266627ef24cc0480290f323d95f3b8023..78c6a0ea51d1708900a03944cc10248318832df3 100644 (file)
--- a/dhcp.h
+++ b/dhcp.h
@@ -267,7 +267,7 @@ void dhcp_start(struct interface *);
 void dhcp_stop(struct interface *);
 void dhcp_discover(void *);
 void dhcp_inform(struct interface *);
-void dhcp_bind(struct interface *, struct arp_state *);
+void dhcp_bind(struct interface *);
 void dhcp_reboot_newopts(struct interface *, unsigned long long);
 void dhcp_close(struct interface *);
 void dhcp_free(struct interface *);
diff --git a/ipv4.c b/ipv4.c
index ae665db43632cd728466955201125f5a9c42acbf..5a2b56406de40600f893b25f4c7d90d982ed3830 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -934,7 +934,7 @@ ipv4_preferanother(struct interface *ifp)
                        preferred = 1;
                        delete_address(ifp);
                        if (ifn->options->options & DHCPCD_ARP)
-                               dhcp_bind(ifn, NULL);
+                               dhcp_bind(ifn);
                        else {
                                ipv4_daddaddr(ifn, &nstate->lease);
                                nstate->added = STATE_ADDED;