summaryrefslogtreecommitdiffstats
path: root/sys/netatalk/aarp.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-02-22 14:20:29 +0000
committerrwatson <rwatson@FreeBSD.org>2005-02-22 14:20:29 +0000
commitd552b6fe480d4086e05aa88c4bcf23baf0c470a3 (patch)
treee491c0df9e3888bbb34db162823ab69087e3b44b /sys/netatalk/aarp.c
parentcd21b2e10ce05cf965e2989f557834034cf53854 (diff)
downloadFreeBSD-src-d552b6fe480d4086e05aa88c4bcf23baf0c470a3.zip
FreeBSD-src-d552b6fe480d4086e05aa88c4bcf23baf0c470a3.tar.gz
Convert the aa_ifaddr timeout to a callout, and run the aarprobe callout
MPSAFE. Acquire the aarptab_mtx to make sure that the callout and msleep in the ioctl thread don't race. MFC after: 1 week
Diffstat (limited to 'sys/netatalk/aarp.c')
-rw-r--r--sys/netatalk/aarp.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/netatalk/aarp.c b/sys/netatalk/aarp.c
index bdff6af..7e0c96a 100644
--- a/sys/netatalk/aarp.c
+++ b/sys/netatalk/aarp.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004 Robert N. M. Watson
+ * Copyright (c) 2004-2005 Robert N. M. Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -82,14 +82,9 @@ static void at_aarpinput(struct ifnet *ifp, struct mbuf *m);
#define AARPTAB_SIZE (AARPTAB_BSIZ * AARPTAB_NB)
static struct aarptab aarptab[AARPTAB_SIZE];
-static struct mtx aarptab_mtx;
+struct mtx aarptab_mtx;
MTX_SYSINIT(aarptab_mtx, &aarptab_mtx, "aarptab_mtx", MTX_DEF);
-#define AARPTAB_LOCK() mtx_lock(&aarptab_mtx)
-#define AARPTAB_UNLOCK() mtx_unlock(&aarptab_mtx)
-#define AARPTAB_LOCK_ASSERT() mtx_assert(&aarptab_mtx, MA_OWNED)
-#define AARPTAB_UNLOCK_ASSERT() mtx_assert(&aarptab_mtx, MA_NOTOWNED)
-
#define AARPTAB_HASH(a) \
((((a).s_net << 8) + (a).s_node) % AARPTAB_NB)
@@ -418,7 +413,7 @@ at_aarpinput(struct ifnet *ifp, struct mbuf *m)
* probed for the same address we'd like to use. Change the
* address we're probing for.
*/
- untimeout(aarpprobe, ifp, aa->aa_ch);
+ callout_stop(&aa->aa_callout);
wakeup(aa);
m_freem(m);
return;
@@ -593,6 +588,7 @@ aarpprobe(void *arg)
* interface with the same address as we're looking for. If the
* net is phase 2, generate an 802.2 and SNAP header.
*/
+ AARPTAB_LOCK();
for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ifp->if_addrhead); aa;
aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) {
if (AA_SAT(aa)->sat_family == AF_APPLETALK &&
@@ -601,6 +597,7 @@ aarpprobe(void *arg)
}
}
if (aa == NULL) { /* serious error XXX */
+ AARPTAB_UNLOCK();
printf("aarpprobe why did this happen?!\n");
return;
}
@@ -608,10 +605,12 @@ aarpprobe(void *arg)
if (aa->aa_probcnt <= 0) {
aa->aa_flags &= ~AFA_PROBING;
wakeup(aa);
+ AARPTAB_UNLOCK();
return;
} else {
- aa->aa_ch = timeout(aarpprobe, (caddr_t)ifp, hz / 5);
+ callout_reset(&aa->aa_callout, hz / 5, aarpprobe, ifp);
}
+ AARPTAB_UNLOCK();
if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) {
return;
OpenPOWER on IntegriCloud