Since pfslowtimo() runs in the network epoch, tcp_slowtimo()

also does.  This allows to simplify tcp_tw_2msl_scan() and
always require the network epoch in it.
This commit is contained in:
Gleb Smirnoff 2019-11-07 21:28:46 +00:00
parent 032677ceb5
commit a81e3ecf46

View File

@ -689,25 +689,8 @@ tcp_tw_2msl_scan(int reuse)
{ {
struct tcptw *tw; struct tcptw *tw;
struct inpcb *inp; struct inpcb *inp;
struct epoch_tracker et;
#ifdef INVARIANTS NET_EPOCH_ASSERT();
if (reuse) {
/*
* Exclusive pcbinfo lock is not required in reuse case even if
* two inpcb locks can be acquired simultaneously:
* - the inpcb transitioning to TIME_WAIT state in
* tcp_tw_start(),
* - the inpcb closed by tcp_twclose().
*
* It is because only inpcbs in FIN_WAIT2 or CLOSING states can
* transition in TIME_WAIT state. Then a pcbcb cannot be in
* TIME_WAIT list and transitioning to TIME_WAIT state at same
* time.
*/
INP_INFO_RLOCK_ASSERT(&V_tcbinfo);
}
#endif
for (;;) { for (;;) {
TW_RLOCK(V_tw_lock); TW_RLOCK(V_tw_lock);
@ -723,12 +706,10 @@ tcp_tw_2msl_scan(int reuse)
in_pcbref(inp); in_pcbref(inp);
TW_RUNLOCK(V_tw_lock); TW_RUNLOCK(V_tw_lock);
INP_INFO_RLOCK_ET(&V_tcbinfo, et);
INP_WLOCK(inp); INP_WLOCK(inp);
tw = intotw(inp); tw = intotw(inp);
if (in_pcbrele_wlocked(inp)) { if (in_pcbrele_wlocked(inp)) {
if (__predict_true(tw == NULL)) { if (__predict_true(tw == NULL)) {
INP_INFO_RUNLOCK_ET(&V_tcbinfo, et);
continue; continue;
} else { } else {
/* This should not happen as in TIMEWAIT /* This should not happen as in TIMEWAIT
@ -747,7 +728,6 @@ tcp_tw_2msl_scan(int reuse)
"|| inp last reference) && tw != " "|| inp last reference) && tw != "
"NULL", __func__); "NULL", __func__);
#endif #endif
INP_INFO_RUNLOCK_ET(&V_tcbinfo, et);
break; break;
} }
} }
@ -755,12 +735,10 @@ tcp_tw_2msl_scan(int reuse)
if (tw == NULL) { if (tw == NULL) {
/* tcp_twclose() has already been called */ /* tcp_twclose() has already been called */
INP_WUNLOCK(inp); INP_WUNLOCK(inp);
INP_INFO_RUNLOCK_ET(&V_tcbinfo, et);
continue; continue;
} }
tcp_twclose(tw, reuse); tcp_twclose(tw, reuse);
INP_INFO_RUNLOCK_ET(&V_tcbinfo, et);
if (reuse) if (reuse)
return tw; return tw;
} }