From 954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85 Mon Sep 17 00:00:00 2001 From: jlemon Date: Sat, 25 Nov 2000 07:35:38 +0000 Subject: 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. --- sys/net/if_atmsubr.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'sys/net/if_atmsubr.c') diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index 3c04db5..4d71d57 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -203,17 +203,8 @@ atm_output(ifp, m0, dst, rt0) * Queue message on interface, and start output if interface * not yet active. */ - s = splimp(); - if (IF_QFULL(&ifp->if_snd)) { - IF_DROP(&ifp->if_snd); - splx(s); - senderr(ENOBUFS); - } - ifp->if_obytes += m->m_pkthdr.len; - IF_ENQUEUE(&ifp->if_snd, m); - if ((ifp->if_flags & IFF_OACTIVE) == 0) - (*ifp->if_start)(ifp); - splx(s); + if (! IF_HANDOFF(&ifp->if_snd, m, ifp)) + return (ENOBUFS); return (error); bad: @@ -301,13 +292,7 @@ atm_input(ifp, ah, m, rxhand) } } - s = splimp(); - if (IF_QFULL(inq)) { - IF_DROP(inq); - m_freem(m); - } else - IF_ENQUEUE(inq, m); - splx(s); + (void) IF_HANDOFF(inq, m, NULL); } /* -- cgit v1.1