Lines Matching refs:tp

313 static void tcp_ecn_queue_cwr(struct tcp_sock *tp)  in tcp_ecn_queue_cwr()  argument
315 if (tp->ecn_flags & TCP_ECN_OK) in tcp_ecn_queue_cwr()
316 tp->ecn_flags |= TCP_ECN_QUEUE_CWR; in tcp_ecn_queue_cwr()
333 static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp) in tcp_ecn_withdraw_cwr() argument
335 tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; in tcp_ecn_withdraw_cwr()
340 struct tcp_sock *tp = tcp_sk(sk); in __tcp_ecn_check_ce() local
348 if (tp->ecn_flags & TCP_ECN_SEEN) in __tcp_ecn_check_ce()
355 if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) { in __tcp_ecn_check_ce()
358 tp->ecn_flags |= TCP_ECN_DEMAND_CWR; in __tcp_ecn_check_ce()
360 tp->ecn_flags |= TCP_ECN_SEEN; in __tcp_ecn_check_ce()
365 tp->ecn_flags |= TCP_ECN_SEEN; in __tcp_ecn_check_ce()
376 static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th) in tcp_ecn_rcv_synack() argument
378 if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || th->cwr)) in tcp_ecn_rcv_synack()
379 tp->ecn_flags &= ~TCP_ECN_OK; in tcp_ecn_rcv_synack()
382 static void tcp_ecn_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th) in tcp_ecn_rcv_syn() argument
384 if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || !th->cwr)) in tcp_ecn_rcv_syn()
385 tp->ecn_flags &= ~TCP_ECN_OK; in tcp_ecn_rcv_syn()
388 static bool tcp_ecn_rcv_ecn_echo(const struct tcp_sock *tp, const struct tcphdr *th) in tcp_ecn_rcv_ecn_echo() argument
390 if (th->ece && !th->syn && (tp->ecn_flags & TCP_ECN_OK)) in tcp_ecn_rcv_ecn_echo()
402 const struct tcp_sock *tp = tcp_sk(sk); in tcp_sndbuf_expand() local
410 per_mss = max_t(u32, tp->rx_opt.mss_clamp, tp->mss_cache) + in tcp_sndbuf_expand()
417 nr_segs = max_t(u32, TCP_INIT_CWND, tp->snd_cwnd); in tcp_sndbuf_expand()
418 nr_segs = max_t(u32, nr_segs, tp->reordering + 1); in tcp_sndbuf_expand()
461 struct tcp_sock *tp = tcp_sk(sk); in __tcp_grow_window() local
466 while (tp->rcv_ssthresh <= window) { in __tcp_grow_window()
498 struct tcp_sock *tp = tcp_sk(sk); in tcp_grow_window() local
501 room = min_t(int, tp->window_clamp, tcp_space(sk)) - tp->rcv_ssthresh; in tcp_grow_window()
512 incr = 2 * tp->advmss; in tcp_grow_window()
518 tp->rcv_ssthresh += min(room, incr); in tcp_grow_window()
530 struct tcp_sock *tp = tcp_sk(sk); in tcp_init_buffer_space() local
536 tcp_mstamp_refresh(tp); in tcp_init_buffer_space()
537 tp->rcvq_space.time = tp->tcp_mstamp; in tcp_init_buffer_space()
538 tp->rcvq_space.seq = tp->copied_seq; in tcp_init_buffer_space()
542 if (tp->window_clamp >= maxwin) { in tcp_init_buffer_space()
543 tp->window_clamp = maxwin; in tcp_init_buffer_space()
545 if (tcp_app_win && maxwin > 4 * tp->advmss) in tcp_init_buffer_space()
546 tp->window_clamp = max(maxwin - in tcp_init_buffer_space()
548 4 * tp->advmss); in tcp_init_buffer_space()
553 tp->window_clamp > 2 * tp->advmss && in tcp_init_buffer_space()
554 tp->window_clamp + tp->advmss > maxwin) in tcp_init_buffer_space()
555 tp->window_clamp = max(2 * tp->advmss, maxwin - tp->advmss); in tcp_init_buffer_space()
557 tp->rcv_ssthresh = min(tp->rcv_ssthresh, tp->window_clamp); in tcp_init_buffer_space()
558 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_init_buffer_space()
559 tp->rcvq_space.space = min3(tp->rcv_ssthresh, tp->rcv_wnd, in tcp_init_buffer_space()
560 (u32)TCP_INIT_CWND * tp->advmss); in tcp_init_buffer_space()
566 struct tcp_sock *tp = tcp_sk(sk); in tcp_clamp_window() local
582 tp->rcv_ssthresh = min(tp->window_clamp, 2U * tp->advmss); in tcp_clamp_window()
594 const struct tcp_sock *tp = tcp_sk(sk); in tcp_initialize_rcv_mss() local
595 unsigned int hint = min_t(unsigned int, tp->advmss, tp->mss_cache); in tcp_initialize_rcv_mss()
597 hint = min(hint, tp->rcv_wnd / 2); in tcp_initialize_rcv_mss()
616 static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep) in tcp_rcv_rtt_update() argument
618 u32 new_sample = tp->rcv_rtt_est.rtt_us; in tcp_rcv_rtt_update()
645 tp->rcv_rtt_est.rtt_us = new_sample; in tcp_rcv_rtt_update()
648 static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp) in tcp_rcv_rtt_measure() argument
652 if (tp->rcv_rtt_est.time == 0) in tcp_rcv_rtt_measure()
654 if (before(tp->rcv_nxt, tp->rcv_rtt_est.seq)) in tcp_rcv_rtt_measure()
656 delta_us = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcv_rtt_est.time); in tcp_rcv_rtt_measure()
659 tcp_rcv_rtt_update(tp, delta_us, 1); in tcp_rcv_rtt_measure()
662 tp->rcv_rtt_est.seq = tp->rcv_nxt + tp->rcv_wnd; in tcp_rcv_rtt_measure()
663 tp->rcv_rtt_est.time = tp->tcp_mstamp; in tcp_rcv_rtt_measure()
669 struct tcp_sock *tp = tcp_sk(sk); in tcp_rcv_rtt_measure_ts() local
671 if (tp->rx_opt.rcv_tsecr == tp->rcv_rtt_last_tsecr) in tcp_rcv_rtt_measure_ts()
673 tp->rcv_rtt_last_tsecr = tp->rx_opt.rcv_tsecr; in tcp_rcv_rtt_measure_ts()
677 u32 delta = tcp_time_stamp(tp) - tp->rx_opt.rcv_tsecr; in tcp_rcv_rtt_measure_ts()
684 tcp_rcv_rtt_update(tp, delta_us, 0); in tcp_rcv_rtt_measure_ts()
695 struct tcp_sock *tp = tcp_sk(sk); in tcp_rcv_space_adjust() local
701 tcp_mstamp_refresh(tp); in tcp_rcv_space_adjust()
702 time = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcvq_space.time); in tcp_rcv_space_adjust()
703 if (time < (tp->rcv_rtt_est.rtt_us >> 3) || tp->rcv_rtt_est.rtt_us == 0) in tcp_rcv_space_adjust()
707 copied = tp->copied_seq - tp->rcvq_space.seq; in tcp_rcv_space_adjust()
708 if (copied <= tp->rcvq_space.space) in tcp_rcv_space_adjust()
728 rcvwin = ((u64)copied << 1) + 16 * tp->advmss; in tcp_rcv_space_adjust()
731 grow = rcvwin * (copied - tp->rcvq_space.space); in tcp_rcv_space_adjust()
732 do_div(grow, tp->rcvq_space.space); in tcp_rcv_space_adjust()
735 rcvmem = SKB_TRUESIZE(tp->advmss + MAX_TCP_HEADER); in tcp_rcv_space_adjust()
736 while (tcp_win_from_space(sk, rcvmem) < tp->advmss) in tcp_rcv_space_adjust()
739 do_div(rcvwin, tp->advmss); in tcp_rcv_space_adjust()
746 tp->window_clamp = tcp_win_from_space(sk, rcvbuf); in tcp_rcv_space_adjust()
749 tp->rcvq_space.space = copied; in tcp_rcv_space_adjust()
752 tp->rcvq_space.seq = tp->copied_seq; in tcp_rcv_space_adjust()
753 tp->rcvq_space.time = tp->tcp_mstamp; in tcp_rcv_space_adjust()
768 struct tcp_sock *tp = tcp_sk(sk); in tcp_event_data_recv() local
776 tcp_rcv_rtt_measure(tp); in tcp_event_data_recv()
823 struct tcp_sock *tp = tcp_sk(sk); in tcp_rtt_estimator() local
825 u32 srtt = tp->srtt_us; in tcp_rtt_estimator()
848 m -= (tp->mdev_us >> 2); /* similar update on mdev */ in tcp_rtt_estimator()
860 m -= (tp->mdev_us >> 2); /* similar update on mdev */ in tcp_rtt_estimator()
862 tp->mdev_us += m; /* mdev = 3/4 mdev + 1/4 new */ in tcp_rtt_estimator()
863 if (tp->mdev_us > tp->mdev_max_us) { in tcp_rtt_estimator()
864 tp->mdev_max_us = tp->mdev_us; in tcp_rtt_estimator()
865 if (tp->mdev_max_us > tp->rttvar_us) in tcp_rtt_estimator()
866 tp->rttvar_us = tp->mdev_max_us; in tcp_rtt_estimator()
868 if (after(tp->snd_una, tp->rtt_seq)) { in tcp_rtt_estimator()
869 if (tp->mdev_max_us < tp->rttvar_us) in tcp_rtt_estimator()
870 tp->rttvar_us -= (tp->rttvar_us - tp->mdev_max_us) >> 2; in tcp_rtt_estimator()
871 tp->rtt_seq = tp->snd_nxt; in tcp_rtt_estimator()
872 tp->mdev_max_us = tcp_rto_min_us(sk); in tcp_rtt_estimator()
879 tp->mdev_us = m << 1; /* make sure rto = 3*rtt */ in tcp_rtt_estimator()
880 tp->rttvar_us = max(tp->mdev_us, tcp_rto_min_us(sk)); in tcp_rtt_estimator()
881 tp->mdev_max_us = tp->rttvar_us; in tcp_rtt_estimator()
882 tp->rtt_seq = tp->snd_nxt; in tcp_rtt_estimator()
886 tp->srtt_us = max(1U, srtt); in tcp_rtt_estimator()
891 const struct tcp_sock *tp = tcp_sk(sk); in tcp_update_pacing_rate() local
895 rate = (u64)tp->mss_cache * ((USEC_PER_SEC / 100) << 3); in tcp_update_pacing_rate()
905 if (tp->snd_cwnd < tp->snd_ssthresh / 2) in tcp_update_pacing_rate()
910 rate *= max(tp->snd_cwnd, tp->packets_out); in tcp_update_pacing_rate()
912 if (likely(tp->srtt_us)) in tcp_update_pacing_rate()
913 do_div(rate, tp->srtt_us); in tcp_update_pacing_rate()
928 const struct tcp_sock *tp = tcp_sk(sk); in tcp_set_rto() local
939 inet_csk(sk)->icsk_rto = __tcp_set_rto(tp); in tcp_set_rto()
953 __u32 tcp_init_cwnd(const struct tcp_sock *tp, const struct dst_entry *dst) in tcp_init_cwnd() argument
959 return min_t(__u32, cwnd, tp->snd_cwnd_clamp); in tcp_init_cwnd()
982 static u32 tcp_dsack_seen(struct tcp_sock *tp, u32 start_seq, in tcp_dsack_seen() argument
992 if (seq_len > tp->max_window) in tcp_dsack_seen()
994 if (seq_len > tp->mss_cache) in tcp_dsack_seen()
995 dup_segs = DIV_ROUND_UP(seq_len, tp->mss_cache); in tcp_dsack_seen()
997 tp->dsack_dups += dup_segs; in tcp_dsack_seen()
999 if (tp->dsack_dups > tp->total_retrans) in tcp_dsack_seen()
1002 tp->rx_opt.sack_ok |= TCP_DSACK_SEEN; in tcp_dsack_seen()
1003 tp->rack.dsack_seen = 1; in tcp_dsack_seen()
1019 struct tcp_sock *tp = tcp_sk(sk); in tcp_check_sack_reordering() local
1020 const u32 mss = tp->mss_cache; in tcp_check_sack_reordering()
1023 fack = tcp_highest_sack_seq(tp); in tcp_check_sack_reordering()
1028 if ((metric > tp->reordering * mss) && mss) { in tcp_check_sack_reordering()
1031 tp->rx_opt.sack_ok, inet_csk(sk)->icsk_ca_state, in tcp_check_sack_reordering()
1032 tp->reordering, in tcp_check_sack_reordering()
1034 tp->sacked_out, in tcp_check_sack_reordering()
1035 tp->undo_marker ? tp->undo_retrans : 0); in tcp_check_sack_reordering()
1037 tp->reordering = min_t(u32, (metric + mss - 1) / mss, in tcp_check_sack_reordering()
1042 tp->reord_seen++; in tcp_check_sack_reordering()
1052 static void tcp_verify_retransmit_hint(struct tcp_sock *tp, struct sk_buff *skb) in tcp_verify_retransmit_hint() argument
1054 if ((!tp->retransmit_skb_hint && tp->retrans_out >= tp->lost_out) || in tcp_verify_retransmit_hint()
1055 (tp->retransmit_skb_hint && in tcp_verify_retransmit_hint()
1057 TCP_SKB_CB(tp->retransmit_skb_hint)->seq))) in tcp_verify_retransmit_hint()
1058 tp->retransmit_skb_hint = skb; in tcp_verify_retransmit_hint()
1064 static void tcp_notify_skb_loss_event(struct tcp_sock *tp, const struct sk_buff *skb) in tcp_notify_skb_loss_event() argument
1066 tp->lost += tcp_skb_pcount(skb); in tcp_notify_skb_loss_event()
1072 struct tcp_sock *tp = tcp_sk(sk); in tcp_mark_skb_lost() local
1077 tcp_verify_retransmit_hint(tp, skb); in tcp_mark_skb_lost()
1082 tp->retrans_out -= tcp_skb_pcount(skb); in tcp_mark_skb_lost()
1085 tcp_notify_skb_loss_event(tp, skb); in tcp_mark_skb_lost()
1088 tp->lost_out += tcp_skb_pcount(skb); in tcp_mark_skb_lost()
1090 tcp_notify_skb_loss_event(tp, skb); in tcp_mark_skb_lost()
1095 static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, in tcp_count_delivered() argument
1098 tp->delivered += delivered; in tcp_count_delivered()
1100 tp->delivered_ce += delivered; in tcp_count_delivered()
1196 static bool tcp_is_sackblock_valid(struct tcp_sock *tp, bool is_dsack, in tcp_is_sackblock_valid() argument
1200 if (after(end_seq, tp->snd_nxt) || !before(start_seq, end_seq)) in tcp_is_sackblock_valid()
1204 if (!before(start_seq, tp->snd_nxt)) in tcp_is_sackblock_valid()
1210 if (after(start_seq, tp->snd_una)) in tcp_is_sackblock_valid()
1213 if (!is_dsack || !tp->undo_marker) in tcp_is_sackblock_valid()
1217 if (after(end_seq, tp->snd_una)) in tcp_is_sackblock_valid()
1220 if (!before(start_seq, tp->undo_marker)) in tcp_is_sackblock_valid()
1224 if (!after(end_seq, tp->undo_marker)) in tcp_is_sackblock_valid()
1230 return !before(start_seq, end_seq - tp->max_window); in tcp_is_sackblock_valid()
1237 struct tcp_sock *tp = tcp_sk(sk); in tcp_check_dsack() local
1255 dup_segs = tcp_dsack_seen(tp, start_seq_0, end_seq_0, state); in tcp_check_dsack()
1264 if (tp->undo_marker && tp->undo_retrans > 0 && in tcp_check_dsack()
1266 after(end_seq_0, tp->undo_marker)) in tcp_check_dsack()
1267 tp->undo_retrans = max_t(int, 0, tp->undo_retrans - dup_segs); in tcp_check_dsack()
1335 struct tcp_sock *tp = tcp_sk(sk); in tcp_sacktag_one() local
1339 if (tp->undo_marker && tp->undo_retrans > 0 && in tcp_sacktag_one()
1340 after(end_seq, tp->undo_marker)) in tcp_sacktag_one()
1341 tp->undo_retrans = max_t(int, 0, tp->undo_retrans - pcount); in tcp_sacktag_one()
1348 if (!after(end_seq, tp->snd_una)) in tcp_sacktag_one()
1352 tcp_rack_advance(tp, sacked, end_seq, xmit_time); in tcp_sacktag_one()
1361 tp->lost_out -= pcount; in tcp_sacktag_one()
1362 tp->retrans_out -= pcount; in tcp_sacktag_one()
1370 tcp_highest_sack_seq(tp)) && in tcp_sacktag_one()
1374 if (!after(end_seq, tp->high_seq)) in tcp_sacktag_one()
1383 tp->lost_out -= pcount; in tcp_sacktag_one()
1389 tp->sacked_out += pcount; in tcp_sacktag_one()
1394 if (tp->lost_skb_hint && in tcp_sacktag_one()
1395 before(start_seq, TCP_SKB_CB(tp->lost_skb_hint)->seq)) in tcp_sacktag_one()
1396 tp->lost_cnt_hint += pcount; in tcp_sacktag_one()
1405 tp->retrans_out -= pcount; in tcp_sacktag_one()
1420 struct tcp_sock *tp = tcp_sk(sk); in tcp_shifted_skb() local
1437 if (skb == tp->lost_skb_hint) in tcp_shifted_skb()
1438 tp->lost_cnt_hint += pcount; in tcp_shifted_skb()
1470 if (skb == tp->retransmit_skb_hint) in tcp_shifted_skb()
1471 tp->retransmit_skb_hint = prev; in tcp_shifted_skb()
1472 if (skb == tp->lost_skb_hint) { in tcp_shifted_skb()
1473 tp->lost_skb_hint = prev; in tcp_shifted_skb()
1474 tp->lost_cnt_hint -= tcp_skb_pcount(prev); in tcp_shifted_skb()
1533 struct tcp_sock *tp = tcp_sk(sk); in tcp_shift_skb_data() local
1547 if (!after(TCP_SKB_CB(skb)->end_seq, tp->snd_una)) in tcp_shift_skb_data()
1627 if (!after(TCP_SKB_CB(skb)->seq + len, tp->snd_una)) in tcp_shift_skb_data()
1672 struct tcp_sock *tp = tcp_sk(sk); in tcp_sacktag_walk() local
1731 tcp_highest_sack_seq(tp))) in tcp_sacktag_walk()
1787 static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_block *cache) in tcp_sack_cache_ok() argument
1789 return cache < tp->recv_sack_cache + ARRAY_SIZE(tp->recv_sack_cache); in tcp_sack_cache_ok()
1796 struct tcp_sock *tp = tcp_sk(sk); in tcp_sacktag_write_queue() local
1810 state->reord = tp->snd_nxt; in tcp_sacktag_write_queue()
1812 if (!tp->sacked_out) in tcp_sacktag_write_queue()
1822 if (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window)) in tcp_sacktag_write_queue()
1825 if (!tp->packets_out) in tcp_sacktag_write_queue()
1836 if (!tcp_is_sackblock_valid(tp, dup_sack, in tcp_sacktag_write_queue()
1842 if (!tp->undo_marker) in tcp_sacktag_write_queue()
1848 if ((TCP_SKB_CB(ack_skb)->ack_seq != tp->snd_una) && in tcp_sacktag_write_queue()
1849 !after(sp[used_sacks].end_seq, tp->snd_una)) in tcp_sacktag_write_queue()
1887 if (!tp->sacked_out) { in tcp_sacktag_write_queue()
1889 cache = tp->recv_sack_cache + ARRAY_SIZE(tp->recv_sack_cache); in tcp_sacktag_write_queue()
1891 cache = tp->recv_sack_cache; in tcp_sacktag_write_queue()
1893 while (tcp_sack_cache_ok(tp, cache) && !cache->start_seq && in tcp_sacktag_write_queue()
1908 while (tcp_sack_cache_ok(tp, cache) && in tcp_sacktag_write_queue()
1913 if (tcp_sack_cache_ok(tp, cache) && !dup_sack && in tcp_sacktag_write_queue()
1935 if (tcp_highest_sack_seq(tp) == cache->end_seq) { in tcp_sacktag_write_queue()
1950 if (!before(start_seq, tcp_highest_sack_seq(tp))) { in tcp_sacktag_write_queue()
1966 for (i = 0; i < ARRAY_SIZE(tp->recv_sack_cache) - used_sacks; i++) { in tcp_sacktag_write_queue()
1967 tp->recv_sack_cache[i].start_seq = 0; in tcp_sacktag_write_queue()
1968 tp->recv_sack_cache[i].end_seq = 0; in tcp_sacktag_write_queue()
1971 tp->recv_sack_cache[i++] = sp[j]; in tcp_sacktag_write_queue()
1973 if (inet_csk(sk)->icsk_ca_state != TCP_CA_Loss || tp->undo_marker) in tcp_sacktag_write_queue()
1976 tcp_verify_left_out(tp); in tcp_sacktag_write_queue()
1980 WARN_ON((int)tp->sacked_out < 0); in tcp_sacktag_write_queue()
1981 WARN_ON((int)tp->lost_out < 0); in tcp_sacktag_write_queue()
1982 WARN_ON((int)tp->retrans_out < 0); in tcp_sacktag_write_queue()
1983 WARN_ON((int)tcp_packets_in_flight(tp) < 0); in tcp_sacktag_write_queue()
1991 static bool tcp_limit_reno_sacked(struct tcp_sock *tp) in tcp_limit_reno_sacked() argument
1995 holes = max(tp->lost_out, 1U); in tcp_limit_reno_sacked()
1996 holes = min(holes, tp->packets_out); in tcp_limit_reno_sacked()
1998 if ((tp->sacked_out + holes) > tp->packets_out) { in tcp_limit_reno_sacked()
1999 tp->sacked_out = tp->packets_out - holes; in tcp_limit_reno_sacked()
2011 struct tcp_sock *tp = tcp_sk(sk); in tcp_check_reno_reordering() local
2013 if (!tcp_limit_reno_sacked(tp)) in tcp_check_reno_reordering()
2016 tp->reordering = min_t(u32, tp->packets_out + addend, in tcp_check_reno_reordering()
2018 tp->reord_seen++; in tcp_check_reno_reordering()
2027 struct tcp_sock *tp = tcp_sk(sk); in tcp_add_reno_sack() local
2028 u32 prior_sacked = tp->sacked_out; in tcp_add_reno_sack()
2031 tp->sacked_out += num_dupack; in tcp_add_reno_sack()
2033 delivered = tp->sacked_out - prior_sacked; in tcp_add_reno_sack()
2035 tcp_count_delivered(tp, delivered, ece_ack); in tcp_add_reno_sack()
2036 tcp_verify_left_out(tp); in tcp_add_reno_sack()
2044 struct tcp_sock *tp = tcp_sk(sk); in tcp_remove_reno_sacks() local
2048 tcp_count_delivered(tp, max_t(int, acked - tp->sacked_out, 1), in tcp_remove_reno_sacks()
2050 if (acked - 1 >= tp->sacked_out) in tcp_remove_reno_sacks()
2051 tp->sacked_out = 0; in tcp_remove_reno_sacks()
2053 tp->sacked_out -= acked - 1; in tcp_remove_reno_sacks()
2056 tcp_verify_left_out(tp); in tcp_remove_reno_sacks()
2059 static inline void tcp_reset_reno_sack(struct tcp_sock *tp) in tcp_reset_reno_sack() argument
2061 tp->sacked_out = 0; in tcp_reset_reno_sack()
2064 void tcp_clear_retrans(struct tcp_sock *tp) in tcp_clear_retrans() argument
2066 tp->retrans_out = 0; in tcp_clear_retrans()
2067 tp->lost_out = 0; in tcp_clear_retrans()
2068 tp->undo_marker = 0; in tcp_clear_retrans()
2069 tp->undo_retrans = -1; in tcp_clear_retrans()
2070 tp->sacked_out = 0; in tcp_clear_retrans()
2073 static inline void tcp_init_undo(struct tcp_sock *tp) in tcp_init_undo() argument
2075 tp->undo_marker = tp->snd_una; in tcp_init_undo()
2077 tp->undo_retrans = tp->retrans_out ? : -1; in tcp_init_undo()
2092 struct tcp_sock *tp = tcp_sk(sk); in tcp_timeout_mark_lost() local
2100 tp->sacked_out = 0; in tcp_timeout_mark_lost()
2102 tp->is_sack_reneg = 1; in tcp_timeout_mark_lost()
2103 } else if (tcp_is_reno(tp)) { in tcp_timeout_mark_lost()
2104 tcp_reset_reno_sack(tp); in tcp_timeout_mark_lost()
2112 tcp_rack_skb_timeout(tp, skb, 0) > 0) in tcp_timeout_mark_lost()
2116 tcp_verify_left_out(tp); in tcp_timeout_mark_lost()
2117 tcp_clear_all_retrans_hints(tp); in tcp_timeout_mark_lost()
2124 struct tcp_sock *tp = tcp_sk(sk); in tcp_enter_loss() local
2133 !after(tp->high_seq, tp->snd_una) || in tcp_enter_loss()
2135 tp->prior_ssthresh = tcp_current_ssthresh(sk); in tcp_enter_loss()
2136 tp->prior_cwnd = tp->snd_cwnd; in tcp_enter_loss()
2137 tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh(sk); in tcp_enter_loss()
2139 tcp_init_undo(tp); in tcp_enter_loss()
2141 tp->snd_cwnd = tcp_packets_in_flight(tp) + 1; in tcp_enter_loss()
2142 tp->snd_cwnd_cnt = 0; in tcp_enter_loss()
2143 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_enter_loss()
2150 tp->sacked_out >= reordering) in tcp_enter_loss()
2151 tp->reordering = min_t(unsigned int, tp->reordering, in tcp_enter_loss()
2155 tp->high_seq = tp->snd_nxt; in tcp_enter_loss()
2156 tcp_ecn_queue_cwr(tp); in tcp_enter_loss()
2162 tp->frto = READ_ONCE(net->ipv4.sysctl_tcp_frto) && in tcp_enter_loss()
2181 struct tcp_sock *tp = tcp_sk(sk); in tcp_check_sack_reneging() local
2182 unsigned long delay = max(usecs_to_jiffies(tp->srtt_us >> 4), in tcp_check_sack_reneging()
2203 static inline int tcp_dupack_heuristics(const struct tcp_sock *tp) in tcp_dupack_heuristics() argument
2205 return tp->sacked_out + 1; in tcp_dupack_heuristics()
2307 struct tcp_sock *tp = tcp_sk(sk); in tcp_time_to_recover() local
2310 if (tp->lost_out) in tcp_time_to_recover()
2314 if (!tcp_is_rack(sk) && tcp_dupack_heuristics(tp) > tp->reordering) in tcp_time_to_recover()
2327 struct tcp_sock *tp = tcp_sk(sk); in tcp_mark_head_lost() local
2331 const u32 loss_high = tp->snd_nxt; in tcp_mark_head_lost()
2333 WARN_ON(packets > tp->packets_out); in tcp_mark_head_lost()
2334 skb = tp->lost_skb_hint; in tcp_mark_head_lost()
2337 if (mark_head && after(TCP_SKB_CB(skb)->seq, tp->snd_una)) in tcp_mark_head_lost()
2339 cnt = tp->lost_cnt_hint; in tcp_mark_head_lost()
2348 tp->lost_skb_hint = skb; in tcp_mark_head_lost()
2349 tp->lost_cnt_hint = cnt; in tcp_mark_head_lost()
2366 tcp_verify_left_out(tp); in tcp_mark_head_lost()
2373 struct tcp_sock *tp = tcp_sk(sk); in tcp_update_scoreboard() local
2375 if (tcp_is_sack(tp)) { in tcp_update_scoreboard()
2376 int sacked_upto = tp->sacked_out - tp->reordering; in tcp_update_scoreboard()
2384 static bool tcp_tsopt_ecr_before(const struct tcp_sock *tp, u32 when) in tcp_tsopt_ecr_before() argument
2386 return tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && in tcp_tsopt_ecr_before()
2387 before(tp->rx_opt.rcv_tsecr, when); in tcp_tsopt_ecr_before()
2393 static bool tcp_skb_spurious_retrans(const struct tcp_sock *tp, in tcp_skb_spurious_retrans() argument
2397 tcp_tsopt_ecr_before(tp, tcp_skb_timestamp(skb)); in tcp_skb_spurious_retrans()
2403 static inline bool tcp_packet_delayed(const struct tcp_sock *tp) in tcp_packet_delayed() argument
2405 return tp->retrans_stamp && in tcp_packet_delayed()
2406 tcp_tsopt_ecr_before(tp, tp->retrans_stamp); in tcp_packet_delayed()
2427 const struct tcp_sock *tp = tcp_sk(sk); in tcp_any_retrans_done() local
2430 if (tp->retrans_out) in tcp_any_retrans_done()
2443 struct tcp_sock *tp = tcp_sk(sk); in DBGUNDO() local
2450 tp->snd_cwnd, tcp_left_out(tp), in DBGUNDO()
2451 tp->snd_ssthresh, tp->prior_ssthresh, in DBGUNDO()
2452 tp->packets_out); in DBGUNDO()
2459 tp->snd_cwnd, tcp_left_out(tp), in DBGUNDO()
2460 tp->snd_ssthresh, tp->prior_ssthresh, in DBGUNDO()
2461 tp->packets_out); in DBGUNDO()
2469 struct tcp_sock *tp = tcp_sk(sk); in tcp_undo_cwnd_reduction() local
2477 tp->lost_out = 0; in tcp_undo_cwnd_reduction()
2478 tcp_clear_all_retrans_hints(tp); in tcp_undo_cwnd_reduction()
2481 if (tp->prior_ssthresh) { in tcp_undo_cwnd_reduction()
2484 tp->snd_cwnd = icsk->icsk_ca_ops->undo_cwnd(sk); in tcp_undo_cwnd_reduction()
2486 if (tp->prior_ssthresh > tp->snd_ssthresh) { in tcp_undo_cwnd_reduction()
2487 tp->snd_ssthresh = tp->prior_ssthresh; in tcp_undo_cwnd_reduction()
2488 tcp_ecn_withdraw_cwr(tp); in tcp_undo_cwnd_reduction()
2491 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_undo_cwnd_reduction()
2492 tp->undo_marker = 0; in tcp_undo_cwnd_reduction()
2493 tp->rack.advanced = 1; /* Force RACK to re-exam losses */ in tcp_undo_cwnd_reduction()
2496 static inline bool tcp_may_undo(const struct tcp_sock *tp) in tcp_may_undo() argument
2498 return tp->undo_marker && (!tp->undo_retrans || tcp_packet_delayed(tp)); in tcp_may_undo()
2503 struct tcp_sock *tp = tcp_sk(sk); in tcp_is_non_sack_preventing_reopen() local
2505 if (tp->snd_una == tp->high_seq && tcp_is_reno(tp)) { in tcp_is_non_sack_preventing_reopen()
2510 tp->retrans_stamp = 0; in tcp_is_non_sack_preventing_reopen()
2519 struct tcp_sock *tp = tcp_sk(sk); in tcp_try_undo_recovery() local
2521 if (tcp_may_undo(tp)) { in tcp_try_undo_recovery()
2535 } else if (tp->rack.reo_wnd_persist) { in tcp_try_undo_recovery()
2536 tp->rack.reo_wnd_persist--; in tcp_try_undo_recovery()
2541 tp->is_sack_reneg = 0; in tcp_try_undo_recovery()
2548 struct tcp_sock *tp = tcp_sk(sk); in tcp_try_undo_dsack() local
2550 if (tp->undo_marker && !tp->undo_retrans) { in tcp_try_undo_dsack()
2551 tp->rack.reo_wnd_persist = min(TCP_RACK_RECOVERY_THRESH, in tcp_try_undo_dsack()
2552 tp->rack.reo_wnd_persist + 1); in tcp_try_undo_dsack()
2564 struct tcp_sock *tp = tcp_sk(sk); in tcp_try_undo_loss() local
2566 if (frto_undo || tcp_may_undo(tp)) { in tcp_try_undo_loss()
2577 if (frto_undo || tcp_is_sack(tp)) { in tcp_try_undo_loss()
2579 tp->is_sack_reneg = 0; in tcp_try_undo_loss()
2597 struct tcp_sock *tp = tcp_sk(sk); in tcp_init_cwnd_reduction() local
2599 tp->high_seq = tp->snd_nxt; in tcp_init_cwnd_reduction()
2600 tp->tlp_high_seq = 0; in tcp_init_cwnd_reduction()
2601 tp->snd_cwnd_cnt = 0; in tcp_init_cwnd_reduction()
2602 tp->prior_cwnd = tp->snd_cwnd; in tcp_init_cwnd_reduction()
2603 tp->prr_delivered = 0; in tcp_init_cwnd_reduction()
2604 tp->prr_out = 0; in tcp_init_cwnd_reduction()
2605 tp->snd_ssthresh = inet_csk(sk)->icsk_ca_ops->ssthresh(sk); in tcp_init_cwnd_reduction()
2606 tcp_ecn_queue_cwr(tp); in tcp_init_cwnd_reduction()
2611 struct tcp_sock *tp = tcp_sk(sk); in tcp_cwnd_reduction() local
2613 int delta = tp->snd_ssthresh - tcp_packets_in_flight(tp); in tcp_cwnd_reduction()
2615 if (newly_acked_sacked <= 0 || WARN_ON_ONCE(!tp->prior_cwnd)) in tcp_cwnd_reduction()
2618 tp->prr_delivered += newly_acked_sacked; in tcp_cwnd_reduction()
2620 u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered + in tcp_cwnd_reduction()
2621 tp->prior_cwnd - 1; in tcp_cwnd_reduction()
2622 sndcnt = div_u64(dividend, tp->prior_cwnd) - tp->prr_out; in tcp_cwnd_reduction()
2626 max_t(int, tp->prr_delivered - tp->prr_out, in tcp_cwnd_reduction()
2632 sndcnt = max(sndcnt, (tp->prr_out ? 0 : 1)); in tcp_cwnd_reduction()
2633 tp->snd_cwnd = tcp_packets_in_flight(tp) + sndcnt; in tcp_cwnd_reduction()
2638 struct tcp_sock *tp = tcp_sk(sk); in tcp_end_cwnd_reduction() local
2644 if (tp->snd_ssthresh < TCP_INFINITE_SSTHRESH && in tcp_end_cwnd_reduction()
2645 (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR || tp->undo_marker)) { in tcp_end_cwnd_reduction()
2646 tp->snd_cwnd = tp->snd_ssthresh; in tcp_end_cwnd_reduction()
2647 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_end_cwnd_reduction()
2655 struct tcp_sock *tp = tcp_sk(sk); in tcp_enter_cwr() local
2657 tp->prior_ssthresh = 0; in tcp_enter_cwr()
2659 tp->undo_marker = 0; in tcp_enter_cwr()
2668 struct tcp_sock *tp = tcp_sk(sk); in tcp_try_keep_open() local
2671 if (tcp_left_out(tp) || tcp_any_retrans_done(sk)) in tcp_try_keep_open()
2676 tp->high_seq = tp->snd_nxt; in tcp_try_keep_open()
2682 struct tcp_sock *tp = tcp_sk(sk); in tcp_try_to_open() local
2684 tcp_verify_left_out(tp); in tcp_try_to_open()
2687 tp->retrans_stamp = 0; in tcp_try_to_open()
2708 struct tcp_sock *tp = tcp_sk(sk); in tcp_mtup_probe_success() local
2712 tp->prior_ssthresh = tcp_current_ssthresh(sk); in tcp_mtup_probe_success()
2714 val = (u64)tp->snd_cwnd * tcp_mss_to_mtu(sk, tp->mss_cache); in tcp_mtup_probe_success()
2717 tp->snd_cwnd = max_t(u32, 1U, val); in tcp_mtup_probe_success()
2719 tp->snd_cwnd_cnt = 0; in tcp_mtup_probe_success()
2720 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_mtup_probe_success()
2721 tp->snd_ssthresh = tcp_current_ssthresh(sk); in tcp_mtup_probe_success()
2736 struct tcp_sock *tp = tcp_sk(sk); in tcp_simple_retransmit() local
2745 tcp_clear_retrans_hints_partial(tp); in tcp_simple_retransmit()
2747 if (!tp->lost_out) in tcp_simple_retransmit()
2750 if (tcp_is_reno(tp)) in tcp_simple_retransmit()
2751 tcp_limit_reno_sacked(tp); in tcp_simple_retransmit()
2753 tcp_verify_left_out(tp); in tcp_simple_retransmit()
2761 tp->high_seq = tp->snd_nxt; in tcp_simple_retransmit()
2762 tp->snd_ssthresh = tcp_current_ssthresh(sk); in tcp_simple_retransmit()
2763 tp->prior_ssthresh = 0; in tcp_simple_retransmit()
2764 tp->undo_marker = 0; in tcp_simple_retransmit()
2773 struct tcp_sock *tp = tcp_sk(sk); in tcp_enter_recovery() local
2776 if (tcp_is_reno(tp)) in tcp_enter_recovery()
2783 tp->prior_ssthresh = 0; in tcp_enter_recovery()
2784 tcp_init_undo(tp); in tcp_enter_recovery()
2788 tp->prior_ssthresh = tcp_current_ssthresh(sk); in tcp_enter_recovery()
2800 struct tcp_sock *tp = tcp_sk(sk); in tcp_process_loss() local
2801 bool recovered = !before(tp->snd_una, tp->high_seq); in tcp_process_loss()
2803 if ((flag & FLAG_SND_UNA_ADVANCED || rcu_access_pointer(tp->fastopen_rsk)) && in tcp_process_loss()
2807 if (tp->frto) { /* F-RTO RFC5682 sec 3.1 (sack enhanced version). */ in tcp_process_loss()
2815 if (after(tp->snd_nxt, tp->high_seq)) { in tcp_process_loss()
2817 tp->frto = 0; /* Step 3.a. loss was real */ in tcp_process_loss()
2819 tp->high_seq = tp->snd_nxt; in tcp_process_loss()
2825 after(tcp_wnd_end(tp), tp->snd_nxt)) { in tcp_process_loss()
2829 tp->frto = 0; in tcp_process_loss()
2838 if (tcp_is_reno(tp)) { in tcp_process_loss()
2842 if (after(tp->snd_nxt, tp->high_seq) && num_dupack) in tcp_process_loss()
2845 tcp_reset_reno_sack(tp); in tcp_process_loss()
2852 struct tcp_sock *tp = tcp_sk(sk); in tcp_force_fast_retransmit() local
2854 return after(tcp_highest_sack_seq(tp), in tcp_force_fast_retransmit()
2855 tp->snd_una + tp->reordering * tp->mss_cache); in tcp_force_fast_retransmit()
2862 struct tcp_sock *tp = tcp_sk(sk); in tcp_try_undo_partial() local
2864 if (tp->undo_marker && tcp_packet_delayed(tp)) { in tcp_try_undo_partial()
2875 if (tp->retrans_out) in tcp_try_undo_partial()
2879 tp->retrans_stamp = 0; in tcp_try_undo_partial()
2894 struct tcp_sock *tp = tcp_sk(sk); in tcp_identify_packet_loss() local
2899 if (unlikely(tcp_is_reno(tp))) { in tcp_identify_packet_loss()
2902 u32 prior_retrans = tp->retrans_out; in tcp_identify_packet_loss()
2906 if (prior_retrans > tp->retrans_out) in tcp_identify_packet_loss()
2927 struct tcp_sock *tp = tcp_sk(sk); in tcp_fastretrans_alert() local
2933 if (!tp->packets_out && tp->sacked_out) in tcp_fastretrans_alert()
2934 tp->sacked_out = 0; in tcp_fastretrans_alert()
2939 tp->prior_ssthresh = 0; in tcp_fastretrans_alert()
2946 tcp_verify_left_out(tp); in tcp_fastretrans_alert()
2951 WARN_ON(tp->retrans_out != 0); in tcp_fastretrans_alert()
2952 tp->retrans_stamp = 0; in tcp_fastretrans_alert()
2953 } else if (!before(tp->snd_una, tp->high_seq)) { in tcp_fastretrans_alert()
2958 if (tp->snd_una != tp->high_seq) { in tcp_fastretrans_alert()
2965 if (tcp_is_reno(tp)) in tcp_fastretrans_alert()
2966 tcp_reset_reno_sack(tp); in tcp_fastretrans_alert()
2978 if (tcp_is_reno(tp)) in tcp_fastretrans_alert()
3005 if (tcp_is_reno(tp)) { in tcp_fastretrans_alert()
3007 tcp_reset_reno_sack(tp); in tcp_fastretrans_alert()
3023 tp->snd_una == tp->mtu_probe.probe_seq_start) { in tcp_fastretrans_alert()
3026 tp->snd_cwnd++; in tcp_fastretrans_alert()
3044 struct tcp_sock *tp = tcp_sk(sk); in tcp_update_rtt_min() local
3046 if ((flag & FLAG_ACK_MAYBE_DELAYED) && rtt_us > tcp_min_rtt(tp)) { in tcp_update_rtt_min()
3053 minmax_running_min(&tp->rtt_min, wlen, tcp_jiffies32, in tcp_update_rtt_min()
3061 const struct tcp_sock *tp = tcp_sk(sk); in tcp_ack_update_rtt() local
3077 if (seq_rtt_us < 0 && tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && in tcp_ack_update_rtt()
3079 u32 delta = tcp_time_stamp(tp) - tp->rx_opt.rcv_tsecr; in tcp_ack_update_rtt()
3132 struct tcp_sock *tp = tcp_sk(sk); in tcp_rearm_rto() local
3137 if (rcu_access_pointer(tp->fastopen_rsk)) in tcp_rearm_rto()
3140 if (!tp->packets_out) { in tcp_rearm_rto()
3168 struct tcp_sock *tp = tcp_sk(sk); in tcp_tso_acked() local
3171 BUG_ON(!after(TCP_SKB_CB(skb)->end_seq, tp->snd_una)); in tcp_tso_acked()
3174 if (tcp_trim_head(sk, skb, tp->snd_una - TCP_SKB_CB(skb)->seq)) in tcp_tso_acked()
3214 struct tcp_sock *tp = tcp_sk(sk); in tcp_clean_rtx_queue() local
3215 u32 prior_sacked = tp->sacked_out; in tcp_clean_rtx_queue()
3216 u32 reord = tp->snd_nxt; /* lowest acked un-retx un-sacked seq */ in tcp_clean_rtx_queue()
3236 if (after(scb->end_seq, tp->snd_una)) { in tcp_clean_rtx_queue()
3238 !after(tp->snd_una, scb->seq)) in tcp_clean_rtx_queue()
3251 tp->retrans_out -= acked_pcount; in tcp_clean_rtx_queue()
3262 if (!after(scb->end_seq, tp->high_seq)) in tcp_clean_rtx_queue()
3267 tp->sacked_out -= acked_pcount; in tcp_clean_rtx_queue()
3268 } else if (tcp_is_sack(tp)) { in tcp_clean_rtx_queue()
3269 tcp_count_delivered(tp, acked_pcount, ece_ack); in tcp_clean_rtx_queue()
3270 if (!tcp_skb_spurious_retrans(tp, skb)) in tcp_clean_rtx_queue()
3271 tcp_rack_advance(tp, sacked, scb->end_seq, in tcp_clean_rtx_queue()
3275 tp->lost_out -= acked_pcount; in tcp_clean_rtx_queue()
3277 tp->packets_out -= acked_pcount; in tcp_clean_rtx_queue()
3292 tp->retrans_stamp = 0; in tcp_clean_rtx_queue()
3301 if (unlikely(skb == tp->retransmit_skb_hint)) in tcp_clean_rtx_queue()
3302 tp->retransmit_skb_hint = NULL; in tcp_clean_rtx_queue()
3303 if (unlikely(skb == tp->lost_skb_hint)) in tcp_clean_rtx_queue()
3304 tp->lost_skb_hint = NULL; in tcp_clean_rtx_queue()
3312 if (likely(between(tp->snd_up, prior_snd_una, tp->snd_una))) in tcp_clean_rtx_queue()
3313 tp->snd_up = tp->snd_una; in tcp_clean_rtx_queue()
3322 seq_rtt_us = tcp_stamp_us_delta(tp->tcp_mstamp, first_ackt); in tcp_clean_rtx_queue()
3323 ca_rtt_us = tcp_stamp_us_delta(tp->tcp_mstamp, last_ackt); in tcp_clean_rtx_queue()
3325 if (pkts_acked == 1 && last_in_flight < tp->mss_cache && in tcp_clean_rtx_queue()
3327 sack->rate->prior_delivered + 1 == tp->delivered && in tcp_clean_rtx_queue()
3337 sack_rtt_us = tcp_stamp_us_delta(tp->tcp_mstamp, sack->first_sackt); in tcp_clean_rtx_queue()
3338 ca_rtt_us = tcp_stamp_us_delta(tp->tcp_mstamp, sack->last_sackt); in tcp_clean_rtx_queue()
3346 !after(tp->mtu_probe.probe_seq_end, tp->snd_una))) { in tcp_clean_rtx_queue()
3350 if (tcp_is_reno(tp)) { in tcp_clean_rtx_queue()
3368 delta = prior_sacked - tp->sacked_out; in tcp_clean_rtx_queue()
3369 tp->lost_cnt_hint -= min(tp->lost_cnt_hint, delta); in tcp_clean_rtx_queue()
3372 sack_rtt_us > tcp_stamp_us_delta(tp->tcp_mstamp, in tcp_clean_rtx_queue()
3390 WARN_ON((int)tp->sacked_out < 0); in tcp_clean_rtx_queue()
3391 WARN_ON((int)tp->lost_out < 0); in tcp_clean_rtx_queue()
3392 WARN_ON((int)tp->retrans_out < 0); in tcp_clean_rtx_queue()
3393 if (!tp->packets_out && tcp_is_sack(tp)) { in tcp_clean_rtx_queue()
3395 if (tp->lost_out) { in tcp_clean_rtx_queue()
3397 tp->lost_out, icsk->icsk_ca_state); in tcp_clean_rtx_queue()
3398 tp->lost_out = 0; in tcp_clean_rtx_queue()
3400 if (tp->sacked_out) { in tcp_clean_rtx_queue()
3402 tp->sacked_out, icsk->icsk_ca_state); in tcp_clean_rtx_queue()
3403 tp->sacked_out = 0; in tcp_clean_rtx_queue()
3405 if (tp->retrans_out) { in tcp_clean_rtx_queue()
3407 tp->retrans_out, icsk->icsk_ca_state); in tcp_clean_rtx_queue()
3408 tp->retrans_out = 0; in tcp_clean_rtx_queue()
3419 const struct tcp_sock *tp = tcp_sk(sk); in tcp_ack_probe() local
3424 if (!after(TCP_SKB_CB(head)->end_seq, tcp_wnd_end(tp))) { in tcp_ack_probe()
3489 static inline bool tcp_may_update_window(const struct tcp_sock *tp, in tcp_may_update_window() argument
3493 return after(ack, tp->snd_una) || in tcp_may_update_window()
3494 after(ack_seq, tp->snd_wl1) || in tcp_may_update_window()
3495 (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd); in tcp_may_update_window()
3499 static void tcp_snd_una_update(struct tcp_sock *tp, u32 ack) in tcp_snd_una_update() argument
3501 u32 delta = ack - tp->snd_una; in tcp_snd_una_update()
3503 sock_owned_by_me((struct sock *)tp); in tcp_snd_una_update()
3504 tp->bytes_acked += delta; in tcp_snd_una_update()
3505 tp->snd_una = ack; in tcp_snd_una_update()
3509 static void tcp_rcv_nxt_update(struct tcp_sock *tp, u32 seq) in tcp_rcv_nxt_update() argument
3511 u32 delta = seq - tp->rcv_nxt; in tcp_rcv_nxt_update()
3513 sock_owned_by_me((struct sock *)tp); in tcp_rcv_nxt_update()
3514 tp->bytes_received += delta; in tcp_rcv_nxt_update()
3515 WRITE_ONCE(tp->rcv_nxt, seq); in tcp_rcv_nxt_update()
3526 struct tcp_sock *tp = tcp_sk(sk); in tcp_ack_update_window() local
3531 nwin <<= tp->rx_opt.snd_wscale; in tcp_ack_update_window()
3533 if (tcp_may_update_window(tp, ack, ack_seq, nwin)) { in tcp_ack_update_window()
3535 tcp_update_wl(tp, ack_seq); in tcp_ack_update_window()
3537 if (tp->snd_wnd != nwin) { in tcp_ack_update_window()
3538 tp->snd_wnd = nwin; in tcp_ack_update_window()
3543 tp->pred_flags = 0; in tcp_ack_update_window()
3549 if (nwin > tp->max_window) { in tcp_ack_update_window()
3550 tp->max_window = nwin; in tcp_ack_update_window()
3556 tcp_snd_una_update(tp, ack); in tcp_ack_update_window()
3603 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_challenge_ack() local
3610 &tp->last_oow_ack_time)) in tcp_send_challenge_ack()
3630 static void tcp_store_ts_recent(struct tcp_sock *tp) in tcp_store_ts_recent() argument
3632 tp->rx_opt.ts_recent = tp->rx_opt.rcv_tsval; in tcp_store_ts_recent()
3633 tp->rx_opt.ts_recent_stamp = ktime_get_seconds(); in tcp_store_ts_recent()
3636 static void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) in tcp_replace_ts_recent() argument
3638 if (tp->rx_opt.saw_tstamp && !after(seq, tp->rcv_wup)) { in tcp_replace_ts_recent()
3646 if (tcp_paws_check(&tp->rx_opt, 0)) in tcp_replace_ts_recent()
3647 tcp_store_ts_recent(tp); in tcp_replace_ts_recent()
3656 struct tcp_sock *tp = tcp_sk(sk); in tcp_process_tlp_ack() local
3658 if (before(ack, tp->tlp_high_seq)) in tcp_process_tlp_ack()
3661 if (!tp->tlp_retrans) { in tcp_process_tlp_ack()
3663 tp->tlp_high_seq = 0; in tcp_process_tlp_ack()
3666 tp->tlp_high_seq = 0; in tcp_process_tlp_ack()
3667 } else if (after(ack, tp->tlp_high_seq)) { in tcp_process_tlp_ack()
3680 tp->tlp_high_seq = 0; in tcp_process_tlp_ack()
3698 struct tcp_sock *tp = tcp_sk(sk); in tcp_xmit_recovery() local
3706 if (after(tp->snd_nxt, tp->high_seq)) in tcp_xmit_recovery()
3708 tp->frto = 0; in tcp_xmit_recovery()
3717 struct tcp_sock *tp = tcp_sk(sk); in tcp_newly_delivered() local
3720 delivered = tp->delivered - prior_delivered; in tcp_newly_delivered()
3732 struct tcp_sock *tp = tcp_sk(sk); in tcp_ack() local
3735 u32 prior_snd_una = tp->snd_una; in tcp_ack()
3736 bool is_sack_reneg = tp->is_sack_reneg; in tcp_ack()
3740 int prior_packets = tp->packets_out; in tcp_ack()
3741 u32 delivered = tp->delivered; in tcp_ack()
3742 u32 lost = tp->lost; in tcp_ack()
3758 if (before(ack, prior_snd_una - tp->max_window)) { in tcp_ack()
3769 if (after(ack, tp->snd_nxt)) in tcp_ack()
3783 prior_fack = tcp_is_sack(tp) ? tcp_highest_sack_seq(tp) : tp->snd_una; in tcp_ack()
3784 rs.prior_in_flight = tcp_packets_in_flight(tp); in tcp_ack()
3790 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq); in tcp_ack()
3798 tcp_update_wl(tp, ack_seq); in tcp_ack()
3799 tcp_snd_una_update(tp, ack); in tcp_ack()
3819 if (tcp_ecn_rcv_ecn_echo(tp, tcp_hdr(skb))) { in tcp_ack()
3825 tcp_count_delivered(tp, sack_state.sack_delivered, in tcp_ack()
3848 tp->rcv_tstamp = tcp_jiffies32; in tcp_ack()
3858 if (tp->tlp_high_seq) in tcp_ack()
3881 lost = tp->lost - lost; /* freshly marked lost */ in tcp_ack()
3901 if (tp->tlp_high_seq) in tcp_ack()
4128 static bool tcp_parse_aligned_timestamp(struct tcp_sock *tp, const struct tcphdr *th) in tcp_parse_aligned_timestamp() argument
4134 tp->rx_opt.saw_tstamp = 1; in tcp_parse_aligned_timestamp()
4136 tp->rx_opt.rcv_tsval = ntohl(*ptr); in tcp_parse_aligned_timestamp()
4139 tp->rx_opt.rcv_tsecr = ntohl(*ptr) - tp->tsoffset; in tcp_parse_aligned_timestamp()
4141 tp->rx_opt.rcv_tsecr = 0; in tcp_parse_aligned_timestamp()
4152 const struct tcphdr *th, struct tcp_sock *tp) in tcp_fast_parse_options() argument
4158 tp->rx_opt.saw_tstamp = 0; in tcp_fast_parse_options()
4160 } else if (tp->rx_opt.tstamp_ok && in tcp_fast_parse_options()
4162 if (tcp_parse_aligned_timestamp(tp, th)) in tcp_fast_parse_options()
4166 tcp_parse_options(net, skb, &tp->rx_opt, 1, NULL); in tcp_fast_parse_options()
4167 if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr) in tcp_fast_parse_options()
4168 tp->rx_opt.rcv_tsecr -= tp->tsoffset; in tcp_fast_parse_options()
4233 const struct tcp_sock *tp = tcp_sk(sk); in tcp_disordered_ack() local
4239 (th->ack && seq == TCP_SKB_CB(skb)->end_seq && seq == tp->rcv_nxt) && in tcp_disordered_ack()
4242 ack == tp->snd_una && in tcp_disordered_ack()
4245 !tcp_may_update_window(tp, ack, seq, ntohs(th->window) << tp->rx_opt.snd_wscale) && in tcp_disordered_ack()
4248 (s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) <= (inet_csk(sk)->icsk_rto * 1024) / HZ); in tcp_disordered_ack()
4254 const struct tcp_sock *tp = tcp_sk(sk); in tcp_paws_discard() local
4256 return !tcp_paws_check(&tp->rx_opt, TCP_PAWS_WINDOW) && in tcp_paws_discard()
4273 static inline bool tcp_sequence(const struct tcp_sock *tp, u32 seq, u32 end_seq) in tcp_sequence() argument
4275 return !before(end_seq, tp->rcv_wup) && in tcp_sequence()
4276 !after(seq, tp->rcv_nxt + tcp_receive_window(tp)); in tcp_sequence()
4323 struct tcp_sock *tp = tcp_sk(sk); in tcp_fin() local
4373 skb_rbtree_purge(&tp->out_of_order_queue); in tcp_fin()
4374 if (tcp_is_sack(tp)) in tcp_fin()
4375 tcp_sack_reset(&tp->rx_opt); in tcp_fin()
4405 struct tcp_sock *tp = tcp_sk(sk); in tcp_dsack_set() local
4407 if (tcp_is_sack(tp) && READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_dsack)) { in tcp_dsack_set()
4410 if (before(seq, tp->rcv_nxt)) in tcp_dsack_set()
4417 tp->rx_opt.dsack = 1; in tcp_dsack_set()
4418 tp->duplicate_sack[0].start_seq = seq; in tcp_dsack_set()
4419 tp->duplicate_sack[0].end_seq = end_seq; in tcp_dsack_set()
4425 struct tcp_sock *tp = tcp_sk(sk); in tcp_dsack_extend() local
4427 if (!tp->rx_opt.dsack) in tcp_dsack_extend()
4430 tcp_sack_extend(tp->duplicate_sack, seq, end_seq); in tcp_dsack_extend()
4447 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_dupack() local
4450 before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { in tcp_send_dupack()
4454 if (tcp_is_sack(tp) && READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_dsack)) { in tcp_send_dupack()
4458 if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) in tcp_send_dupack()
4459 end_seq = tp->rcv_nxt; in tcp_send_dupack()
4470 static void tcp_sack_maybe_coalesce(struct tcp_sock *tp) in tcp_sack_maybe_coalesce() argument
4473 struct tcp_sack_block *sp = &tp->selective_acks[0]; in tcp_sack_maybe_coalesce()
4479 for (this_sack = 1; this_sack < tp->rx_opt.num_sacks;) { in tcp_sack_maybe_coalesce()
4486 tp->rx_opt.num_sacks--; in tcp_sack_maybe_coalesce()
4487 for (i = this_sack; i < tp->rx_opt.num_sacks; i++) in tcp_sack_maybe_coalesce()
4498 struct tcp_sock *tp = tcp_sk(sk); in tcp_sack_compress_send_ack() local
4500 if (!tp->compressed_ack) in tcp_sack_compress_send_ack()
4503 if (hrtimer_try_to_cancel(&tp->compressed_ack_timer) == 1) in tcp_sack_compress_send_ack()
4511 tp->compressed_ack - 1); in tcp_sack_compress_send_ack()
4513 tp->compressed_ack = 0; in tcp_sack_compress_send_ack()
4525 struct tcp_sock *tp = tcp_sk(sk); in tcp_sack_new_ofo_skb() local
4526 struct tcp_sack_block *sp = &tp->selective_acks[0]; in tcp_sack_new_ofo_skb()
4527 int cur_sacks = tp->rx_opt.num_sacks; in tcp_sack_new_ofo_skb()
4541 tcp_sack_maybe_coalesce(tp); in tcp_sack_new_ofo_skb()
4557 tp->rx_opt.num_sacks--; in tcp_sack_new_ofo_skb()
4567 tp->rx_opt.num_sacks++; in tcp_sack_new_ofo_skb()
4572 static void tcp_sack_remove(struct tcp_sock *tp) in tcp_sack_remove() argument
4574 struct tcp_sack_block *sp = &tp->selective_acks[0]; in tcp_sack_remove()
4575 int num_sacks = tp->rx_opt.num_sacks; in tcp_sack_remove()
4579 if (RB_EMPTY_ROOT(&tp->out_of_order_queue)) { in tcp_sack_remove()
4580 tp->rx_opt.num_sacks = 0; in tcp_sack_remove()
4586 if (!before(tp->rcv_nxt, sp->start_seq)) { in tcp_sack_remove()
4590 WARN_ON(before(tp->rcv_nxt, sp->end_seq)); in tcp_sack_remove()
4594 tp->selective_acks[i-1] = tp->selective_acks[i]; in tcp_sack_remove()
4601 tp->rx_opt.num_sacks = num_sacks; in tcp_sack_remove()
4686 struct tcp_sock *tp = tcp_sk(sk); in tcp_ofo_queue() local
4687 __u32 dsack_high = tp->rcv_nxt; in tcp_ofo_queue()
4692 p = rb_first(&tp->out_of_order_queue); in tcp_ofo_queue()
4695 if (after(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) in tcp_ofo_queue()
4705 rb_erase(&skb->rbnode, &tp->out_of_order_queue); in tcp_ofo_queue()
4707 if (unlikely(!after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt))) { in tcp_ofo_queue()
4714 tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq); in tcp_ofo_queue()
4753 struct tcp_sock *tp = tcp_sk(sk); in tcp_data_queue_ofo() local
4769 tp->pred_flags = 0; in tcp_data_queue_ofo()
4772 tp->rcv_ooopack += max_t(u16, 1, skb_shinfo(skb)->gso_segs); in tcp_data_queue_ofo()
4777 p = &tp->out_of_order_queue.rb_node; in tcp_data_queue_ofo()
4778 if (RB_EMPTY_ROOT(&tp->out_of_order_queue)) { in tcp_data_queue_ofo()
4780 if (tcp_is_sack(tp)) { in tcp_data_queue_ofo()
4781 tp->rx_opt.num_sacks = 1; in tcp_data_queue_ofo()
4782 tp->selective_acks[0].start_seq = seq; in tcp_data_queue_ofo()
4783 tp->selective_acks[0].end_seq = end_seq; in tcp_data_queue_ofo()
4786 rb_insert_color(&skb->rbnode, &tp->out_of_order_queue); in tcp_data_queue_ofo()
4787 tp->ooo_last_skb = skb; in tcp_data_queue_ofo()
4794 if (tcp_ooo_try_coalesce(sk, tp->ooo_last_skb, in tcp_data_queue_ofo()
4800 if (tcp_is_sack(tp)) in tcp_data_queue_ofo()
4807 if (!before(seq, TCP_SKB_CB(tp->ooo_last_skb)->end_seq)) { in tcp_data_queue_ofo()
4808 parent = &tp->ooo_last_skb->rbnode; in tcp_data_queue_ofo()
4840 &tp->out_of_order_queue); in tcp_data_queue_ofo()
4858 rb_insert_color(&skb->rbnode, &tp->out_of_order_queue); in tcp_data_queue_ofo()
4870 rb_erase(&skb1->rbnode, &tp->out_of_order_queue); in tcp_data_queue_ofo()
4878 tp->ooo_last_skb = skb; in tcp_data_queue_ofo()
4881 if (tcp_is_sack(tp)) in tcp_data_queue_ofo()
4888 if (tcp_is_sack(tp)) in tcp_data_queue_ofo()
4966 const struct tcp_sock *tp = tcp_sk(sk); in tcp_data_ready() local
4967 int avail = tp->rcv_nxt - tp->copied_seq; in tcp_data_ready()
4971 tcp_receive_window(tp) > inet_csk(sk)->icsk_ack.rcv_mss) in tcp_data_ready()
4979 struct tcp_sock *tp = tcp_sk(sk); in tcp_data_queue() local
4993 tp->rx_opt.dsack = 0; in tcp_data_queue()
4999 if (TCP_SKB_CB(skb)->seq == tp->rcv_nxt) { in tcp_data_queue()
5000 if (tcp_receive_window(tp) == 0) { in tcp_data_queue()
5021 if (!RB_EMPTY_ROOT(&tp->out_of_order_queue)) { in tcp_data_queue()
5027 if (RB_EMPTY_ROOT(&tp->out_of_order_queue)) in tcp_data_queue()
5031 if (tp->rx_opt.num_sacks) in tcp_data_queue()
5032 tcp_sack_remove(tp); in tcp_data_queue()
5043 if (!after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) { in tcp_data_queue()
5058 if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt + tcp_receive_window(tp))) in tcp_data_queue()
5061 if (before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { in tcp_data_queue()
5063 tcp_dsack_set(sk, TCP_SKB_CB(skb)->seq, tp->rcv_nxt); in tcp_data_queue()
5068 if (!tcp_receive_window(tp)) { in tcp_data_queue()
5238 struct tcp_sock *tp = tcp_sk(sk); in tcp_collapse_ofo_queue() local
5243 skb = skb_rb_first(&tp->out_of_order_queue); in tcp_collapse_ofo_queue()
5246 tp->ooo_last_skb = skb_rb_last(&tp->out_of_order_queue); in tcp_collapse_ofo_queue()
5265 tcp_collapse(sk, NULL, &tp->out_of_order_queue, in tcp_collapse_ofo_queue()
5296 struct tcp_sock *tp = tcp_sk(sk); in tcp_prune_ofo_queue() local
5300 if (RB_EMPTY_ROOT(&tp->out_of_order_queue)) in tcp_prune_ofo_queue()
5305 node = &tp->ooo_last_skb->rbnode; in tcp_prune_ofo_queue()
5308 rb_erase(node, &tp->out_of_order_queue); in tcp_prune_ofo_queue()
5320 tp->ooo_last_skb = rb_to_skb(prev); in tcp_prune_ofo_queue()
5327 if (tp->rx_opt.sack_ok) in tcp_prune_ofo_queue()
5328 tcp_sack_reset(&tp->rx_opt); in tcp_prune_ofo_queue()
5341 struct tcp_sock *tp = tcp_sk(sk); in tcp_prune_queue() local
5348 tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U * tp->advmss); in tcp_prune_queue()
5358 tp->copied_seq, tp->rcv_nxt); in tcp_prune_queue()
5379 tp->pred_flags = 0; in tcp_prune_queue()
5385 const struct tcp_sock *tp = tcp_sk(sk); in tcp_should_expand_sndbuf() local
5402 if (tcp_packets_in_flight(tp) >= tp->snd_cwnd) in tcp_should_expand_sndbuf()
5410 struct tcp_sock *tp = tcp_sk(sk); in tcp_new_space() local
5414 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_new_space()
5453 struct tcp_sock *tp = tcp_sk(sk); in __tcp_ack_snd_check() local
5457 if (((tp->rcv_nxt - tp->rcv_wup) > inet_csk(sk)->icsk_ack.rcv_mss && in __tcp_ack_snd_check()
5463 (tp->rcv_nxt - tp->copied_seq < sk->sk_rcvlowat || in __tcp_ack_snd_check()
5464 __tcp_select_window(sk) >= tp->rcv_wnd)) || in __tcp_ack_snd_check()
5474 if (!ofo_possible || RB_EMPTY_ROOT(&tp->out_of_order_queue)) { in __tcp_ack_snd_check()
5479 if (!tcp_is_sack(tp) || in __tcp_ack_snd_check()
5480 tp->compressed_ack >= READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_comp_sack_nr)) in __tcp_ack_snd_check()
5483 if (tp->compressed_ack_rcv_nxt != tp->rcv_nxt) { in __tcp_ack_snd_check()
5484 tp->compressed_ack_rcv_nxt = tp->rcv_nxt; in __tcp_ack_snd_check()
5485 tp->dup_ack_counter = 0; in __tcp_ack_snd_check()
5487 if (tp->dup_ack_counter < TCP_FASTRETRANS_THRESH) { in __tcp_ack_snd_check()
5488 tp->dup_ack_counter++; in __tcp_ack_snd_check()
5491 tp->compressed_ack++; in __tcp_ack_snd_check()
5492 if (hrtimer_is_queued(&tp->compressed_ack_timer)) in __tcp_ack_snd_check()
5497 rtt = tp->rcv_rtt_est.rtt_us; in __tcp_ack_snd_check()
5498 if (tp->srtt_us && tp->srtt_us < rtt) in __tcp_ack_snd_check()
5499 rtt = tp->srtt_us; in __tcp_ack_snd_check()
5505 hrtimer_start_range_ns(&tp->compressed_ack_timer, ns_to_ktime(delay), in __tcp_ack_snd_check()
5531 struct tcp_sock *tp = tcp_sk(sk); in tcp_check_urg() local
5539 if (after(tp->copied_seq, ptr)) in tcp_check_urg()
5552 if (before(ptr, tp->rcv_nxt)) in tcp_check_urg()
5556 if (tp->urg_data && !after(ptr, tp->urg_seq)) in tcp_check_urg()
5577 if (tp->urg_seq == tp->copied_seq && tp->urg_data && in tcp_check_urg()
5578 !sock_flag(sk, SOCK_URGINLINE) && tp->copied_seq != tp->rcv_nxt) { in tcp_check_urg()
5580 tp->copied_seq++; in tcp_check_urg()
5581 if (skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq)) { in tcp_check_urg()
5587 tp->urg_data = TCP_URG_NOTYET; in tcp_check_urg()
5588 WRITE_ONCE(tp->urg_seq, ptr); in tcp_check_urg()
5591 tp->pred_flags = 0; in tcp_check_urg()
5597 struct tcp_sock *tp = tcp_sk(sk); in tcp_urg() local
5604 if (tp->urg_data == TCP_URG_NOTYET) { in tcp_urg()
5605 u32 ptr = tp->urg_seq - ntohl(th->seq) + (th->doff * 4) - in tcp_urg()
5613 tp->urg_data = TCP_URG_VALID | tmp; in tcp_urg()
5630 struct tcp_sock *tp = tcp_sk(sk); in tcp_reset_check() local
5632 return unlikely(TCP_SKB_CB(skb)->seq == (tp->rcv_nxt - 1) && in tcp_reset_check()
5643 struct tcp_sock *tp = tcp_sk(sk); in tcp_validate_incoming() local
5647 if (tcp_fast_parse_options(sock_net(sk), skb, th, tp) && in tcp_validate_incoming()
5648 tp->rx_opt.saw_tstamp && in tcp_validate_incoming()
5654 &tp->last_oow_ack_time)) in tcp_validate_incoming()
5662 if (!tcp_sequence(tp, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq)) { in tcp_validate_incoming()
5674 &tp->last_oow_ack_time)) in tcp_validate_incoming()
5693 if (TCP_SKB_CB(skb)->seq == tp->rcv_nxt || in tcp_validate_incoming()
5696 } else if (tcp_is_sack(tp) && tp->rx_opt.num_sacks > 0) { in tcp_validate_incoming()
5697 struct tcp_sack_block *sp = &tp->selective_acks[0]; in tcp_validate_incoming()
5701 for (this_sack = 1; this_sack < tp->rx_opt.num_sacks; in tcp_validate_incoming()
5719 if (tp->syn_fastopen && !tp->data_segs_in && in tcp_validate_incoming()
5776 struct tcp_sock *tp = tcp_sk(sk); in tcp_rcv_established() local
5782 tcp_mstamp_refresh(tp); in tcp_rcv_established()
5800 tp->rx_opt.saw_tstamp = 0; in tcp_rcv_established()
5811 if ((tcp_flag_word(th) & TCP_HP_BITS) == tp->pred_flags && in tcp_rcv_established()
5812 TCP_SKB_CB(skb)->seq == tp->rcv_nxt && in tcp_rcv_established()
5813 !after(TCP_SKB_CB(skb)->ack_seq, tp->snd_nxt)) { in tcp_rcv_established()
5814 int tcp_header_len = tp->tcp_header_len; in tcp_rcv_established()
5824 if (!tcp_parse_aligned_timestamp(tp, th)) in tcp_rcv_established()
5828 if ((s32)(tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent) < 0) in tcp_rcv_established()
5847 tp->rcv_nxt == tp->rcv_wup) in tcp_rcv_established()
5848 tcp_store_ts_recent(tp); in tcp_rcv_established()
5860 tp->rcv_rtt_last_tsecr = tp->rx_opt.rcv_tsecr; in tcp_rcv_established()
5882 tp->rcv_nxt == tp->rcv_wup) in tcp_rcv_established()
5883 tcp_store_ts_recent(tp); in tcp_rcv_established()
5895 if (TCP_SKB_CB(skb)->ack_seq != tp->snd_una) { in tcp_rcv_established()
5902 tcp_update_wl(tp, TCP_SKB_CB(skb)->seq); in tcp_rcv_established()
5956 struct tcp_sock *tp = tcp_sk(sk); in tcp_init_transfer() local
5968 if (tp->total_retrans > 1 && tp->undo_marker) in tcp_init_transfer()
5969 tp->snd_cwnd = 1; in tcp_init_transfer()
5971 tp->snd_cwnd = tcp_init_cwnd(tp, __sk_dst_get(sk)); in tcp_init_transfer()
5972 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_init_transfer()
5983 struct tcp_sock *tp = tcp_sk(sk); in tcp_finish_connect() local
6000 tp->lsndtime = tcp_jiffies32; in tcp_finish_connect()
6003 inet_csk_reset_keepalive_timer(sk, keepalive_time_when(tp)); in tcp_finish_connect()
6005 if (!tp->rx_opt.snd_wscale) in tcp_finish_connect()
6006 __tcp_fast_path_on(tp, tp->snd_wnd); in tcp_finish_connect()
6008 tp->pred_flags = 0; in tcp_finish_connect()
6014 struct tcp_sock *tp = tcp_sk(sk); in tcp_rcv_fastopen_synack() local
6015 struct sk_buff *data = tp->syn_data ? tcp_rtx_queue_head(sk) : NULL; in tcp_rcv_fastopen_synack()
6016 u16 mss = tp->rx_opt.mss_clamp, try_exp = 0; in tcp_rcv_fastopen_synack()
6019 if (mss == tp->rx_opt.user_mss) { in tcp_rcv_fastopen_synack()
6029 if (!tp->syn_fastopen) { in tcp_rcv_fastopen_synack()
6032 } else if (tp->total_retrans) { in tcp_rcv_fastopen_synack()
6039 } else if (cookie->len < 0 && !tp->syn_data) { in tcp_rcv_fastopen_synack()
6044 try_exp = tp->syn_fastopen_exp ? 2 : 1; in tcp_rcv_fastopen_synack()
6050 if (tp->total_retrans) in tcp_rcv_fastopen_synack()
6051 tp->fastopen_client_fail = TFO_SYN_RETRANSMITTED; in tcp_rcv_fastopen_synack()
6053 tp->fastopen_client_fail = TFO_DATA_NOT_ACKED; in tcp_rcv_fastopen_synack()
6063 tp->syn_data_acked = tp->syn_data; in tcp_rcv_fastopen_synack()
6064 if (tp->syn_data_acked) { in tcp_rcv_fastopen_synack()
6067 if (tp->delivered > 1) in tcp_rcv_fastopen_synack()
6068 --tp->delivered; in tcp_rcv_fastopen_synack()
6076 static void smc_check_reset_syn(struct tcp_sock *tp) in smc_check_reset_syn() argument
6080 if (tp->syn_smc && !tp->rx_opt.smc_ok) in smc_check_reset_syn()
6081 tp->syn_smc = 0; in smc_check_reset_syn()
6088 struct tcp_sock *tp = tcp_sk(sk); in tcp_try_undo_spurious_syn() local
6095 syn_stamp = tp->retrans_stamp; in tcp_try_undo_spurious_syn()
6096 if (tp->undo_marker && syn_stamp && tp->rx_opt.saw_tstamp && in tcp_try_undo_spurious_syn()
6097 syn_stamp == tp->rx_opt.rcv_tsecr) in tcp_try_undo_spurious_syn()
6098 tp->undo_marker = 0; in tcp_try_undo_spurious_syn()
6105 struct tcp_sock *tp = tcp_sk(sk); in tcp_rcv_synsent_state_process() local
6107 int saved_clamp = tp->rx_opt.mss_clamp; in tcp_rcv_synsent_state_process()
6110 tcp_parse_options(sock_net(sk), skb, &tp->rx_opt, 0, &foc); in tcp_rcv_synsent_state_process()
6111 if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr) in tcp_rcv_synsent_state_process()
6112 tp->rx_opt.rcv_tsecr -= tp->tsoffset; in tcp_rcv_synsent_state_process()
6123 if (!after(TCP_SKB_CB(skb)->ack_seq, tp->snd_una) || in tcp_rcv_synsent_state_process()
6124 after(TCP_SKB_CB(skb)->ack_seq, tp->snd_nxt)) { in tcp_rcv_synsent_state_process()
6133 if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && in tcp_rcv_synsent_state_process()
6134 !between(tp->rx_opt.rcv_tsecr, tp->retrans_stamp, in tcp_rcv_synsent_state_process()
6135 tcp_time_stamp(tp))) { in tcp_rcv_synsent_state_process()
6171 tcp_ecn_rcv_synack(tp, th); in tcp_rcv_synsent_state_process()
6173 tcp_init_wl(tp, TCP_SKB_CB(skb)->seq); in tcp_rcv_synsent_state_process()
6180 WRITE_ONCE(tp->rcv_nxt, TCP_SKB_CB(skb)->seq + 1); in tcp_rcv_synsent_state_process()
6181 tp->rcv_wup = TCP_SKB_CB(skb)->seq + 1; in tcp_rcv_synsent_state_process()
6186 tp->snd_wnd = ntohs(th->window); in tcp_rcv_synsent_state_process()
6188 if (!tp->rx_opt.wscale_ok) { in tcp_rcv_synsent_state_process()
6189 tp->rx_opt.snd_wscale = tp->rx_opt.rcv_wscale = 0; in tcp_rcv_synsent_state_process()
6190 tp->window_clamp = min(tp->window_clamp, 65535U); in tcp_rcv_synsent_state_process()
6193 if (tp->rx_opt.saw_tstamp) { in tcp_rcv_synsent_state_process()
6194 tp->rx_opt.tstamp_ok = 1; in tcp_rcv_synsent_state_process()
6195 tp->tcp_header_len = in tcp_rcv_synsent_state_process()
6197 tp->advmss -= TCPOLEN_TSTAMP_ALIGNED; in tcp_rcv_synsent_state_process()
6198 tcp_store_ts_recent(tp); in tcp_rcv_synsent_state_process()
6200 tp->tcp_header_len = sizeof(struct tcphdr); in tcp_rcv_synsent_state_process()
6209 WRITE_ONCE(tp->copied_seq, tp->rcv_nxt); in tcp_rcv_synsent_state_process()
6211 smc_check_reset_syn(tp); in tcp_rcv_synsent_state_process()
6217 fastopen_fail = (tp->syn_fastopen || tp->syn_data) && in tcp_rcv_synsent_state_process()
6263 if (tp->rx_opt.ts_recent_stamp && tp->rx_opt.saw_tstamp && in tcp_rcv_synsent_state_process()
6264 tcp_paws_reject(&tp->rx_opt, 0)) in tcp_rcv_synsent_state_process()
6274 if (tp->rx_opt.saw_tstamp) { in tcp_rcv_synsent_state_process()
6275 tp->rx_opt.tstamp_ok = 1; in tcp_rcv_synsent_state_process()
6276 tcp_store_ts_recent(tp); in tcp_rcv_synsent_state_process()
6277 tp->tcp_header_len = in tcp_rcv_synsent_state_process()
6280 tp->tcp_header_len = sizeof(struct tcphdr); in tcp_rcv_synsent_state_process()
6283 WRITE_ONCE(tp->rcv_nxt, TCP_SKB_CB(skb)->seq + 1); in tcp_rcv_synsent_state_process()
6284 WRITE_ONCE(tp->copied_seq, tp->rcv_nxt); in tcp_rcv_synsent_state_process()
6285 tp->rcv_wup = TCP_SKB_CB(skb)->seq + 1; in tcp_rcv_synsent_state_process()
6290 tp->snd_wnd = ntohs(th->window); in tcp_rcv_synsent_state_process()
6291 tp->snd_wl1 = TCP_SKB_CB(skb)->seq; in tcp_rcv_synsent_state_process()
6292 tp->max_window = tp->snd_wnd; in tcp_rcv_synsent_state_process()
6294 tcp_ecn_rcv_syn(tp, th); in tcp_rcv_synsent_state_process()
6323 tcp_clear_options(&tp->rx_opt); in tcp_rcv_synsent_state_process()
6324 tp->rx_opt.mss_clamp = saved_clamp; in tcp_rcv_synsent_state_process()
6328 tcp_clear_options(&tp->rx_opt); in tcp_rcv_synsent_state_process()
6329 tp->rx_opt.mss_clamp = saved_clamp; in tcp_rcv_synsent_state_process()
6374 struct tcp_sock *tp = tcp_sk(sk); in tcp_rcv_state_process() local
6412 tp->rx_opt.saw_tstamp = 0; in tcp_rcv_state_process()
6413 tcp_mstamp_refresh(tp); in tcp_rcv_state_process()
6425 tcp_mstamp_refresh(tp); in tcp_rcv_state_process()
6426 tp->rx_opt.saw_tstamp = 0; in tcp_rcv_state_process()
6427 req = rcu_dereference_protected(tp->fastopen_rsk, in tcp_rcv_state_process()
6458 tp->delivered++; /* SYN-ACK delivery isn't tracked in tcp_ack */ in tcp_rcv_state_process()
6459 if (!tp->srtt_us) in tcp_rcv_state_process()
6466 tp->retrans_stamp = 0; in tcp_rcv_state_process()
6469 WRITE_ONCE(tp->copied_seq, tp->rcv_nxt); in tcp_rcv_state_process()
6482 tp->snd_una = TCP_SKB_CB(skb)->ack_seq; in tcp_rcv_state_process()
6483 tp->snd_wnd = ntohs(th->window) << tp->rx_opt.snd_wscale; in tcp_rcv_state_process()
6484 tcp_init_wl(tp, TCP_SKB_CB(skb)->seq); in tcp_rcv_state_process()
6486 if (tp->rx_opt.tstamp_ok) in tcp_rcv_state_process()
6487 tp->advmss -= TCPOLEN_TSTAMP_ALIGNED; in tcp_rcv_state_process()
6493 tp->lsndtime = tcp_jiffies32; in tcp_rcv_state_process()
6496 tcp_fast_path_on(tp); in tcp_rcv_state_process()
6505 if (tp->snd_una != tp->write_seq) in tcp_rcv_state_process()
6519 if (tp->linger2 < 0) { in tcp_rcv_state_process()
6525 after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) { in tcp_rcv_state_process()
6527 if (tp->syn_fastopen && th->fin) in tcp_rcv_state_process()
6553 if (tp->snd_una == tp->write_seq) { in tcp_rcv_state_process()
6560 if (tp->snd_una == tp->write_seq) { in tcp_rcv_state_process()
6576 if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { in tcp_rcv_state_process()
6590 after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) { in tcp_rcv_state_process()
6791 struct tcp_sock *tp = tcp_sk(sk); in tcp_get_syncookie_mss() local
6806 mss = tcp_parse_mss_option(th, tp->rx_opt.user_mss); in tcp_get_syncookie_mss()
6821 struct tcp_sock *tp = tcp_sk(sk); in tcp_conn_request() local
6860 tmp_opt.user_mss = tp->rx_opt.user_mss; in tcp_conn_request()