diff options
| author | Julien Charbon <jch@FreeBSD.org> | 2017-10-01 21:20:28 +0000 |
|---|---|---|
| committer | Julien Charbon <jch@FreeBSD.org> | 2017-10-01 21:20:28 +0000 |
| commit | dfa1f80ce9b4465811be9437c7db95bd41adab61 (patch) | |
| tree | 4faf33c5beec7f759788bf49891f9a74fe8f5a54 /sys/netinet | |
| parent | 6a2f82bdf8060d7037fa5c2a99a1fc508edd780e (diff) | |
Notes
Diffstat (limited to 'sys/netinet')
| -rw-r--r-- | sys/netinet/tcp_timewait.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 81725c7560fd..1345a2f878b0 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -709,10 +709,29 @@ tcp_tw_2msl_scan(int reuse) INP_WLOCK(inp); tw = intotw(inp); if (in_pcbrele_wlocked(inp)) { - KASSERT(tw == NULL, ("%s: held last inp " - "reference but tw not NULL", __func__)); - INP_INFO_RUNLOCK(&V_tcbinfo); - continue; + if (__predict_true(tw == NULL)) { + INP_INFO_RUNLOCK(&V_tcbinfo); + continue; + } else { + /* This should not happen as in TIMEWAIT + * state the inp should not be destroyed + * before its tcptw. If INVARIANTS is + * defined panic. + */ +#ifdef INVARIANTS + panic("%s: Panic before an infinite " + "loop: INP_TIMEWAIT && (INP_FREED " + "|| inp last reference) && tw != " + "NULL", __func__); +#else + log(LOG_ERR, "%s: Avoid an infinite " + "loop: INP_TIMEWAIT && (INP_FREED " + "|| inp last reference) && tw != " + "NULL", __func__); +#endif + INP_INFO_RUNLOCK(&V_tcbinfo); + break; + } } if (tw == NULL) { |
