dhcpcd-discuss

Problem with IPv6 router solicitations on a ppp interface

David Williams

Sat May 20 09:05:12 2017

Hello all,

I've been having a problem with router solicitations sent out by dhcpcd onto a ppp interface being ignored. I did some captures and found that dhcpcd was adding a source address option with all zeros which is against my understanding of RFC4861. I've patched the router solicitation routine to detect an all zero hardware address and omit the source address option in that case. Please find attached patch.

As background the ppp interface was set up using pppd version 2.4.7 on Gentoo Linux 4.7.10-hardened.

Hope this is useful.

cheers

David

--- dhcpcd-6.11.3/ipv6nd.c	2016-08-15 11:53:49.000000000 +0100
+++ dhcpcd-6.11.3-r2/ipv6nd.c	2017-05-19 14:24:59.639828233 +0100
@@ -237,9 +237,17 @@
 	struct nd_router_solicit *rs;
 	struct nd_opt_hdr *nd;
 
+	size_t ihwp;
 	state = RS_STATE(ifp);
 	free(state->rs);
-	state->rslen = sizeof(*rs) + (size_t)ROUNDUP8(ifp->hwlen + 2);
+	state->rslen = sizeof(*rs);
+	/* check for hwadd full of zeros */
+	for (ihwp=0; ihwp < ifp->hwlen; ihwp++) {
+		if (ifp->hwaddr[ihwp]) {
+			state->rslen += (size_t)ROUNDUP8(ifp->hwlen + 2);
+			break;
+		}
+	}
 	state->rs = calloc(1, state->rslen);
 	if (state->rs == NULL)
 		return -1;
@@ -248,10 +256,13 @@
 	rs->nd_rs_code = 0;
 	rs->nd_rs_cksum = 0;
 	rs->nd_rs_reserved = 0;
-	nd = (struct nd_opt_hdr *)(state->rs + sizeof(*rs));
-	nd->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
-	nd->nd_opt_len = (uint8_t)((ROUNDUP8(ifp->hwlen + 2)) >> 3);
-	memcpy(nd + 1, ifp->hwaddr, ifp->hwlen);
+	/* add source address option if valid hwaddr */
+	if (ihwp < ifp->hwlen) {
+		nd = (struct nd_opt_hdr *)(state->rs + sizeof(*rs));
+		nd->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
+		nd->nd_opt_len = (uint8_t)((ROUNDUP8(ifp->hwlen + 2)) >> 3);
+		memcpy(nd + 1, ifp->hwaddr, ifp->hwlen);
+	}
 	return 0;
 }

Follow-Ups:
Re: Problem with IPv6 router solicitations on a ppp interfaceRoy Marples
Archive administrator: postmaster@marples.name