Mercurial > hg > dhcpcd
changeset 5005:ffb5b2280ed2 draft
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.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Sat, 25 Jan 2020 13:27:36 +0000 |
| parents | 8abc8f810b83 |
| children | 8f08888b3c0f |
| files | src/dhcpcd.c |
| diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcpcd.c Wed Jan 22 19:25:14 2020 +0000 +++ b/src/dhcpcd.c Sat Jan 25 13:27:36 2020 +0000 @@ -728,10 +728,14 @@ #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) {
