Lines Matching refs:th

309 hhook_run_tcp_est_in(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to)  in hhook_run_tcp_est_in()  argument
315 hhook_data.th = th; in hhook_run_tcp_est_in()
328 cc_ack_received(struct tcpcb *tp, struct tcphdr *th, uint16_t nsegs, in cc_ack_received() argument
338 tp->ccv->bytes_this_ack = BYTES_THIS_ACK(tp, th); in cc_ack_received()
354 SEQ_GEQ(th->th_ack, tp->gput_ack)) { in cc_ack_received()
358 gput = (((int64_t)(th->th_ack - tp->gput_seq)) << 3) / in cc_ack_received()
390 tp->ccv->curack = th->th_ack; in cc_ack_received()
455 cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type) in cc_cong_signal() argument
477 SEQ_GEQ(th->th_ack, tp->snd_recover)) { in cc_cong_signal()
509 if (th != NULL) in cc_cong_signal()
510 tp->ccv->curack = th->th_ack; in cc_cong_signal()
516 cc_post_recovery(struct tcpcb *tp, struct tcphdr *th) in cc_post_recovery() argument
523 tp->ccv->curack = th->th_ack; in cc_post_recovery()
581 cc_ecnpkt_handler(struct tcpcb *tp, struct tcphdr *th, uint8_t iptos) in cc_ecnpkt_handler() argument
583 cc_ecnpkt_handler_flags(tp, th->th_flags, iptos); in cc_ecnpkt_handler()
642 struct tcphdr *th = NULL; in tcp_input_with_port() local
693 th = (struct tcphdr *)((caddr_t)ip6 + off0); in tcp_input_with_port()
699 th->th_sum = m->m_pkthdr.csum_data; in tcp_input_with_port()
701 th->th_sum = in6_cksum_pseudo(ip6, tlen, in tcp_input_with_port()
703 th->th_sum ^= 0xffff; in tcp_input_with_port()
705 th->th_sum = in6_cksum(m, IPPROTO_TCP, off0, tlen); in tcp_input_with_port()
706 if (th->th_sum) { in tcp_input_with_port()
747 th = (struct tcphdr *)((caddr_t)ip + off0); in tcp_input_with_port()
755 th->th_sum = m->m_pkthdr.csum_data; in tcp_input_with_port()
757 th->th_sum = in_pseudo(ip->ip_src.s_addr, in tcp_input_with_port()
761 th->th_sum ^= 0xffff; in tcp_input_with_port()
772 th->th_sum = in_cksum(m, len); in tcp_input_with_port()
783 if (th->th_sum && (port == 0)) { in tcp_input_with_port()
794 off = th->th_off << 2; in tcp_input_with_port()
811 th = (struct tcphdr *)((caddr_t)ip6 + off0); in tcp_input_with_port()
826 th = (struct tcphdr *)((caddr_t)ip + off0); in tcp_input_with_port()
831 optp = (u_char *)(th + 1); in tcp_input_with_port()
833 thflags = th->th_flags; in tcp_input_with_port()
838 tcp_fields_to_host(th); in tcp_input_with_port()
872 &ip6->ip6_src, th->th_sport, &ip6->ip6_dst, th->th_dport, in tcp_input_with_port()
881 th->th_sport, &next_hop6->sin6_addr, in tcp_input_with_port()
883 th->th_dport, INPLOOKUP_WILDCARD | in tcp_input_with_port()
888 th->th_sport, &ip6->ip6_dst, th->th_dport, in tcp_input_with_port()
905 inp = in_pcblookup_mbuf(&V_tcbinfo, ip->ip_src, th->th_sport, in tcp_input_with_port()
906 ip->ip_dst, th->th_dport, INPLOOKUP_WLOCKPCB, in tcp_input_with_port()
915 th->th_sport, next_hop->sin_addr, in tcp_input_with_port()
917 th->th_dport, INPLOOKUP_WILDCARD | in tcp_input_with_port()
922 th->th_sport, ip->ip_dst, th->th_dport, in tcp_input_with_port()
939 if ((s = tcp_log_vain(NULL, th, (void *)ip, ip6))) in tcp_input_with_port()
1025 if (tcp_twcheck(inp, &to, th, m, tlen)) in tcp_input_with_port()
1069 tcp_savetcp = *th; in tcp_input_with_port()
1096 inc.inc_fport = th->th_sport; in tcp_input_with_port()
1097 inc.inc_lport = th->th_dport; in tcp_input_with_port()
1116 rstreason = syncache_expand(&inc, &to, th, &so, m, port); in tcp_input_with_port()
1147 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1180 TCP_PROBE5(receive, NULL, tp, m, tp, th); in tcp_input_with_port()
1181 tp->t_fb->tfb_tcp_do_segment(m, th, so, tp, drop_hdrlen, tlen, in tcp_input_with_port()
1196 syncache_chkrst(&inc, th, m, port); in tcp_input_with_port()
1203 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1214 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1235 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1290 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1312 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1320 if (th->th_dport == th->th_sport && in tcp_input_with_port()
1322 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1330 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1343 if (th->th_dport == th->th_sport && in tcp_input_with_port()
1345 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1355 if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) in tcp_input_with_port()
1373 TCP_PROBE3(debug__input, tp, th, m); in tcp_input_with_port()
1375 if (syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL, iptos, in tcp_input_with_port()
1403 TCPMD5_INPUT(m, th, to.to_signature) != 0) in tcp_input_with_port()
1407 TCP_PROBE5(receive, NULL, tp, m, tp, th); in tcp_input_with_port()
1414 tp->t_fb->tfb_tcp_do_segment(m, th, so, tp, drop_hdrlen, tlen, iptos); in tcp_input_with_port()
1418 TCP_PROBE5(receive, NULL, tp, m, tp, th); in tcp_input_with_port()
1421 tcp_dropwithreset(m, th, tp, tlen, rstreason); in tcp_input_with_port()
1424 tcp_dropwithreset(m, th, NULL, tlen, rstreason); in tcp_input_with_port()
1430 TCP_PROBE5(receive, NULL, tp, m, tp, th); in tcp_input_with_port()
1483 tcp_autorcvbuf(struct mbuf *m, struct tcphdr *th, struct socket *so, in tcp_autorcvbuf() argument
1496 TCP_PROBE6(receive__autoresize, NULL, tp, m, tp, th, newsize); in tcp_autorcvbuf()
1536 tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, in tcp_do_segment() argument
1559 thflags = th->th_flags; in tcp_do_segment()
1574 tcp_pcap_add(th, m, &(tp->t_inpkts)); in tcp_do_segment()
1576 TCP_LOG_EVENT(tp, th, &so->so_rcv, &so->so_snd, TCP_LOG_IN, 0, in tcp_do_segment()
1580 if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { in tcp_do_segment()
1594 (SEQ_LEQ(th->th_ack, tp->iss) || SEQ_GT(th->th_ack, tp->snd_max))) { in tcp_do_segment()
1611 tiwin = th->th_win << tp->snd_scale; in tcp_do_segment()
1638 cc_ecnpkt_handler(tp, th, iptos); in tcp_do_segment()
1642 cc_cong_signal(tp, th, CC_ECN); in tcp_do_segment()
1649 tcp_dooptions(&to, (u_char *)(th + 1), in tcp_do_segment()
1650 (th->th_off << 2) - sizeof(struct tcphdr), in tcp_do_segment()
1674 cc_cong_signal(tp, th, CC_RTO_ERR); in tcp_do_segment()
1703 tp->snd_wnd = th->th_win; in tcp_do_segment()
1746 if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { in tcp_do_segment()
1753 if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { in tcp_do_segment()
1768 if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { in tcp_do_segment()
1793 th->th_seq == tp->rcv_nxt && in tcp_do_segment()
1808 SEQ_LEQ(th->th_seq, tp->last_ack_sent)) { in tcp_do_segment()
1814 if (SEQ_GT(th->th_ack, tp->snd_una) && in tcp_do_segment()
1815 SEQ_LEQ(th->th_ack, tp->snd_max) && in tcp_do_segment()
1832 cc_cong_signal(tp, th, CC_RTO_ERR); in tcp_do_segment()
1853 SEQ_GT(th->th_ack, tp->t_rtseq)) { in tcp_do_segment()
1860 acked = BYTES_THIS_ACK(tp, th); in tcp_do_segment()
1864 hhook_run_tcp_est_in(tp, th, &to); in tcp_do_segment()
1871 SEQ_LEQ(th->th_ack, tp->snd_recover)) in tcp_do_segment()
1872 tp->snd_recover = th->th_ack - 1; in tcp_do_segment()
1880 cc_ack_received(tp, th, nsegs, CC_ACK); in tcp_do_segment()
1882 tp->snd_una = th->th_ack; in tcp_do_segment()
1887 tp->snd_wl2 = th->th_ack; in tcp_do_segment()
1906 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
1917 } else if (th->th_ack == tp->snd_una && in tcp_do_segment()
1944 tp->snd_wl1 = th->th_seq; in tcp_do_segment()
1957 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
1959 newsize = tcp_autorcvbuf(m, th, so, tp, tlen); in tcp_do_segment()
2007 (SEQ_LEQ(th->th_ack, tp->snd_una) || in tcp_do_segment()
2008 SEQ_GT(th->th_ack, tp->snd_max))) { in tcp_do_segment()
2052 m, tp, th); in tcp_do_segment()
2060 tp->irs = th->th_seq; in tcp_do_segment()
2084 tp->snd_nxt = th->th_ack; in tcp_do_segment()
2117 m, tp, th); in tcp_do_segment()
2143 th->th_seq++; in tcp_do_segment()
2152 tp->snd_wl1 = th->th_seq - 1; in tcp_do_segment()
2153 tp->rcv_up = th->th_seq; in tcp_do_segment()
2204 if ((SEQ_GEQ(th->th_seq, tp->last_ack_sent) && in tcp_do_segment()
2205 SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) || in tcp_do_segment()
2206 (tp->rcv_wnd == 0 && tp->last_ack_sent == th->th_seq)) { in tcp_do_segment()
2209 __func__, th, tp)); in tcp_do_segment()
2212 tp->last_ack_sent == th->th_seq) { in tcp_do_segment()
2234 tcp_respond(tp, mtod(m, void *), th, m, in tcp_do_segment()
2251 SEQ_GEQ(th->th_seq, tp->last_ack_sent) && in tcp_do_segment()
2252 SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) { in tcp_do_segment()
2257 tcp_respond(tp, mtod(m, void *), th, m, tp->rcv_nxt, in tcp_do_segment()
2302 if (tp->t_state == TCPS_SYN_RECEIVED && SEQ_LT(th->th_seq, tp->irs)) { in tcp_do_segment()
2307 todrop = tp->rcv_nxt - th->th_seq; in tcp_do_segment()
2311 th->th_seq++; in tcp_do_segment()
2312 if (th->th_urp > 1) in tcp_do_segment()
2313 th->th_urp--; in tcp_do_segment()
2346 tcp_update_sack_list(tp, th->th_seq, in tcp_do_segment()
2347 th->th_seq + todrop); in tcp_do_segment()
2355 th->th_seq += todrop; in tcp_do_segment()
2357 if (th->th_urp > todrop) in tcp_do_segment()
2358 th->th_urp -= todrop; in tcp_do_segment()
2361 th->th_urp = 0; in tcp_do_segment()
2371 if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { in tcp_do_segment()
2388 todrop = (th->th_seq + tlen) - (tp->rcv_nxt + tp->rcv_wnd); in tcp_do_segment()
2400 if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) { in tcp_do_segment()
2431 SEQ_LEQ(th->th_seq, tp->last_ack_sent) && in tcp_do_segment()
2432 SEQ_LEQ(tp->last_ack_sent, th->th_seq + tlen + in tcp_do_segment()
2493 m, tp, th); in tcp_do_segment()
2510 if (SEQ_GT(th->th_ack, tp->snd_una) && !(tp->t_flags & TF_NEEDSYN)) in tcp_do_segment()
2521 tp->snd_wl1 = th->th_seq - 1; in tcp_do_segment()
2538 if (SEQ_GT(th->th_ack, tp->snd_max)) { in tcp_do_segment()
2543 sack_changed = tcp_sack_doack(tp, &to, th->th_ack); in tcp_do_segment()
2553 hhook_run_tcp_est_in(tp, th, &to); in tcp_do_segment()
2556 if (SEQ_LEQ(th->th_ack, tp->snd_una)) { in tcp_do_segment()
2611 if (th->th_ack != tp->snd_una || in tcp_do_segment()
2619 cc_ack_received(tp, th, nsegs, in tcp_do_segment()
2623 tcp_do_prr_ack(tp, th, &to); in tcp_do_segment()
2680 if (SEQ_LEQ(th->th_ack, in tcp_do_segment()
2687 cc_cong_signal(tp, th, CC_NDUPACK); in tcp_do_segment()
2688 cc_ack_received(tp, th, nsegs, in tcp_do_segment()
2715 if (SEQ_GT(th->th_ack, tp->snd_una)) in tcp_do_segment()
2719 tp->snd_nxt = th->th_ack; in tcp_do_segment()
2742 cc_ack_received(tp, th, nsegs, in tcp_do_segment()
2815 KASSERT(SEQ_GT(th->th_ack, tp->snd_una), in tcp_do_segment()
2823 if (SEQ_LT(th->th_ack, tp->snd_recover)) { in tcp_do_segment()
2828 tcp_do_prr_ack(tp, th, &to); in tcp_do_segment()
2832 tcp_sack_partialack(tp, th); in tcp_do_segment()
2834 tcp_newreno_partial_ack(tp, th); in tcp_do_segment()
2836 cc_post_recovery(tp, th); in tcp_do_segment()
2838 if (SEQ_LT(th->th_ack, tp->snd_recover)) { in tcp_do_segment()
2840 tp->sackhint.delivered_data = BYTES_THIS_ACK(tp, th); in tcp_do_segment()
2841 tp->snd_fack = th->th_ack; in tcp_do_segment()
2842 tcp_do_prr_ack(tp, th, &to); in tcp_do_segment()
2846 cc_post_recovery(tp, th); in tcp_do_segment()
2882 acked = BYTES_THIS_ACK(tp, th); in tcp_do_segment()
2885 tp->snd_una, th->th_ack, tp, m)); in tcp_do_segment()
2902 cc_cong_signal(tp, th, CC_RTO_ERR); in tcp_do_segment()
2925 } else if (tp->t_rtttime && SEQ_GT(th->th_ack, tp->t_rtseq)) { in tcp_do_segment()
2937 if (th->th_ack == tp->snd_max) { in tcp_do_segment()
2955 cc_ack_received(tp, th, nsegs, CC_ACK); in tcp_do_segment()
2980 SEQ_LEQ(th->th_ack, tp->snd_recover)) in tcp_do_segment()
2981 tp->snd_recover = th->th_ack - 1; in tcp_do_segment()
2984 SEQ_GEQ(th->th_ack, tp->snd_recover)) { in tcp_do_segment()
2987 tp->snd_una = th->th_ack; in tcp_do_segment()
3062 (SEQ_LT(tp->snd_wl1, th->th_seq) || in tcp_do_segment()
3063 (tp->snd_wl1 == th->th_seq && (SEQ_LT(tp->snd_wl2, th->th_ack) || in tcp_do_segment()
3064 (tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd))))) { in tcp_do_segment()
3067 tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd) in tcp_do_segment()
3070 tp->snd_wl1 = th->th_seq; in tcp_do_segment()
3071 tp->snd_wl2 = th->th_ack; in tcp_do_segment()
3080 if ((thflags & TH_URG) && th->th_urp && in tcp_do_segment()
3089 if (th->th_urp + sbavail(&so->so_rcv) > sb_max) { in tcp_do_segment()
3090 th->th_urp = 0; /* XXX */ in tcp_do_segment()
3109 if (SEQ_GT(th->th_seq+th->th_urp, tp->rcv_up)) { in tcp_do_segment()
3110 tp->rcv_up = th->th_seq + th->th_urp; in tcp_do_segment()
3125 if (th->th_urp <= (uint32_t)tlen && in tcp_do_segment()
3128 tcp_pulloutofband(so, th, m, drop_hdrlen); in tcp_do_segment()
3154 tcp_seq save_start = th->th_seq; in tcp_do_segment()
3170 if (th->th_seq == tp->rcv_nxt && in tcp_do_segment()
3188 thflags = th->th_flags & TH_FIN; in tcp_do_segment()
3206 thflags = tcp_reass(tp, th, &temp, &tlen, m); in tcp_do_segment()
3316 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
3351 (SEQ_GT(tp->snd_una, th->th_ack) || in tcp_do_segment()
3352 SEQ_GT(th->th_ack, tp->snd_max)) ) { in tcp_do_segment()
3361 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
3370 tcp_dropwithreset(m, th, tp, tlen, rstreason); in tcp_do_segment()
3373 tcp_dropwithreset(m, th, NULL, tlen, rstreason); in tcp_do_segment()
3385 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
3398 tcp_dropwithreset(struct mbuf *m, struct tcphdr *th, struct tcpcb *tp, in tcp_dropwithreset() argument
3413 if ((th->th_flags & TH_RST) || m->m_flags & (M_BCAST|M_MCAST)) in tcp_dropwithreset()
3443 if (th->th_flags & TH_ACK) { in tcp_dropwithreset()
3444 tcp_respond(tp, mtod(m, void *), th, m, (tcp_seq)0, in tcp_dropwithreset()
3445 th->th_ack, TH_RST); in tcp_dropwithreset()
3447 if (th->th_flags & TH_SYN) in tcp_dropwithreset()
3449 if (th->th_flags & TH_FIN) in tcp_dropwithreset()
3451 tcp_respond(tp, mtod(m, void *), th, m, th->th_seq+tlen, in tcp_dropwithreset()
3571 tcp_pulloutofband(struct socket *so, struct tcphdr *th, struct mbuf *m, in tcp_pulloutofband() argument
3574 int cnt = off + th->th_urp - 1; in tcp_pulloutofband()
3971 tcp_do_prr_ack(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to) in tcp_do_prr_ack() argument
4047 tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th) in tcp_newreno_partial_ack() argument
4057 tp->snd_nxt = th->th_ack; in tcp_newreno_partial_ack()
4062 tp->snd_cwnd = maxseg + BYTES_THIS_ACK(tp, th); in tcp_newreno_partial_ack()
4072 if (tp->snd_cwnd > BYTES_THIS_ACK(tp, th)) in tcp_newreno_partial_ack()
4073 tp->snd_cwnd -= BYTES_THIS_ACK(tp, th); in tcp_newreno_partial_ack()