summaryrefslogtreecommitdiffstats
path: root/sys/net/if_loop.c
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2000-11-25 07:35:38 +0000
committerjlemon <jlemon@FreeBSD.org>2000-11-25 07:35:38 +0000
commit954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85 (patch)
tree0a4e9f6dcd5fa64a78f5991ac425f3ca97aba154 /sys/net/if_loop.c
parent2daca11cae375091daf49a7cd704e5e4e1be27db (diff)
downloadFreeBSD-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/if_loop.c')
-rw-r--r--sys/net/if_loop.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 21f9695..a76466b 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -207,8 +207,8 @@ if_simloop(ifp, m, af, hlen)
int af;
int hlen;
{
- int s, isr;
- register struct ifqueue *ifq = 0;
+ int isr;
+ struct ifqueue *inq = 0;
KASSERT((m->m_flags & M_PKTHDR) != 0, ("if_simloop: no HDR"));
m->m_pkthdr.rcvif = ifp;
@@ -261,32 +261,32 @@ if_simloop(ifp, m, af, hlen)
switch (af) {
#ifdef INET
case AF_INET:
- ifq = &ipintrq;
+ inq = &ipintrq;
isr = NETISR_IP;
break;
#endif
#ifdef INET6
case AF_INET6:
m->m_flags |= M_LOOP;
- ifq = &ip6intrq;
+ inq = &ip6intrq;
isr = NETISR_IPV6;
break;
#endif
#ifdef IPX
case AF_IPX:
- ifq = &ipxintrq;
+ inq = &ipxintrq;
isr = NETISR_IPX;
break;
#endif
#ifdef NS
case AF_NS:
- ifq = &nsintrq;
+ inq = &nsintrq;
isr = NETISR_NS;
break;
#endif
#ifdef NETATALK
case AF_APPLETALK:
- ifq = &atintrq2;
+ inq = &atintrq2;
isr = NETISR_ATALK;
break;
#endif NETATALK
@@ -295,18 +295,10 @@ if_simloop(ifp, m, af, hlen)
m_freem(m);
return (EAFNOSUPPORT);
}
- s = splimp();
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
- m_freem(m);
- splx(s);
- return (ENOBUFS);
- }
- IF_ENQUEUE(ifq, m);
- schednetisr(isr);
ifp->if_ipackets++;
ifp->if_ibytes += m->m_pkthdr.len;
- splx(s);
+ (void) IF_HANDOFF(inq, m, NULL);
+ schednetisr(isr);
return (0);
}
OpenPOWER on IntegriCloud