Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'tcp-misc-changes'

Eric Dumazet says:

====================
tcp: misc changes

Minor changes, following recent changes in TCP stack.
====================

Link: https://patch.msgid.link/20250301201424.2046477-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+77 -60
+9
include/net/dropreason-core.h
··· 40 40 FN(TCP_OFOMERGE) \ 41 41 FN(TCP_RFC7323_PAWS) \ 42 42 FN(TCP_RFC7323_PAWS_ACK) \ 43 + FN(TCP_RFC7323_TSECR) \ 44 + FN(TCP_LISTEN_OVERFLOW) \ 43 45 FN(TCP_OLD_SEQUENCE) \ 44 46 FN(TCP_INVALID_SEQUENCE) \ 45 47 FN(TCP_INVALID_ACK_SEQUENCE) \ ··· 283 281 * Corresponds to LINUX_MIB_PAWS_OLD_ACK. 284 282 */ 285 283 SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK, 284 + /** 285 + * @SKB_DROP_REASON_TCP_RFC7323_TSECR: PAWS check, invalid TSEcr. 286 + * Corresponds to LINUX_MIB_TSECRREJECTED. 287 + */ 288 + SKB_DROP_REASON_TCP_RFC7323_TSECR, 289 + /** @SKB_DROP_REASON_TCP_LISTEN_OVERFLOW: listener queue full. */ 290 + SKB_DROP_REASON_TCP_LISTEN_OVERFLOW, 286 291 /** @SKB_DROP_REASON_TCP_OLD_SEQUENCE: Old SEQ field (duplicate packet) */ 287 292 SKB_DROP_REASON_TCP_OLD_SEQUENCE, 288 293 /** @SKB_DROP_REASON_TCP_INVALID_SEQUENCE: Not acceptable SEQ field */
+1 -1
include/net/inet6_hashtables.h
··· 150 150 int iif, int sdif, 151 151 bool *refcounted) 152 152 { 153 - struct net *net = dev_net(skb_dst(skb)->dev); 153 + struct net *net = dev_net_rcu(skb_dst(skb)->dev); 154 154 const struct ipv6hdr *ip6h = ipv6_hdr(skb); 155 155 struct sock *sk; 156 156
+1 -1
include/net/inet_hashtables.h
··· 492 492 const int sdif, 493 493 bool *refcounted) 494 494 { 495 - struct net *net = dev_net(skb_dst(skb)->dev); 495 + struct net *net = dev_net_rcu(skb_dst(skb)->dev); 496 496 const struct iphdr *iph = ip_hdr(skb); 497 497 struct sock *sk; 498 498
+1 -1
include/net/tcp.h
··· 392 392 u32 *tw_isn); 393 393 struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, 394 394 struct request_sock *req, bool fastopen, 395 - bool *lost_race); 395 + bool *lost_race, enum skb_drop_reason *drop_reason); 396 396 enum skb_drop_reason tcp_child_process(struct sock *parent, struct sock *child, 397 397 struct sk_buff *skb); 398 398 void tcp_enter_loss(struct sock *sk);
+20 -20
net/ipv4/tcp.c
··· 3693 3693 3694 3694 int tcp_set_window_clamp(struct sock *sk, int val) 3695 3695 { 3696 + u32 old_window_clamp, new_window_clamp; 3696 3697 struct tcp_sock *tp = tcp_sk(sk); 3697 3698 3698 3699 if (!val) { 3699 3700 if (sk->sk_state != TCP_CLOSE) 3700 3701 return -EINVAL; 3701 3702 WRITE_ONCE(tp->window_clamp, 0); 3702 - } else { 3703 - u32 new_rcv_ssthresh, old_window_clamp = tp->window_clamp; 3704 - u32 new_window_clamp = val < SOCK_MIN_RCVBUF / 2 ? 3705 - SOCK_MIN_RCVBUF / 2 : val; 3706 - 3707 - if (new_window_clamp == old_window_clamp) 3708 - return 0; 3709 - 3710 - WRITE_ONCE(tp->window_clamp, new_window_clamp); 3711 - if (new_window_clamp < old_window_clamp) { 3712 - /* need to apply the reserved mem provisioning only 3713 - * when shrinking the window clamp 3714 - */ 3715 - __tcp_adjust_rcv_ssthresh(sk, tp->window_clamp); 3716 - 3717 - } else { 3718 - new_rcv_ssthresh = min(tp->rcv_wnd, tp->window_clamp); 3719 - tp->rcv_ssthresh = max(new_rcv_ssthresh, 3720 - tp->rcv_ssthresh); 3721 - } 3703 + return 0; 3722 3704 } 3705 + 3706 + old_window_clamp = tp->window_clamp; 3707 + new_window_clamp = max_t(int, SOCK_MIN_RCVBUF / 2, val); 3708 + 3709 + if (new_window_clamp == old_window_clamp) 3710 + return 0; 3711 + 3712 + WRITE_ONCE(tp->window_clamp, new_window_clamp); 3713 + 3714 + /* Need to apply the reserved mem provisioning only 3715 + * when shrinking the window clamp. 3716 + */ 3717 + if (new_window_clamp < old_window_clamp) 3718 + __tcp_adjust_rcv_ssthresh(sk, new_window_clamp); 3719 + else 3720 + tp->rcv_ssthresh = clamp(new_window_clamp, 3721 + tp->rcv_ssthresh, 3722 + tp->rcv_wnd); 3723 3723 return 0; 3724 3724 } 3725 3725
+2 -3
net/ipv4/tcp_input.c
··· 6812 6812 WARN_ON_ONCE(sk->sk_state != TCP_SYN_RECV && 6813 6813 sk->sk_state != TCP_FIN_WAIT1); 6814 6814 6815 - if (!tcp_check_req(sk, skb, req, true, &req_stolen)) { 6816 - SKB_DR_SET(reason, TCP_FASTOPEN); 6815 + SKB_DR_SET(reason, TCP_FASTOPEN); 6816 + if (!tcp_check_req(sk, skb, req, true, &req_stolen, &reason)) 6817 6817 goto discard; 6818 - } 6819 6818 } 6820 6819 6821 6820 if (!th->ack && !th->rst && !th->syn) {
+9 -8
net/ipv4/tcp_ipv4.c
··· 494 494 { 495 495 const struct iphdr *iph = (const struct iphdr *)skb->data; 496 496 struct tcphdr *th = (struct tcphdr *)(skb->data + (iph->ihl << 2)); 497 - struct tcp_sock *tp; 497 + struct net *net = dev_net_rcu(skb->dev); 498 498 const int type = icmp_hdr(skb)->type; 499 499 const int code = icmp_hdr(skb)->code; 500 - struct sock *sk; 501 500 struct request_sock *fastopen; 501 + struct tcp_sock *tp; 502 502 u32 seq, snd_una; 503 + struct sock *sk; 503 504 int err; 504 - struct net *net = dev_net(skb->dev); 505 505 506 506 sk = __inet_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, 507 507 iph->daddr, th->dest, iph->saddr, ··· 786 786 arg.iov[0].iov_base = (unsigned char *)&rep; 787 787 arg.iov[0].iov_len = sizeof(rep.th); 788 788 789 - net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev); 789 + net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); 790 790 791 791 /* Invalid TCP option size or twice included auth */ 792 792 if (tcp_parse_auth_options(tcp_hdr(skb), &md5_hash_location, &aoh)) ··· 1155 1155 tcp_rsk(req)->rcv_nxt, 1156 1156 tcp_synack_window(req) >> inet_rsk(req)->rcv_wscale, 1157 1157 tcp_rsk_tsval(tcp_rsk(req)), 1158 - READ_ONCE(req->ts_recent), 1158 + req->ts_recent, 1159 1159 0, &key, 1160 1160 inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, 1161 1161 ip_hdr(skb)->tos, ··· 1961 1961 1962 1962 int tcp_v4_early_demux(struct sk_buff *skb) 1963 1963 { 1964 - struct net *net = dev_net(skb->dev); 1964 + struct net *net = dev_net_rcu(skb->dev); 1965 1965 const struct iphdr *iph; 1966 1966 const struct tcphdr *th; 1967 1967 struct sock *sk; ··· 2172 2172 2173 2173 int tcp_v4_rcv(struct sk_buff *skb) 2174 2174 { 2175 - struct net *net = dev_net(skb->dev); 2175 + struct net *net = dev_net_rcu(skb->dev); 2176 2176 enum skb_drop_reason drop_reason; 2177 2177 int sdif = inet_sdif(skb); 2178 2178 int dif = inet_iif(skb); ··· 2265 2265 th = (const struct tcphdr *)skb->data; 2266 2266 iph = ip_hdr(skb); 2267 2267 tcp_v4_fill_cb(skb, iph, th); 2268 - nsk = tcp_check_req(sk, skb, req, false, &req_stolen); 2268 + nsk = tcp_check_req(sk, skb, req, false, &req_stolen, 2269 + &drop_reason); 2269 2270 } else { 2270 2271 drop_reason = SKB_DROP_REASON_SOCKET_FILTER; 2271 2272 }
+3 -3
net/ipv4/tcp_metrics.c
··· 170 170 bool reclaim = false; 171 171 172 172 spin_lock_bh(&tcp_metrics_lock); 173 - net = dev_net(dst->dev); 173 + net = dev_net_rcu(dst->dev); 174 174 175 175 /* While waiting for the spin-lock the cache might have been populated 176 176 * with this entry and so we have to check again. ··· 273 273 return NULL; 274 274 } 275 275 276 - net = dev_net(dst->dev); 276 + net = dev_net_rcu(dst->dev); 277 277 hash ^= net_hash_mix(net); 278 278 hash = hash_32(hash, tcp_metrics_hash_log); 279 279 ··· 318 318 else 319 319 return NULL; 320 320 321 - net = dev_net(dst->dev); 321 + net = dev_net_rcu(dst->dev); 322 322 hash ^= net_hash_mix(net); 323 323 hash = hash_32(hash, tcp_metrics_hash_log); 324 324
+12 -5
net/ipv4/tcp_minisocks.c
··· 585 585 586 586 if (newtp->rx_opt.tstamp_ok) { 587 587 newtp->tcp_usec_ts = treq->req_usec_ts; 588 - newtp->rx_opt.ts_recent = READ_ONCE(req->ts_recent); 588 + newtp->rx_opt.ts_recent = req->ts_recent; 589 589 newtp->rx_opt.ts_recent_stamp = ktime_get_seconds(); 590 590 newtp->tcp_header_len = sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED; 591 591 } else { ··· 657 657 658 658 struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, 659 659 struct request_sock *req, 660 - bool fastopen, bool *req_stolen) 660 + bool fastopen, bool *req_stolen, 661 + enum skb_drop_reason *drop_reason) 661 662 { 662 663 struct tcp_options_received tmp_opt; 663 664 struct sock *child; ··· 673 672 tcp_parse_options(sock_net(sk), skb, &tmp_opt, 0, NULL); 674 673 675 674 if (tmp_opt.saw_tstamp) { 676 - tmp_opt.ts_recent = READ_ONCE(req->ts_recent); 675 + tmp_opt.ts_recent = req->ts_recent; 677 676 if (tmp_opt.rcv_tsecr) { 678 677 if (inet_rsk(req)->tstamp_ok && !fastopen) 679 678 tsecr_reject = !between(tmp_opt.rcv_tsecr, ··· 809 808 LINUX_MIB_TCPACKSKIPPEDSYNRECV, 810 809 &tcp_rsk(req)->last_oow_ack_time)) 811 810 req->rsk_ops->send_ack(sk, skb, req); 812 - if (paws_reject) 811 + if (paws_reject) { 812 + SKB_DR_SET(*drop_reason, TCP_RFC7323_PAWS); 813 813 NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED); 814 - else if (tsecr_reject) 814 + } else if (tsecr_reject) { 815 + SKB_DR_SET(*drop_reason, TCP_RFC7323_TSECR); 815 816 NET_INC_STATS(sock_net(sk), LINUX_MIB_TSECRREJECTED); 817 + } else { 818 + SKB_DR_SET(*drop_reason, TCP_OVERWINDOW); 819 + } 816 820 return NULL; 817 821 } 818 822 ··· 887 881 return inet_csk_complete_hashdance(sk, child, req, own_req); 888 882 889 883 listen_overflow: 884 + SKB_DR_SET(*drop_reason, TCP_LISTEN_OVERFLOW); 890 885 if (sk != req->rsk_listener) 891 886 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMIGRATEREQFAILURE); 892 887
+1 -1
net/ipv4/tcp_offload.c
··· 425 425 426 426 inet_get_iif_sdif(skb, &iif, &sdif); 427 427 iph = skb_gro_network_header(skb); 428 - net = dev_net(skb->dev); 428 + net = dev_net_rcu(skb->dev); 429 429 sk = __inet_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, 430 430 iph->saddr, th->source, 431 431 iph->daddr, ntohs(th->dest),
+1 -1
net/ipv4/tcp_output.c
··· 949 949 tcp_rsk(req)->snt_tsval_first = opts->tsval; 950 950 } 951 951 WRITE_ONCE(tcp_rsk(req)->snt_tsval_last, opts->tsval); 952 - opts->tsecr = READ_ONCE(req->ts_recent); 952 + opts->tsecr = req->ts_recent; 953 953 remaining -= TCPOLEN_TSTAMP_ALIGNED; 954 954 } 955 955 if (likely(ireq->sack_ok)) {
+1 -1
net/ipv4/udp_offload.c
··· 630 630 __be16 dport) 631 631 { 632 632 const struct iphdr *iph = skb_gro_network_header(skb); 633 - struct net *net = dev_net(skb->dev); 633 + struct net *net = dev_net_rcu(skb->dev); 634 634 int iif, sdif; 635 635 636 636 inet_get_iif_sdif(skb, &iif, &sdif);
+14 -13
net/ipv6/tcp_ipv6.c
··· 376 376 { 377 377 const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data; 378 378 const struct tcphdr *th = (struct tcphdr *)(skb->data+offset); 379 - struct net *net = dev_net(skb->dev); 379 + struct net *net = dev_net_rcu(skb->dev); 380 380 struct request_sock *fastopen; 381 381 struct ipv6_pinfo *np; 382 382 struct tcp_sock *tp; ··· 866 866 int oif, int rst, u8 tclass, __be32 label, 867 867 u32 priority, u32 txhash, struct tcp_key *key) 868 868 { 869 - const struct tcphdr *th = tcp_hdr(skb); 870 - struct tcphdr *t1; 871 - struct sk_buff *buff; 872 - struct flowi6 fl6; 873 - struct net *net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev); 874 - struct sock *ctl_sk = net->ipv6.tcp_sk; 869 + struct net *net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); 875 870 unsigned int tot_len = sizeof(struct tcphdr); 871 + struct sock *ctl_sk = net->ipv6.tcp_sk; 872 + const struct tcphdr *th = tcp_hdr(skb); 876 873 __be32 mrst = 0, *topt; 877 874 struct dst_entry *dst; 878 - __u32 mark = 0; 875 + struct sk_buff *buff; 876 + struct tcphdr *t1; 877 + struct flowi6 fl6; 878 + u32 mark = 0; 879 879 880 880 if (tsecr) 881 881 tot_len += TCPOLEN_TSTAMP_ALIGNED; ··· 1041 1041 if (!sk && !ipv6_unicast_destination(skb)) 1042 1042 return; 1043 1043 1044 - net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev); 1044 + net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); 1045 1045 /* Invalid TCP option size or twice included auth */ 1046 1046 if (tcp_parse_auth_options(th, &md5_hash_location, &aoh)) 1047 1047 return; ··· 1279 1279 tcp_rsk(req)->rcv_nxt, 1280 1280 tcp_synack_window(req) >> inet_rsk(req)->rcv_wscale, 1281 1281 tcp_rsk_tsval(tcp_rsk(req)), 1282 - READ_ONCE(req->ts_recent), sk->sk_bound_dev_if, 1282 + req->ts_recent, sk->sk_bound_dev_if, 1283 1283 &key, ipv6_get_dsfield(ipv6_hdr(skb)), 0, 1284 1284 READ_ONCE(sk->sk_priority), 1285 1285 READ_ONCE(tcp_rsk(req)->txhash)); ··· 1740 1740 1741 1741 INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) 1742 1742 { 1743 + struct net *net = dev_net_rcu(skb->dev); 1743 1744 enum skb_drop_reason drop_reason; 1744 1745 int sdif = inet6_sdif(skb); 1745 1746 int dif = inet6_iif(skb); ··· 1750 1749 bool refcounted; 1751 1750 int ret; 1752 1751 u32 isn; 1753 - struct net *net = dev_net(skb->dev); 1754 1752 1755 1753 drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; 1756 1754 if (skb->pkt_type != PACKET_HOST) ··· 1828 1828 th = (const struct tcphdr *)skb->data; 1829 1829 hdr = ipv6_hdr(skb); 1830 1830 tcp_v6_fill_cb(skb, hdr, th); 1831 - nsk = tcp_check_req(sk, skb, req, false, &req_stolen); 1831 + nsk = tcp_check_req(sk, skb, req, false, &req_stolen, 1832 + &drop_reason); 1832 1833 } else { 1833 1834 drop_reason = SKB_DROP_REASON_SOCKET_FILTER; 1834 1835 } ··· 2001 2000 2002 2001 void tcp_v6_early_demux(struct sk_buff *skb) 2003 2002 { 2004 - struct net *net = dev_net(skb->dev); 2003 + struct net *net = dev_net_rcu(skb->dev); 2005 2004 const struct ipv6hdr *hdr; 2006 2005 const struct tcphdr *th; 2007 2006 struct sock *sk;
+1 -1
net/ipv6/tcpv6_offload.c
··· 35 35 36 36 inet6_get_iif_sdif(skb, &iif, &sdif); 37 37 hdr = skb_gro_network_header(skb); 38 - net = dev_net(skb->dev); 38 + net = dev_net_rcu(skb->dev); 39 39 sk = __inet6_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, 40 40 &hdr->saddr, th->source, 41 41 &hdr->daddr, ntohs(th->dest),
+1 -1
net/ipv6/udp_offload.c
··· 117 117 __be16 dport) 118 118 { 119 119 const struct ipv6hdr *iph = skb_gro_network_header(skb); 120 - struct net *net = dev_net(skb->dev); 120 + struct net *net = dev_net_rcu(skb->dev); 121 121 int iif, sdif; 122 122 123 123 inet6_get_iif_sdif(skb, &iif, &sdif);