From: Roy Marples Date: Thu, 7 Jan 2016 16:15:02 +0000 (+0000) Subject: Add PROBE state so we can reject DHCP messages whilst probing. X-Git-Tag: v6.10.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e9a6d97ef40148f9c3f31c766f792d7426b641c;p=thirdparty%2Fdhcpcd.git Add PROBE state so we can reject DHCP messages whilst probing. Another fix for [4728faad35] and [07675d4330]. Remove RTV_MTU check here as it's not correct (mistakenly added to this commit). --- diff --git a/dhcp.c b/dhcp.c index 46f89e62..b098b9a4 100644 --- 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 2bbf3db3..efc97a0c 100644 --- 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, diff --git a/if-bsd.c b/if-bsd.c index b3c160b8..9f63a345 100644 --- 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);