summaryrefslogtreecommitdiffstats
path: root/sys/net/if_sl.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_sl.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_sl.c')
-rw-r--r--sys/net/if_sl.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 45483bb..50888ee 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -291,6 +291,7 @@ slcreate()
sc->sc_fastq.ifq_maxlen = 32;
sc->sc_if.if_linkmib = sc;
sc->sc_if.if_linkmiblen = sizeof *sc;
+ mtx_init(&sc->sc_fastq.ifq_mtx, "sl_fastq", MTX_DEF);
/*
* Find a suitable unit number.
@@ -372,6 +373,7 @@ sldestroy(struct sl_softc *sc) {
if_detach(&sc->sc_if);
LIST_REMOVE(sc, sl_next);
m_free(sc->sc_mbuf);
+ mtx_destroy(&sc->sc_fastq.ifq_mtx);
FREE(sc, M_SL);
}
@@ -560,15 +562,11 @@ sloutput(ifp, m, dst, rtp)
}
if (ip->ip_tos & IPTOS_LOWDELAY)
ifq = &sc->sc_fastq;
- s = splimp();
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
- m_freem(m);
- splx(s);
+ if (! IF_HANDOFF(ifq, m, NULL)) {
sc->sc_if.if_oerrors++;
return (ENOBUFS);
}
- IF_ENQUEUE(ifq, m);
+ s = splimp();
if (sc->sc_ttyp->t_outq.c_cc == 0)
slstart(sc->sc_ttyp);
splx(s);
@@ -824,7 +822,6 @@ slinput(c, tp)
register struct sl_softc *sc;
register struct mbuf *m;
register int len;
- int s;
u_char chdr[CHDR_LEN];
tk_nin++;
@@ -955,17 +952,12 @@ slinput(c, tp)
goto newpack;
}
- s = splimp();
- if (IF_QFULL(&ipintrq)) {
- IF_DROP(&ipintrq);
+ if (! IF_HANDOFF(&ipintrq, m, NULL)) {
sc->sc_if.if_ierrors++;
sc->sc_if.if_iqdrops++;
- m_freem(m);
} else {
- IF_ENQUEUE(&ipintrq, m);
schednetisr(NETISR_IP);
}
- splx(s);
goto newpack;
}
if (sc->sc_mp < sc->sc_ep) {
OpenPOWER on IntegriCloud