]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add PROBE state so we can reject DHCP messages whilst probing.
authorRoy Marples <roy@marples.name>
Thu, 7 Jan 2016 16:15:02 +0000 (16:15 +0000)
committerRoy Marples <roy@marples.name>
Thu, 7 Jan 2016 16:15:02 +0000 (16:15 +0000)
Another fix for [4728faad35] and [07675d4330].

Remove RTV_MTU check here as it's not correct (mistakenly added to this commit).

dhcp.c
dhcp.h
if-bsd.c

diff --git a/dhcp.c b/dhcp.c
index 46f89e62443e28bba52fbcf368c3bd8716b5a54b..b098b9a450f41b6516226431bce4d3462cbd6a5e 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -2170,14 +2170,15 @@ dhcp_message_new(const struct in_addr *addr, const struct in_addr *mask)
 static int
 dhcp_arp_address(struct interface *ifp)
 {
-       const struct dhcp_state *state;
+       struct dhcp_state *state;
        struct in_addr addr;
        struct ipv4_addr *ia;
        struct arp_state *astate;
 
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
 
-       state = D_CSTATE(ifp);
+       state = D_STATE(ifp);
+       state->state = DHS_PROBE;
        addr.s_addr = state->offer->yiaddr == INADDR_ANY ?
            state->offer->ciaddr : state->offer->yiaddr;
        /* If the interface already has the address configured
@@ -2641,7 +2642,7 @@ dhcp_handledhcp(struct interface *ifp, struct dhcp_message **dhcpp,
                /* Before we supported FORCERENEW we closed off the raw
                 * port so we effectively ignored all messages.
                 * As such we'll not log by default here. */
-               //log_dhcp(LOG_DEBUG, "bound, ignoring", iface, dhcp, from);
+               //log_dhcp(LOG_DEBUG, "bound, ignoring", ifp, dhcp, from);
                return;
        }
 
@@ -2653,6 +2654,13 @@ dhcp_handledhcp(struct interface *ifp, struct dhcp_message **dhcpp,
                    inet_ntoa(*from));
                return;
        }
+
+       if (state->state == DHS_PROBE) {
+               /* Ignore any DHCP messages whilst probing a lease to bind. */
+               log_dhcp(LOG_DEBUG, "probing, ignoring", ifp, dhcp, from);
+               return;
+       }
+
        /* reset the message counter */
        state->interval = 0;
 
diff --git a/dhcp.h b/dhcp.h
index 2bbf3db3d40048bc42644bb0c5e3331cc5904fd4..efc97a0c92c4dc40150e9306abc5164e7199e229 100644 (file)
--- a/dhcp.h
+++ b/dhcp.h
@@ -189,6 +189,7 @@ enum DHS {
        DHS_INIT,
        DHS_DISCOVER,
        DHS_REQUEST,
+       DHS_PROBE,
        DHS_BOUND,
        DHS_RENEW,
        DHS_REBIND,
index b3c160b89ed69c6443e4d54845bdec28d0b3da4e..9f63a3454518723247ade785168ace817d56afee 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -493,9 +493,7 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct rt_msghdr *rtm)
                rt->net.s_addr = INADDR_BROADCAST;
        COPYOUT(rt->gate, rti_info[RTAX_GATEWAY]);
        COPYOUT(rt->src, rti_info[RTAX_IFA]);
-
-       if (rtm->rtm_inits & RTV_MTU)
-               rt->mtu = (unsigned int)rtm->rtm_rmx.rmx_mtu;
+       rt->mtu = (unsigned int)rtm->rtm_rmx.rmx_mtu;
 
        if (rtm->rtm_index)
                rt->iface = if_findindex(ctx->ifaces, rtm->rtm_index);
@@ -886,9 +884,7 @@ if_copyrt6(struct dhcpcd_ctx *ctx, struct rt6 *rt, struct rt_msghdr *rtm)
        } else
                ipv6_mask(&rt->net, 128);
        COPYOUT6(rt->gate, rti_info[RTAX_GATEWAY]);
-
-       if (rtm->rtm_inits & RTV_MTU)
-               rt->mtu = (unsigned int)rtm->rtm_rmx.rmx_mtu;
+       rt->mtu = (unsigned int)rtm->rtm_rmx.rmx_mtu;
 
        if (rtm->rtm_index)
                rt->iface = if_findindex(ctx->ifaces, rtm->rtm_index);