| 1496 | } |
| 1497 | |
| 1498 | void |
| 1499 | tcp_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) && |
nothing calls this directly
no test coverage detected