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: populate inet->cork.fl.u.ip6 in tcp_v6_syn_recv_sock()

As explained in commit 85d05e281712 ("ipv6: change inet6_sk_rebuild_header()
to use inet->cork.fl.u.ip6"):

TCP v6 spends a good amount of time rebuilding a fresh fl6 at each
transmit in inet6_csk_xmit()/inet6_csk_route_socket().

TCP v4 caches the information in inet->cork.fl.u.ip4 instead.

After this patch, passive TCP ipv6 flows have correctly initialized
inet->cork.fl.u.ip6 structure.

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

authored by

Eric Dumazet and committed by
Jakub Kicinski
a6eee39c 19bdb267

+17 -15
+3 -1
include/net/inet6_connection_sock.h
··· 18 18 struct sock; 19 19 struct sockaddr; 20 20 21 - struct dst_entry *inet6_csk_route_req(const struct sock *sk, struct flowi6 *fl6, 21 + struct dst_entry *inet6_csk_route_req(const struct sock *sk, 22 + struct dst_entry *dst, 23 + struct flowi6 *fl6, 22 24 const struct request_sock *req, u8 proto); 23 25 24 26 int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
+6 -5
net/ipv6/inet6_connection_sock.c
··· 25 25 #include <net/sock_reuseport.h> 26 26 27 27 struct dst_entry *inet6_csk_route_req(const struct sock *sk, 28 + struct dst_entry *dst, 28 29 struct flowi6 *fl6, 29 30 const struct request_sock *req, 30 31 u8 proto) ··· 33 32 const struct inet_request_sock *ireq = inet_rsk(req); 34 33 const struct ipv6_pinfo *np = inet6_sk(sk); 35 34 struct in6_addr *final_p, final; 36 - struct dst_entry *dst; 37 35 38 36 memset(fl6, 0, sizeof(*fl6)); 39 37 fl6->flowi6_proto = proto; ··· 48 48 fl6->flowi6_uid = sk_uid(sk); 49 49 security_req_classify_flow(req, flowi6_to_flowi_common(fl6)); 50 50 51 - dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p); 52 - if (IS_ERR(dst)) 53 - return NULL; 54 - 51 + if (!dst) { 52 + dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p); 53 + if (IS_ERR(dst)) 54 + return NULL; 55 + } 55 56 return dst; 56 57 } 57 58
+8 -9
net/ipv6/tcp_ipv6.c
··· 539 539 u8 tclass; 540 540 541 541 /* First, grab a route. */ 542 - if (!dst && (dst = inet6_csk_route_req(sk, fl6, req, 542 + if (!dst && (dst = inet6_csk_route_req(sk, NULL, fl6, req, 543 543 IPPROTO_TCP)) == NULL) 544 544 goto done; 545 545 ··· 789 789 if (security_inet_conn_request(sk, skb, req)) 790 790 return NULL; 791 791 792 - return inet6_csk_route_req(sk, &fl->u.ip6, req, IPPROTO_TCP); 792 + return inet6_csk_route_req(sk, NULL, &fl->u.ip6, req, IPPROTO_TCP); 793 793 } 794 794 795 795 struct request_sock_ops tcp6_request_sock_ops __read_mostly = { ··· 1318 1318 struct request_sock *req_unhash, 1319 1319 bool *own_req) 1320 1320 { 1321 - struct inet_request_sock *ireq; 1322 - struct ipv6_pinfo *newnp; 1323 1321 const struct ipv6_pinfo *np = tcp_inet6_sk(sk); 1322 + struct inet_request_sock *ireq; 1324 1323 struct ipv6_txoptions *opt; 1325 1324 struct inet_sock *newinet; 1326 1325 bool found_dup_sk = false; 1326 + struct ipv6_pinfo *newnp; 1327 1327 struct tcp_sock *newtp; 1328 1328 struct sock *newsk; 1329 1329 #ifdef CONFIG_TCP_MD5SIG ··· 1392 1392 if (sk_acceptq_is_full(sk)) 1393 1393 goto exit_overflow; 1394 1394 1395 - if (!dst) { 1396 - dst = inet6_csk_route_req(sk, &fl6, req, IPPROTO_TCP); 1397 - if (!dst) 1398 - goto exit; 1399 - } 1395 + dst = inet6_csk_route_req(sk, dst, &fl6, req, IPPROTO_TCP); 1396 + if (!dst) 1397 + goto exit; 1400 1398 1401 1399 newsk = tcp_create_openreq_child(sk, req, skb); 1402 1400 if (!newsk) ··· 1410 1412 inet6_sk_rx_dst_set(newsk, skb); 1411 1413 1412 1414 newinet = inet_sk(newsk); 1415 + newinet->cork.fl.u.ip6 = fl6; 1413 1416 newinet->pinet6 = tcp_inet6_sk(newsk); 1414 1417 newinet->ipv6_fl_list = NULL; 1415 1418 newinet->inet_opt = NULL;