diff options
author | thompsa <thompsa@FreeBSD.org> | 2012-04-20 09:55:50 +0000 |
---|---|---|
committer | thompsa <thompsa@FreeBSD.org> | 2012-04-20 09:55:50 +0000 |
commit | 5ffa03204ccf2735f460fb6731c0c73d0ac11d17 (patch) | |
tree | 5e720f1f10937bda6108ab3cf3fe0a0b81caa055 /sys/net/bridgestp.c | |
parent | 6152dc39f23cf9b5f8db831ea0d2de2e59e9feea (diff) | |
download | FreeBSD-src-5ffa03204ccf2735f460fb6731c0c73d0ac11d17.zip FreeBSD-src-5ffa03204ccf2735f460fb6731c0c73d0ac11d17.tar.gz |
Add linkstate to bridge(4), set the link to up when at least one underlying
interface is up, otherwise the link is down.
This, among other things, allows carp to work on a bridge.
Prodded by: glebius
Tested by: Alexander Lunev
Diffstat (limited to 'sys/net/bridgestp.c')
-rw-r--r-- | sys/net/bridgestp.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index 06d7f15..dd2aa09 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -1767,28 +1767,16 @@ bstp_notify_rtage(void *arg, int pending) } void -bstp_linkstate(struct ifnet *ifp, int state) +bstp_linkstate(struct bstp_port *bp) { - struct bstp_state *bs; - struct bstp_port *bp; + struct bstp_state *bs = bp->bp_bs; - /* search for the stp port */ - mtx_lock(&bstp_list_mtx); - LIST_FOREACH(bs, &bstp_list, bs_list) { - BSTP_LOCK(bs); - LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { - if (bp->bp_ifp == ifp) { - bstp_ifupdstatus(bs, bp); - bstp_update_state(bs, bp); - /* it only exists once so return */ - BSTP_UNLOCK(bs); - mtx_unlock(&bstp_list_mtx); - return; - } - } - BSTP_UNLOCK(bs); + BSTP_LOCK(bs); + if (bp->bp_active) { + bstp_ifupdstatus(bs, bp); + bstp_update_state(bs, bp); } - mtx_unlock(&bstp_list_mtx); + BSTP_UNLOCK(bs); } static void @@ -2103,10 +2091,8 @@ bstp_modevent(module_t mod, int type, void *data) case MOD_LOAD: mtx_init(&bstp_list_mtx, "bridgestp list", NULL, MTX_DEF); LIST_INIT(&bstp_list); - bstp_linkstate_p = bstp_linkstate; break; case MOD_UNLOAD: - bstp_linkstate_p = NULL; mtx_destroy(&bstp_list_mtx); break; default: |