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

Function tcp_do_segment

freebsd/netinet/tcp_input.c:1498–3343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1496}
1497
1498void
1499tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
1500 struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos)
1501{
1502 int thflags, acked, ourfinisacked, needoutput = 0, sack_changed;
1503 int rstreason, todrop, win, incforsyn = 0;
1504 uint32_t tiwin;
1505 uint16_t nsegs;
1506 char *s;
1507 struct in_conninfo *inc;
1508 struct mbuf *mfree;
1509 struct tcpopt to;
1510 int tfo_syn;
1511
1512#ifdef TCPDEBUG
1513 /*
1514 * The size of tcp_saveipgen must be the size of the max ip header,
1515 * now IPv6.
1516 */
1517 u_char tcp_saveipgen[IP6_HDR_LEN];
1518 struct tcphdr tcp_savetcp;
1519 short ostate = 0;
1520#endif
1521 thflags = th->th_flags;
1522 inc = &tp->t_inpcb->inp_inc;
1523 tp->sackhint.last_sack_ack = 0;
1524 sack_changed = 0;
1525 nsegs = max(1, m->m_pkthdr.lro_nsegs);
1526
1527 NET_EPOCH_ASSERT();
1528 INP_WLOCK_ASSERT(tp->t_inpcb);
1529 KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN",
1530 __func__));
1531 KASSERT(tp->t_state != TCPS_TIME_WAIT, ("%s: TCPS_TIME_WAIT",
1532 __func__));
1533
1534#ifdef TCPPCAP
1535 /* Save segment, if requested. */
1536 tcp_pcap_add(th, m, &(tp->t_inpkts));
1537#endif
1538 TCP_LOG_EVENT(tp, th, &so->so_rcv, &so->so_snd, TCP_LOG_IN, 0,
1539 tlen, NULL, true);
1540
1541 if ((thflags & TH_SYN) && (thflags & TH_FIN) && V_drop_synfin) {
1542 if ((s = tcp_log_addrs(inc, th, NULL, NULL))) {
1543 log(LOG_DEBUG, "%s; %s: "
1544 "SYN|FIN segment ignored (based on "
1545 "sysctl setting)\n", s, __func__);
1546 free(s, M_TCPLOG);
1547 }
1548 goto drop;
1549 }
1550
1551 /*
1552 * If a segment with the ACK-bit set arrives in the SYN-SENT state
1553 * check SEQ.ACK first.
1554 */
1555 if ((tp->t_state == TCPS_SYN_SENT) && (thflags & TH_ACK) &&

Callers

nothing calls this directly

Calls 15

maxFunction · 0.85
tcp_pcap_addFunction · 0.85
tcp_log_addrsFunction · 0.85
cc_ecnpkt_handlerFunction · 0.85
cc_cong_signalFunction · 0.85
tcp_dooptionsFunction · 0.85
tcp_mssFunction · 0.85
tcp_xmit_timerFunction · 0.85
hhook_run_tcp_est_inFunction · 0.85

Tested by

no test coverage detected