summaryrefslogtreecommitdiffstats
path: root/src/if.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-10-07 14:11:47 +0100
committerRoy Marples <roy@marples.name>2020-10-07 14:11:47 +0100
commit76b513c6ebf26ae0dfd320f742b945db76466ac0 (patch)
tree3911abc0ebd1a0757aa7459a3c82e4b5c460266f /src/if.c
parentf2b2cdfb7305245d17fd790db3bf366f34f6d596 (diff)
downloaddhcpcd-76b513c6ebf26ae0dfd320f742b945db76466ac0.tar.xz
dhcpcd: Simplify the link handling even more
Move the IS_LINK_UP macro to if_is_link_up function to reduce binary size. Rather than DHCPCD_LINK option controlling the carrier state, use it in if_is_link_up to determine the outcome.
Diffstat (limited to 'src/if.c')
-rw-r--r--src/if.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/if.c b/src/if.c
index 67586150..d21625ef 100644
--- a/src/if.c
+++ b/src/if.c
@@ -193,6 +193,17 @@ if_setflag(struct interface *ifp, short setflag, short unsetflag)
return 0;
}
+bool
+if_is_link_up(const struct interface *ifp)
+{
+
+ return ifp->flags & IFF_UP &&
+ (ifp->carrier == LINK_UP ||
+ (ifp->carrier == LINK_UNKNOWN &&
+ !(ifp->options == NULL ||
+ ifp->options->options & DHCPCD_LINK)));
+}
+
int
if_randomisemac(struct interface *ifp)
{
@@ -692,12 +703,6 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs,
ifp->active = active;
ifp->carrier = if_carrier(ifp, ifa->ifa_data);
-
- /* Wireless devices must support carrier change,
- * so treat UNKNOWN as down. */
- if (ifp->wireless && ifp->carrier == LINK_UNKNOWN)
- ifp->carrier = LINK_DOWN;
-
TAILQ_INSERT_TAIL(ifs, ifp, next);
}