From 6fb206e1e9f8f2e247e313f7f53378ae120d1504 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Thu, 14 Feb 2019 18:19:14 +0000 Subject: Use timeout_barrier() when bringing the bridge(4) down and only execute the timeout handler if the interface is running. ok claudio@ --- sys/net/bridgectl.c | 6 +++++- sys/net/if_bridge.c | 19 +++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'sys/net') diff --git a/sys/net/bridgectl.c b/sys/net/bridgectl.c index ffc47f950fb..4f27669fd92 100644 --- a/sys/net/bridgectl.c +++ b/sys/net/bridgectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bridgectl.c,v 1.13 2018/12/12 14:19:15 mpi Exp $ */ +/* $OpenBSD: bridgectl.c,v 1.14 2019/02/14 18:19:13 mpi Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -321,11 +321,15 @@ void bridge_rtage(void *vsc) { struct bridge_softc *sc = vsc; + struct ifnet *ifp = &sc->sc_if; struct bridge_rtnode *n, *p; int i; KERNEL_ASSERT_LOCKED(); + if (!ISSET(ifp->if_flags, IFF_RUNNING)) + return; + for (i = 0; i < BRIDGE_RTABLE_SIZE; i++) { n = LIST_FIRST(&sc->sc_rts[i]); while (n != NULL) { diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 3c59874b615..ca8f61acde1 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.320 2019/02/14 17:51:25 mpi Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.321 2019/02/14 18:19:13 mpi Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -682,14 +682,15 @@ bridge_init(struct bridge_softc *sc) { struct ifnet *ifp = &sc->sc_if; - if ((ifp->if_flags & IFF_RUNNING) == IFF_RUNNING) + if (ISSET(ifp->if_flags, IFF_RUNNING)) return; - ifp->if_flags |= IFF_RUNNING; bstp_initialization(sc->sc_stp); if (sc->sc_brttimeout != 0) timeout_add_sec(&sc->sc_brtimeout, sc->sc_brttimeout); + + SET(ifp->if_flags, IFF_RUNNING); } /* @@ -700,17 +701,15 @@ bridge_stop(struct bridge_softc *sc) { struct ifnet *ifp = &sc->sc_if; - /* - * If we're not running, there's nothing to do. - */ - if ((ifp->if_flags & IFF_RUNNING) == 0) + if (!ISSET(ifp->if_flags, IFF_RUNNING)) return; - timeout_del(&sc->sc_brtimeout); + CLR(ifp->if_flags, IFF_RUNNING); - bridge_rtflush(sc, IFBF_FLUSHDYN); + if (!timeout_del(&sc->sc_brtimeout)) + timeout_barrier(&sc->sc_brtimeout); - ifp->if_flags &= ~IFF_RUNNING; + bridge_rtflush(sc, IFBF_FLUSHDYN); } /* -- cgit v1.2.3