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.
#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) {