changeset 3397:0ad62740fec2 draft

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).
author Roy Marples <roy@marples.name>
date Thu, 07 Jan 2016 16:15:02 +0000
parents 97f98b0547fc
children 2d56b47adb6b
files dhcp.c dhcp.h if-bsd.c
diffstat 3 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/dhcp.c	Thu Jan 07 13:15:04 2016 +0000
+++ b/dhcp.c	Thu Jan 07 16:15:02 2016 +0000
@@ -2170,14 +2170,15 @@
 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 @@
 		/* 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 @@
 		    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;
 
--- a/dhcp.h	Thu Jan 07 13:15:04 2016 +0000
+++ b/dhcp.h	Thu Jan 07 16:15:02 2016 +0000
@@ -189,6 +189,7 @@
 	DHS_INIT,
 	DHS_DISCOVER,
 	DHS_REQUEST,
+	DHS_PROBE,
 	DHS_BOUND,
 	DHS_RENEW,
 	DHS_REBIND,
--- a/if-bsd.c	Thu Jan 07 13:15:04 2016 +0000
+++ b/if-bsd.c	Thu Jan 07 16:15:02 2016 +0000
@@ -493,9 +493,7 @@
 		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 @@
 	} 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);