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.

tcp: inet6_csk_xmit() optimization

After prior patches, inet6_csk_xmit() can reuse inet->cork.fl.u.ip6
if __sk_dst_check() returns a valid dst.

Otherwise call inet6_csk_route_socket() to refresh inet->cork.fl.u.ip6
content and get a new dst.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260206173426.1638518-8-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
97d7ae6e a6eee39c

+15 -15
+15 -15
net/ipv6/inet6_connection_sock.c
··· 81 81 final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &np->final); 82 82 rcu_read_unlock(); 83 83 84 - dst = __sk_dst_check(sk, np->dst_cookie); 85 - if (!dst) { 86 - dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p); 84 + dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p); 87 85 88 - if (!IS_ERR(dst)) 89 - ip6_dst_store(sk, dst, false, false); 90 - } 86 + if (!IS_ERR(dst)) 87 + ip6_dst_store(sk, dst, false, false); 88 + 91 89 return dst; 92 90 } 93 91 ··· 96 98 struct dst_entry *dst; 97 99 int res; 98 100 99 - dst = inet6_csk_route_socket(sk, fl6); 100 - if (IS_ERR(dst)) { 101 - WRITE_ONCE(sk->sk_err_soft, -PTR_ERR(dst)); 102 - sk->sk_route_caps = 0; 103 - kfree_skb(skb); 104 - return PTR_ERR(dst); 101 + dst = __sk_dst_check(sk, np->dst_cookie); 102 + if (unlikely(!dst)) { 103 + dst = inet6_csk_route_socket(sk, fl6); 104 + if (IS_ERR(dst)) { 105 + WRITE_ONCE(sk->sk_err_soft, -PTR_ERR(dst)); 106 + sk->sk_route_caps = 0; 107 + kfree_skb(skb); 108 + return PTR_ERR(dst); 109 + } 110 + /* Restore final destination back after routing done */ 111 + fl6->daddr = sk->sk_v6_daddr; 105 112 } 106 113 107 114 rcu_read_lock(); 108 115 skb_dst_set_noref(skb, dst); 109 - 110 - /* Restore final destination back after routing done */ 111 - fl6->daddr = sk->sk_v6_daddr; 112 116 113 117 res = ip6_xmit(sk, skb, fl6, sk->sk_mark, rcu_dereference(np->opt), 114 118 np->tclass, READ_ONCE(sk->sk_priority));