diff options
author | jlemon <jlemon@FreeBSD.org> | 2000-11-25 07:35:38 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 2000-11-25 07:35:38 +0000 |
commit | 954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85 (patch) | |
tree | 0a4e9f6dcd5fa64a78f5991ac425f3ca97aba154 /sys/net/bridge.c | |
parent | 2daca11cae375091daf49a7cd704e5e4e1be27db (diff) | |
download | FreeBSD-src-954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85.zip FreeBSD-src-954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85.tar.gz |
Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.
IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.
Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.
Diffstat (limited to 'sys/net/bridge.c')
-rw-r--r-- | sys/net/bridge.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/sys/net/bridge.c b/sys/net/bridge.c index 72747f2..00fce3a 100644 --- a/sys/net/bridge.c +++ b/sys/net/bridge.c @@ -830,23 +830,11 @@ forward: if (m == NULL) return ENOBUFS; bcopy(eh, mtod(m, struct ether_header *), ETHER_HDR_LEN); - s = splimp(); - if (IF_QFULL(&last->if_snd)) { - IF_DROP(&last->if_snd); + if (! IF_HANDOFF(&last->if_snd, m, last)) { #if 0 MUTE(last); /* should I also mute ? */ #endif - splx(s); - m_freem(m); /* consume the pkt anyways */ error = ENOBUFS ; - } else { - last->if_obytes += m->m_pkthdr.len ; - if (m->m_flags & M_MCAST) - last->if_omcasts++; - IF_ENQUEUE(&last->if_snd, m); - if ((last->if_flags & IFF_OACTIVE) == 0) - (*last->if_start)(last); - splx(s); } BDG_STAT(last, BDG_OUT); last = NULL ; @@ -857,7 +845,7 @@ forward: break ; if (ifp != src && /* do not send to self */ USED(ifp) && /* if used for bridging */ - ! IF_QFULL(&ifp->if_snd) && + ! _IF_QFULL(&ifp->if_snd) && (ifp->if_flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING) && SAMECLUSTER(ifp, src) && !MUTED(ifp) ) |