Date: Sun, 28 Sep 2003 21:25:37 -0700 (PDT) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 38770 for review Message-ID: <200309290425.h8T4PbCh025063@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=38770 Change 38770 by sam@sam_ebb on 2003/09/28 21:24:35 eliminate recursion on the SAHTREE lock Affected files ... .. //depot/projects/netperf/sys/netipsec/key.c#9 edit Differences ... ==== //depot/projects/netperf/sys/netipsec/key.c#9 (text+ko) ==== @@ -2903,7 +2903,7 @@ u_int stateidx, state; sav = NULL; - SAHTREE_LOCK(); + SAHTREE_LOCK_ASSERT(); /* search all status */ for (stateidx = 0; stateidx < _ARRAYLEN(saorder_state_alive); @@ -2924,7 +2924,6 @@ break; } } - SAHTREE_UNLOCK(); return sav; } @@ -4688,7 +4687,10 @@ return key_senderror(so, m, ENOENT); } #else - if ((sav = key_getsavbyspi(sah, sa0->sadb_sa_spi)) == NULL) { + SAHTREE_LOCK(); + sav = key_getsavbyspi(sah, sa0->sadb_sa_spi); + SAHTREE_UNLOCK(); + if (sav == NULL) { ipseclog((LOG_DEBUG, "%s: no such a SA found (spi:%u)\n", __func__, (u_int32_t)ntohl(sa0->sadb_sa_spi))); return key_senderror(so, m, EINVAL); @@ -4880,7 +4882,10 @@ /* create new SA entry. */ /* We can create new SA only if SPI is differenct. */ - if (key_getsavbyspi(newsah, sa0->sadb_sa_spi)) { + SAHTREE_LOCK(); + newsav = key_getsavbyspi(newsah, sa0->sadb_sa_spi); + SAHTREE_UNLOCK(); + if (newsav != NULL) { ipseclog((LOG_DEBUG, "%s: SA already exists.\n", __func__)); return key_senderror(so, m, EEXIST); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200309290425.h8T4PbCh025063>