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

Function tcp_usr_abort

freebsd/netinet/tcp_usrreq.c:1382–1420  ·  view source on GitHub ↗

* Abort the TCP. Drop the connection abruptly. */

Source from the content-addressed store, hash-verified

1380 * Abort the TCP. Drop the connection abruptly.
1381 */
1382static void
1383tcp_usr_abort(struct socket *so)
1384{
1385 struct inpcb *inp;
1386 struct tcpcb *tp = NULL;
1387 struct epoch_tracker et;
1388 TCPDEBUG0;
1389
1390 inp = sotoinpcb(so);
1391 KASSERT(inp != NULL, ("tcp_usr_abort: inp == NULL"));
1392
1393 NET_EPOCH_ENTER(et);
1394 INP_WLOCK(inp);
1395 KASSERT(inp->inp_socket != NULL,
1396 ("tcp_usr_abort: inp_socket == NULL"));
1397
1398 /*
1399 * If we still have full TCP state, and we're not dropped, drop.
1400 */
1401 if (!(inp->inp_flags & INP_TIMEWAIT) &&
1402 !(inp->inp_flags & INP_DROPPED)) {
1403 tp = intotcpcb(inp);
1404 TCPDEBUG1();
1405 tp = tcp_drop(tp, ECONNABORTED);
1406 if (tp == NULL)
1407 goto dropped;
1408 TCPDEBUG2(PRU_ABORT);
1409 TCP_PROBE2(debug__user, tp, PRU_ABORT);
1410 }
1411 if (!(inp->inp_flags & INP_DROPPED)) {
1412 SOCK_LOCK(so);
1413 so->so_state |= SS_PROTOREF;
1414 SOCK_UNLOCK(so);
1415 inp->inp_flags |= INP_SOCKREF;
1416 }
1417 INP_WUNLOCK(inp);
1418dropped:
1419 NET_EPOCH_EXIT(et);
1420}
1421
1422/*
1423 * TCP socket is closed. Start friendly disconnect.

Callers

nothing calls this directly

Calls 1

tcp_dropFunction · 0.85

Tested by

no test coverage detected