diff options
| author | Roy Marples <roy@marples.name> | 2019-01-26 00:08:43 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-01-26 00:08:43 +0000 |
| commit | 4f903d6ad4adf2de7712d36a921051b4dfd7210a (patch) | |
| tree | 6c1b535d692ae0c96d5a4cb9a70bdb82ad23e9fa /src/if.c | |
| parent | 700fd4e3d3cc65602427816f7446dada757d0538 (diff) | |
| download | dhcpcd-4f903d6ad4adf2de7712d36a921051b4dfd7210a.tar.xz | |
BSD: treat LINK_STATE_UNKNOWN as DOWN if media is invalid
On BSD, some interfaces might emit RTM_IFINFO before the link state
has initialised. Mainly wireless cards.
If the intial carrier call says media state change is valid,
we need to treat LINK_STATE_UNKNOWN as LINK_DOWN rather than
LINK_UP.
Diffstat (limited to 'src/if.c')
| -rw-r--r-- | src/if.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -155,9 +155,13 @@ if_carrier(struct interface *ifp) strlcpy(ifmr.ifm_name, ifp->name, sizeof(ifmr.ifm_name)); if (ioctl(ifp->ctx->pf_inet_fd, SIOCGIFMEDIA, &ifmr) != -1 && ifmr.ifm_status & IFM_AVALID) + { + ifp->media_valid = true; r = (ifmr.ifm_status & IFM_ACTIVE) ? LINK_UP : LINK_DOWN; - else + } else { + ifp->media_valid = false; r = ifr.ifr_flags & IFF_RUNNING ? LINK_UP : LINK_UNKNOWN; + } #else r = ifr.ifr_flags & IFF_RUNNING ? LINK_UP : LINK_DOWN; #endif @@ -592,7 +596,7 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, * we can work them out. */ ifp->metric = 200 + ifp->index; if (if_getssid(ifp) != -1) { - ifp->wireless = 1; + ifp->wireless = true; ifp->metric += 100; } #endif |
