Do some re-sorting of TCP pcbinfo locking and assertions: make sure to

retain the pcbinfo lock until we're done using a pcb in the in-bound
path, as the pcbinfo lock acts as a pseuo-reference to prevent the pcb
from potentially being recycled.  Clean up assertions and make sure to
assert that the pcbinfo is locked at the head of code subsections where
it is needed.  Free the mbuf at the end of tcp_input after releasing
any held locks to reduce the time the locks are held.

MFC after:	3 weeks
This commit is contained in:
Robert Watson 2004-11-07 19:19:35 +00:00
parent f47958407c
commit d6915262af
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=137349
2 changed files with 10 additions and 12 deletions

View File

@ -1151,7 +1151,6 @@ tcp_input(m, off0)
((tcp_do_newreno || tp->sack_enable) &&
!IN_FASTRECOVERY(tp)))) {
KASSERT(headlocked, ("headlocked"));
INP_INFO_WUNLOCK(&tcbinfo);
/*
* this is a pure ack for outstanding data.
*/
@ -1239,7 +1238,6 @@ tcp_input(m, off0)
LIST_EMPTY(&tp->t_segq) &&
tlen <= sbspace(&so->so_rcv)) {
KASSERT(headlocked, ("headlocked"));
INP_INFO_WUNLOCK(&tcbinfo);
/*
* this is a pure, in-sequence data packet
* with nothing on the reassembly queue and
@ -2371,7 +2369,6 @@ tcp_input(m, off0)
break;
}
}
INP_INFO_WUNLOCK(&tcbinfo);
#ifdef TCPDEBUG
if (so->so_options & SO_DEBUG)
tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen,
@ -2385,6 +2382,7 @@ tcp_input(m, off0)
(void) tcp_output(tp);
check_delack:
KASSERT(headlocked == 1, ("headlocked should be 1"));
INP_LOCK_ASSERT(inp);
if (tp->t_flags & TF_DELACK) {
tp->t_flags &= ~TF_DELACK;
@ -2392,6 +2390,7 @@ tcp_input(m, off0)
tcp_timer_delack, tp);
}
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&tcbinfo);
return;
dropafterack:
@ -2422,11 +2421,11 @@ tcp_input(m, off0)
&tcp_savetcp, 0);
#endif
KASSERT(headlocked, ("headlocked should be 1"));
INP_INFO_WUNLOCK(&tcbinfo);
m_freem(m);
tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&tcbinfo);
m_freem(m);
return;
dropwithreset:
@ -2491,9 +2490,9 @@ tcp_input(m, off0)
#endif
if (tp)
INP_UNLOCK(inp);
m_freem(m);
if (headlocked)
INP_INFO_WUNLOCK(&tcbinfo);
m_freem(m);
return;
}

View File

@ -1151,7 +1151,6 @@ tcp_input(m, off0)
((tcp_do_newreno || tp->sack_enable) &&
!IN_FASTRECOVERY(tp)))) {
KASSERT(headlocked, ("headlocked"));
INP_INFO_WUNLOCK(&tcbinfo);
/*
* this is a pure ack for outstanding data.
*/
@ -1239,7 +1238,6 @@ tcp_input(m, off0)
LIST_EMPTY(&tp->t_segq) &&
tlen <= sbspace(&so->so_rcv)) {
KASSERT(headlocked, ("headlocked"));
INP_INFO_WUNLOCK(&tcbinfo);
/*
* this is a pure, in-sequence data packet
* with nothing on the reassembly queue and
@ -2371,7 +2369,6 @@ tcp_input(m, off0)
break;
}
}
INP_INFO_WUNLOCK(&tcbinfo);
#ifdef TCPDEBUG
if (so->so_options & SO_DEBUG)
tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen,
@ -2385,6 +2382,7 @@ tcp_input(m, off0)
(void) tcp_output(tp);
check_delack:
KASSERT(headlocked == 1, ("headlocked should be 1"));
INP_LOCK_ASSERT(inp);
if (tp->t_flags & TF_DELACK) {
tp->t_flags &= ~TF_DELACK;
@ -2392,6 +2390,7 @@ tcp_input(m, off0)
tcp_timer_delack, tp);
}
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&tcbinfo);
return;
dropafterack:
@ -2422,11 +2421,11 @@ tcp_input(m, off0)
&tcp_savetcp, 0);
#endif
KASSERT(headlocked, ("headlocked should be 1"));
INP_INFO_WUNLOCK(&tcbinfo);
m_freem(m);
tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&tcbinfo);
m_freem(m);
return;
dropwithreset:
@ -2491,9 +2490,9 @@ tcp_input(m, off0)
#endif
if (tp)
INP_UNLOCK(inp);
m_freem(m);
if (headlocked)
INP_INFO_WUNLOCK(&tcbinfo);
m_freem(m);
return;
}