summaryrefslogtreecommitdiffstats
path: root/sys/netatm
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/netatm
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/netatm')
-rw-r--r--sys/netatm/atm_device.c2
-rw-r--r--sys/netatm/atm_subr.c1
-rw-r--r--sys/netatm/ipatm/ipatm_input.c11
3 files changed, 4 insertions, 10 deletions
diff --git a/sys/netatm/atm_device.c b/sys/netatm/atm_device.c
index e458bf4..ecca8ad 100644
--- a/sys/netatm/atm_device.c
+++ b/sys/netatm/atm_device.c
@@ -314,6 +314,7 @@ atm_dev_lower(cmd, tok, arg1, arg2)
* Free any buffers from this VCC on the ATM interrupt queue
*/
prev = NULL;
+ IF_LOCK(&atm_intrq);
for (m = atm_intrq.ifq_head; m; m = next) {
next = KB_QNEXT(m);
@@ -344,6 +345,7 @@ atm_dev_lower(cmd, tok, arg1, arg2)
prev = m;
}
}
+ IF_UNLOCK(&atm_intrq);
(void) splx(s);
/*
diff --git a/sys/netatm/atm_subr.c b/sys/netatm/atm_subr.c
index e1478df..25003e6 100644
--- a/sys/netatm/atm_subr.c
+++ b/sys/netatm/atm_subr.c
@@ -135,6 +135,7 @@ atm_initialize()
atm_intrq.ifq_maxlen = ATM_INTRQ_MAX;
+ mtx_init(&atm_intrq.ifq_mtx, "atm_inq", MTX_DEF);
#ifdef sgi
atm_intr_index = register_isr(atm_intr);
#endif
diff --git a/sys/netatm/ipatm/ipatm_input.c b/sys/netatm/ipatm/ipatm_input.c
index 8480506..30f6326 100644
--- a/sys/netatm/ipatm/ipatm_input.c
+++ b/sys/netatm/ipatm/ipatm_input.c
@@ -127,7 +127,6 @@ ipatm_ipinput(inp, m)
struct ip_nif *inp;
KBuffer *m;
{
- int s;
#if BSD < 199103
int space;
#endif
@@ -207,16 +206,8 @@ ipatm_ipinput(inp, m)
* just call IP directly to avoid the extra unnecessary
* kernel scheduling.
*/
- s = splimp();
- if (IF_QFULL(&ipintrq)) {
- IF_DROP(&ipintrq);
- (void) splx(s);
- KB_FREEALL(m);
+ if (! IF_HANDOFF(&ipintrq, m, NULL))
return (1);
- }
-
- IF_ENQUEUE(&ipintrq, m);
- (void) splx(s);
#if BSD < 199506
ipintr();
#else
OpenPOWER on IntegriCloud