Mercurial > hg > dhcpcd
changeset 4498:29e8b4603296 draft
Fix a small brain fart causing LINK_UNKNOWN to spin.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 02 May 2019 21:48:52 +0100 |
| parents | 723efebcd287 |
| children | 94b77a3ab52f |
| files | src/dhcpcd.c |
| diffstat | 1 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcpcd.c Thu May 02 21:25:57 2019 +0100 +++ b/src/dhcpcd.c Thu May 02 21:48:52 2019 +0100 @@ -84,6 +84,9 @@ const size_t dhcpcd_signals_len = __arraycount(dhcpcd_signals); #endif +#define IF_UPANDRUNNING(a) \ + (((a)->flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING)) + static void usage(void) { @@ -714,8 +717,7 @@ } else ifp->flags = flags; if (carrier == LINK_UNKNOWN) - carrier = (ifp->flags & (IFF_UP | IFF_RUNNING)) == - (IFF_UP & IFF_RUNNING) ? LINK_UP : LINK_DOWN; + carrier = IF_UPANDRUNNING(ifp) ? LINK_UP : LINK_DOWN; if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) { if (ifp->carrier != LINK_DOWN) { @@ -832,7 +834,6 @@ struct if_options *ifo = ifp->options; char buf[DUID_LEN * 3]; int carrier; - struct timespec tv; if (ifo->options & DHCPCD_LINK) { switch (ifp->carrier) { @@ -844,14 +845,22 @@ case LINK_UNKNOWN: /* No media state available. * Loop until both IFF_UP and IFF_RUNNING are set */ - if ((carrier = if_carrier(ifp)) == LINK_UNKNOWN) { - tv.tv_sec = 0; - tv.tv_nsec = IF_POLL_UP * NSEC_PER_MSEC; - eloop_timeout_add_tv(ifp->ctx->eloop, - &tv, dhcpcd_startinterface, ifp); - } else - dhcpcd_handlecarrier(ifp->ctx, carrier, - ifp->flags, ifp->name); + carrier = if_carrier(ifp); + if (carrier == LINK_UNKNOWN) { + if (IF_UPANDRUNNING(ifp)) + carrier = LINK_UP; + else { + struct timespec tv; + + tv.tv_sec = 0; + tv.tv_nsec = IF_POLL_UP * NSEC_PER_MSEC; + eloop_timeout_add_tv(ifp->ctx->eloop, + &tv, dhcpcd_startinterface, ifp); + return; + } + } + dhcpcd_handlecarrier(ifp->ctx, carrier, + ifp->flags, ifp->name); return; } }
