MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcp_twstart

Function tcp_twstart

freebsd/netinet/tcp_timewait.c:228–372  ·  view source on GitHub ↗

* Move a TCP connection into TIME_WAIT state. * tcbinfo is locked. * inp is locked, and is unlocked before returning. */

Source from the content-addressed store, hash-verified

226 * inp is locked, and is unlocked before returning.
227 */
228void
229tcp_twstart(struct tcpcb *tp)
230{
231 struct tcptw twlocal, *tw;
232 struct inpcb *inp = tp->t_inpcb;
233 struct socket *so;
234 uint32_t recwin;
235 bool acknow, local;
236#ifdef INET6
237 bool isipv6 = inp->inp_inc.inc_flags & INC_ISIPV6;
238#endif
239
240 NET_EPOCH_ASSERT();
241 INP_WLOCK_ASSERT(inp);
242
243 /* A dropped inp should never transition to TIME_WAIT state. */
244 KASSERT((inp->inp_flags & INP_DROPPED) == 0, ("tcp_twstart: "
245 "(inp->inp_flags & INP_DROPPED) != 0"));
246
247 if (V_nolocaltimewait) {
248#ifdef INET6
249 if (isipv6)
250 local = in6_localaddr(&inp->in6p_faddr);
251 else
252#endif
253#ifdef INET
254 local = in_localip(inp->inp_faddr);
255#else
256 local = false;
257#endif
258 } else
259 local = false;
260
261 /*
262 * For use only by DTrace. We do not reference the state
263 * after this point so modifying it in place is not a problem.
264 */
265 tcp_state_change(tp, TCPS_TIME_WAIT);
266
267 if (local)
268 tw = &twlocal;
269 else
270 tw = uma_zalloc(V_tcptw_zone, M_NOWAIT);
271 if (tw == NULL) {
272 /*
273 * Reached limit on total number of TIMEWAIT connections
274 * allowed. Remove a connection from TIMEWAIT queue in LRU
275 * fashion to make room for this connection.
276 *
277 * XXX: Check if it possible to always have enough room
278 * in advance based on guarantees provided by uma_zalloc().
279 */
280 tw = tcp_tw_2msl_scan(1);
281 if (tw == NULL) {
282 tp = tcp_close(tp);
283 if (tp != NULL)
284 INP_WUNLOCK(inp);
285 return;

Callers 5

tcp_do_segmentFunction · 0.85
rack_process_dataFunction · 0.85
rack_do_closingFunction · 0.85
bbr_process_dataFunction · 0.85
bbr_do_closingFunction · 0.85

Calls 15

in6_localaddrFunction · 0.85
in_localipFunction · 0.85
tcp_state_changeFunction · 0.85
tcp_tw_2msl_scanFunction · 0.85
tcp_closeFunction · 0.85
lminFunction · 0.85
lmaxFunction · 0.85
tcp_discardcbFunction · 0.85
soisdisconnectedFunction · 0.85
tcp_twrespondFunction · 0.85
in_pcbdropFunction · 0.85
in_pcbrefFunction · 0.85

Tested by

no test coverage detected