diff options
author | 2006-05-28 01:14:15 +0000 | |
---|---|---|
committer | 2006-05-28 01:14:15 +0000 | |
commit | 50f51b7c06e5ed849879e68ce1f3587d9ba955f3 (patch) | |
tree | fa14b8020f8c7b015655b1463c5e77fb8e674277 | |
parent | cleanup whitespaces, tabs are so much nicer (diff) | |
download | wireguard-openbsd-50f51b7c06e5ed849879e68ce1f3587d9ba955f3.tar.xz wireguard-openbsd-50f51b7c06e5ed849879e68ce1f3587d9ba955f3.zip |
check if the interface is active and UP. some, but not all, network
drivers report an active link state even if the interface is DOWN.
this should fix trunk with various ethernet devices.
ok brad@
-rw-r--r-- | sys/net/if_trunk.c | 10 | ||||
-rw-r--r-- | sys/net/if_trunk.h | 8 |
2 files changed, 12 insertions, 6 deletions
diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index b6957723b23..3723febfb03 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.28 2006/05/23 04:56:55 reyk Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.29 2006/05/28 01:14:15 reyk Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -568,7 +568,7 @@ trunk_port2req(struct trunk_port *tp, struct trunk_reqport *rp) strlcpy(rp->rp_portname, tp->tp_if->if_xname, sizeof(rp->rp_portname)); rp->rp_prio = tp->tp_prio; rp->rp_flags = tp->tp_flags; - if (tp->tp_link_state != LINK_STATE_DOWN) + if (TRUNK_PORTACTIVE(tp)) rp->rp_flags |= TRUNK_PORT_ACTIVE; } @@ -1025,19 +1025,19 @@ trunk_link_active(struct trunk_softc *tr, struct trunk_port *tp) if (tp == NULL) goto search; - if (tp->tp_link_state != LINK_STATE_DOWN) { + if (TRUNK_PORTACTIVE(tp)) { rval = tp; goto found; } if ((tp_next = SLIST_NEXT(tp, tp_entries)) != NULL && - tp_next->tp_link_state != LINK_STATE_DOWN) { + TRUNK_PORTACTIVE(tp_next)) { rval = tp_next; goto found; } search: SLIST_FOREACH(tp_next, &tr->tr_ports, tp_entries) { - if (tp_next->tp_link_state != LINK_STATE_DOWN) { + if (TRUNK_PORTACTIVE(tp_next)) { rval = tp_next; goto found; } diff --git a/sys/net/if_trunk.h b/sys/net/if_trunk.h index 6049b0db17c..92a70187a26 100644 --- a/sys/net/if_trunk.h +++ b/sys/net/if_trunk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.h,v 1.9 2006/05/23 04:35:52 reyk Exp $ */ +/* $OpenBSD: if_trunk.h,v 1.10 2006/05/28 01:14:15 reyk Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -110,9 +110,15 @@ struct trunk_port { }; #define tp_ifname tp_if->if_xname /* interface name */ +#define tp_ifflags tp_if->if_flags /* interface flags */ #define tp_link_state tp_if->if_link_state /* link state */ #define tp_capabilities tp_if->if_capabilities /* capabilities */ +#define TRUNK_PORTACTIVE(_tp) ( \ + ((_tp)->tp_link_state != LINK_STATE_DOWN) && \ + ((_tp)->tp_ifflags & IFF_UP) \ +) + struct trunk_mc { union { struct ether_multi *mcu_enm; |