summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2006-11-24 11:50:32 +0000
committerreyk <reyk@openbsd.org>2006-11-24 11:50:32 +0000
commit334091d1b2ef436baf36b039e7f88cda9af4d995 (patch)
tree8d05355a35bc6c1cf309c768f7f3c1a25ecf4619
parentfix typo for remote port; from Brian Candler (diff)
downloadwireguard-openbsd-334091d1b2ef436baf36b039e7f88cda9af4d995.tar.xz
wireguard-openbsd-334091d1b2ef436baf36b039e7f88cda9af4d995.zip
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.
-rw-r--r--sys/net/bridgestp.c35
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