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/i4b/layer2 | |
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/i4b/layer2')
-rw-r--r-- | sys/i4b/layer2/i4b_l2.c | 3 | ||||
-rw-r--r-- | sys/i4b/layer2/i4b_mbuf.c | 16 | ||||
-rw-r--r-- | sys/i4b/layer2/i4b_util.c | 2 |
3 files changed, 5 insertions, 16 deletions
diff --git a/sys/i4b/layer2/i4b_l2.c b/sys/i4b/layer2/i4b_l2.c index 59a09ba..b3f79a6 100644 --- a/sys/i4b/layer2/i4b_l2.c +++ b/sys/i4b/layer2/i4b_l2.c @@ -163,7 +163,7 @@ int i4b_dl_data_req(int unit, struct mbuf *m) case ST_MULTIFR: case ST_TIMREC: - if(IF_QFULL(&l2sc->i_queue)) + if(_IF_QFULL(&l2sc->i_queue)) { NDBGL2(L2_ERROR, "i_queue full!!"); i4b_Dfreembuf(m); @@ -277,6 +277,7 @@ i4b_mph_status_ind(int unit, int status, int parm) case STI_ATTACH: l2sc->unit = unit; l2sc->i_queue.ifq_maxlen = IQUEUE_MAXLEN; + mtx_init(&l2sc->i_queue.ifq_mtx, "i4b_l2sc", MTX_DEF); l2sc->ua_frame = NULL; bzero(&l2sc->stat, sizeof(lapdstat_t)); i4b_l2_unit_init(unit); diff --git a/sys/i4b/layer2/i4b_mbuf.c b/sys/i4b/layer2/i4b_mbuf.c index a0f1013..0537a5e 100644 --- a/sys/i4b/layer2/i4b_mbuf.c +++ b/sys/i4b/layer2/i4b_mbuf.c @@ -140,15 +140,9 @@ i4b_Dfreembuf(struct mbuf *m) void i4b_Dcleanifq(struct ifqueue *ifq) { - struct mbuf *m; int x = splimp(); - while(!IF_QEMPTY(ifq)) - { - IF_DEQUEUE(ifq, m); - i4b_Dfreembuf(m); - } - + IF_DRAIN(ifq); splx(x); } @@ -222,15 +216,9 @@ i4b_Bfreembuf(struct mbuf *m) void i4b_Bcleanifq(struct ifqueue *ifq) { - struct mbuf *m; int x = splimp(); - while(!IF_QEMPTY(ifq)) - { - IF_DEQUEUE(ifq, m); - i4b_Bfreembuf(m); - } - + IF_DRAIN(ifq); splx(x); } diff --git a/sys/i4b/layer2/i4b_util.c b/sys/i4b/layer2/i4b_util.c index 982760d..0569a84 100644 --- a/sys/i4b/layer2/i4b_util.c +++ b/sys/i4b/layer2/i4b_util.c @@ -182,7 +182,7 @@ i4b_invoke_retransmission(l2_softc_t *l2sc, int nr) if((l2sc->ua_num != UA_EMPTY) && (l2sc->vs == l2sc->ua_num)) { - if(IF_QFULL(&l2sc->i_queue)) + if(_IF_QFULL(&l2sc->i_queue)) { NDBGL2(L2_ERROR, "ERROR, I-queue full!"); } |