diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-07-18 16:55:46 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-07-18 16:55:46 +0000 |
commit | e11e852d543aa406f0dcc3d72a625f42369d800c (patch) | |
tree | 00048222471599cfa918cd1294924cfab8eb7d6b /sys/net/if_atmsubr.c | |
parent | 32252b633fbaaf2e3a098f36c1c7846a7bedeb0c (diff) | |
download | FreeBSD-src-e11e852d543aa406f0dcc3d72a625f42369d800c.zip FreeBSD-src-e11e852d543aa406f0dcc3d72a625f42369d800c.tar.gz |
Lock down netnatm and mark as MPSAFE:
- Introduce a subsystem mutex, natm_mtx, manipulated with accessor macros
NATM_LOCK_INIT(), NATM_LOCK(), NATM_UNLOCK(), NATM_LOCK_ASSERT(). It
protects the consistency of pcb-related data structures. Finer grained
locking is possible, but should be done in the context of specific
measurements (as very little work is done in netnatm -- most is in the
ATM device driver or socket layer, so there's probably not much
contention).
- Remove GIANT_REQUIRED, mark as NETISR_MPSAFE, remove
NET_NEEDS_GIANT("netnatm").
- Conditionally acquire Giant when entering network interfaces for
ifp->if_ioctl() using IFF_LOCKGIANT(ifp)/IFF_UNLOCKGIANT(ifp) in order
to coexist with non-MPSAFE atm ifnet drivers..
- De-spl.
MFC after: 2 weeks
Reviewed by: harti, bms (various versions)
Diffstat (limited to 'sys/net/if_atmsubr.c')
-rw-r--r-- | sys/net/if_atmsubr.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index 1350f5a..07df91c 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -256,9 +256,6 @@ atm_input(struct ifnet *ifp, struct atm_pseudohdr *ah, struct mbuf *m, { int isr; u_int16_t etype = ETHERTYPE_IP; /* default */ -#ifdef NATM - int s; -#endif if ((ifp->if_flags & IFF_UP) == 0) { m_freem(m); @@ -284,13 +281,19 @@ atm_input(struct ifnet *ifp, struct atm_pseudohdr *ah, struct mbuf *m, if (rxhand) { #ifdef NATM - struct natmpcb *npcb = rxhand; + struct natmpcb *npcb; - s = splimp(); /* in case 2 atm cards @ diff lvls */ + /* + * XXXRW: this use of 'rxhand' is not a very good idea, and + * was subject to races even before SMPng due to the release + * of spl here. + */ + NATM_LOCK(); + npcb = rxhand; npcb->npcb_inq++; /* count # in queue */ - splx(s); isr = NETISR_NATM; m->m_pkthdr.rcvif = rxhand; /* XXX: overload */ + NATM_UNLOCK(); #else printf("atm_input: NATM detected but not " "configured in kernel\n"); |