diff src/dhcpcd.c @ 5574:2a519da0f1a2 draft

DHCP: Split hardware address randomisation out of anonymous option A 3rd party might want to control the randomisation.
author Roy Marples <roy@marples.name>
date Mon, 28 Dec 2020 00:02:26 +0000
parents f32e37b1d371
children
line wrap: on
line diff
--- a/src/dhcpcd.c	Sun Dec 27 23:52:44 2020 +0000
+++ b/src/dhcpcd.c	Mon Dec 28 00:02:26 2020 +0000
@@ -734,9 +734,7 @@
 		 * Preserve the network state until we either disconnect
 		 * or re-connect.
 		 */
-		if (!(ifp->options->options & DHCPCD_ANONYMOUS) &&
-		    if_roaming(ifp))
-		{
+		if (!ifp->options->randomise_hwaddr && if_roaming(ifp)) {
 			dhcpcd_nocarrier_roaming(ifp);
 			return;
 		}
@@ -745,7 +743,7 @@
 		script_runreason(ifp, "NOCARRIER");
 		dhcpcd_drop(ifp, 0);
 
-		if (ifp->options->options & DHCPCD_ANONYMOUS) {
+		if (ifp->options->randomise_hwaddr) {
 			bool is_up = ifp->flags & IFF_UP;
 
 			if (is_up)
@@ -971,22 +969,22 @@
 {
 	struct interface *ifp = arg;
 	struct dhcpcd_ctx *ctx = ifp->ctx;
-	bool anondown;
+	bool randmac_down;
 
 	if (ifp->carrier <= LINK_DOWN &&
-	    ifp->options->options & DHCPCD_ANONYMOUS &&
+	    ifp->options->randomise_hwaddr &&
 	    ifp->flags & IFF_UP)
 	{
 		if_down(ifp);
-		anondown = true;
+		randmac_down = true;
 	} else
-		anondown = false;
+		randmac_down = false;
 
 	if ((!(ctx->options & DHCPCD_MASTER) ||
-	    ifp->options->options & DHCPCD_IF_UP || anondown) &&
+	    ifp->options->options & DHCPCD_IF_UP || randmac_down) &&
 	    !(ifp->flags & IFF_UP))
 	{
-		if (ifp->options->options & DHCPCD_ANONYMOUS &&
+		if (ifp->options->randomise_hwaddr &&
 		    if_randomisemac(ifp) == -1)
 			logerr(__func__);
 		if (if_up(ifp) == -1)