diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2006-11-24 11:50:33 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2006-11-24 11:50:33 +0000 |
commit | 2e37005e33b1ab74053f390d46313cbefe2212ad (patch) | |
tree | b9d8d43d3a011ae6f6015dac8d2cfc7f077e9d0b /sys/net/bridgestp.c | |
parent | 835cf6f5c8c6c55b8f123213b37a544fab566ded (diff) |
never call an ioctl without process context! this diffs checks the
ifp->if_link_state instead of calling the ifmedia ioctl. this is safe
in timeouts without process context and allows to use bridge stp with
usb ethernet devices now.
figured out and tested by Stuart Henderson, closes pr 5304.
Diffstat (limited to 'sys/net/bridgestp.c')
-rw-r--r-- | sys/net/bridgestp.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index 4f567ea3cb8..a621f86c1c4 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bridgestp.c,v 1.21 2006/03/07 18:21:10 brad Exp $ */ +/* $OpenBSD: bridgestp.c,v 1.22 2006/11/24 11:50:32 reyk Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -1088,38 +1088,15 @@ bstp_ifupdstatus(sc, bif) struct bridge_iflist *bif; { struct ifnet *ifp = bif->ifp; - struct ifmediareq ifmr; - int err; - - if (ifp->if_flags & IFF_UP) { - ifmr.ifm_count = 0; - err = (*ifp->if_ioctl)(ifp, SIOCGIFMEDIA, (caddr_t)&ifmr); - if (err) { - if (bif->bif_state == BSTP_IFSTATE_DISABLED) - bstp_enable_port(sc, bif); - return; - } - - if (!(ifmr.ifm_status & IFM_AVALID)) { - if (bif->bif_state == BSTP_IFSTATE_DISABLED) - bstp_enable_port(sc, bif); - return; - } - - if (ifmr.ifm_status & IFM_ACTIVE) { - if (bif->bif_state == BSTP_IFSTATE_DISABLED) - bstp_enable_port(sc, bif); - return; - } + if ((ifp->if_flags & IFF_UP) && + ifp->if_link_state != LINK_STATE_DOWN) { + if (bif->bif_state == BSTP_IFSTATE_DISABLED) + bstp_enable_port(sc, bif); + } else { if (bif->bif_state != BSTP_IFSTATE_DISABLED) bstp_disable_port(sc, bif); - - return; } - - if (bif->bif_state != BSTP_IFSTATE_DISABLED) - bstp_disable_port(sc, bif); } void |