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/pc98 | |
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/pc98')
-rw-r--r-- | sys/pc98/cbus/olpt.c | 22 | ||||
-rw-r--r-- | sys/pc98/pc98/olpt.c | 22 |
2 files changed, 16 insertions, 28 deletions
diff --git a/sys/pc98/cbus/olpt.c b/sys/pc98/cbus/olpt.c index cd64512..a2c7fe6 100644 --- a/sys/pc98/cbus/olpt.c +++ b/sys/pc98/cbus/olpt.c @@ -1161,18 +1161,15 @@ lpintr (int unit) sc->sc_iferrs = 0; - if (IF_QFULL(&ipintrq)) { - lprintf(("DROP")); - IF_DROP(&ipintrq); - goto done; - } len -= CLPIPHDRLEN; sc->sc_if.if_ipackets++; sc->sc_if.if_ibytes += len; top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0); if (top) { - IF_ENQUEUE(&ipintrq, top); - schednetisr(NETISR_IP); + if (! IF_HANDOFF(&ipintrq, top, NULL)) + lprintf(("DROP")); + else + schednetisr(NETISR_IP); } goto done; } @@ -1210,11 +1207,6 @@ lpintr (int unit) sc->sc_iferrs = 0; - if (IF_QFULL(&ipintrq)) { - lprintf(("DROP")); - IF_DROP(&ipintrq); - goto done; - } if (sc->sc_if.if_bpf) { bpf_tap(&sc->sc_if, sc->sc_ifbuf, len); } @@ -1223,8 +1215,10 @@ lpintr (int unit) sc->sc_if.if_ibytes += len; top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0); if (top) { - IF_ENQUEUE(&ipintrq, top); - schednetisr(NETISR_IP); + if (! IF_HANDOFF(&ipintrq, top, NULL)) + lprintf(("DROP")); + else + schednetisr(NETISR_IP); } } goto done; diff --git a/sys/pc98/pc98/olpt.c b/sys/pc98/pc98/olpt.c index cd64512..a2c7fe6 100644 --- a/sys/pc98/pc98/olpt.c +++ b/sys/pc98/pc98/olpt.c @@ -1161,18 +1161,15 @@ lpintr (int unit) sc->sc_iferrs = 0; - if (IF_QFULL(&ipintrq)) { - lprintf(("DROP")); - IF_DROP(&ipintrq); - goto done; - } len -= CLPIPHDRLEN; sc->sc_if.if_ipackets++; sc->sc_if.if_ibytes += len; top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0); if (top) { - IF_ENQUEUE(&ipintrq, top); - schednetisr(NETISR_IP); + if (! IF_HANDOFF(&ipintrq, top, NULL)) + lprintf(("DROP")); + else + schednetisr(NETISR_IP); } goto done; } @@ -1210,11 +1207,6 @@ lpintr (int unit) sc->sc_iferrs = 0; - if (IF_QFULL(&ipintrq)) { - lprintf(("DROP")); - IF_DROP(&ipintrq); - goto done; - } if (sc->sc_if.if_bpf) { bpf_tap(&sc->sc_if, sc->sc_ifbuf, len); } @@ -1223,8 +1215,10 @@ lpintr (int unit) sc->sc_if.if_ibytes += len; top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0); if (top) { - IF_ENQUEUE(&ipintrq, top); - schednetisr(NETISR_IP); + if (! IF_HANDOFF(&ipintrq, top, NULL)) + lprintf(("DROP")); + else + schednetisr(NETISR_IP); } } goto done; |