From: Roy Marples Date: Sat, 25 Jan 2020 13:27:36 +0000 (+0000) Subject: dhcpcd: For anonymous do not bring interface up if was down X-Git-Tag: v9.0.0~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cf5dcbe7ada18172db8414ce4e699f8eb84b3c5;p=thirdparty%2Fdhcpcd.git dhcpcd: For anonymous do not bring interface up if was down We need to bring the interface down on carrier loss to change the hardware address, but we should only bring it up again if it was up previously. After all it's really an administrative flag. --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index df2aff95..20ade526 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -728,10 +728,14 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags, #endif dhcpcd_drop(ifp, 0); if (ifp->options->options & DHCPCD_ANONYMOUS) { - if_down(ifp); + bool was_up = ifp->flags & IFF_UP; + + if (was_up) + if_down(ifp); if (if_randomisemac(ifp) == -1 && errno != ENXIO) logerr(__func__); - if_up(ifp); + if (was_up) + if_up(ifp); } } } else if (carrier == LINK_UP && ifp->flags & IFF_UP) {