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

ipv6: make ipv6_pinfo.daddr_cache a boolean

ipv6_pinfo.daddr_cache is either NULL or &sk->sk_v6_daddr

We do not need 8 bytes, a boolean is enough.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250916160951.541279-3-edumazet@google.com
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Eric Dumazet and committed by
Paolo Abeni
5489f333 3fbb2a6f

+10 -10
+1 -1
include/linux/ipv6.h
··· 219 219 #ifdef CONFIG_IPV6_SUBTREES 220 220 bool saddr_cache; 221 221 #endif 222 - const struct in6_addr *daddr_cache; 222 + bool daddr_cache; 223 223 224 224 __be32 flow_label; 225 225 __u32 frag_size;
+2 -2
include/net/ip6_route.h
··· 229 229 * Store a destination cache entry in a socket 230 230 */ 231 231 static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst, 232 - const struct in6_addr *daddr, 232 + bool daddr_set, 233 233 bool saddr_set) 234 234 { 235 235 struct ipv6_pinfo *np = inet6_sk(sk); 236 236 237 237 np->dst_cookie = rt6_get_cookie(dst_rt6_info(dst)); 238 238 sk_setup_caps(sk, dst); 239 - np->daddr_cache = daddr; 239 + np->daddr_cache = daddr_set; 240 240 #ifdef CONFIG_IPV6_SUBTREES 241 241 np->saddr_cache = saddr_set; 242 242 #endif
+1 -1
net/ipv6/af_inet6.c
··· 857 857 return PTR_ERR(dst); 858 858 } 859 859 860 - ip6_dst_store(sk, dst, NULL, false); 860 + ip6_dst_store(sk, dst, false, false); 861 861 } 862 862 863 863 return 0;
+1 -1
net/ipv6/inet6_connection_sock.c
··· 91 91 dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p); 92 92 93 93 if (!IS_ERR(dst)) 94 - ip6_dst_store(sk, dst, NULL, false); 94 + ip6_dst_store(sk, dst, false, false); 95 95 } 96 96 return dst; 97 97 }
+2 -1
net/ipv6/ip6_output.c
··· 1100 1100 * sockets. 1101 1101 * 2. oif also should be the same. 1102 1102 */ 1103 - if (ip6_rt_check(&rt->rt6i_dst, &fl6->daddr, np->daddr_cache) || 1103 + if (ip6_rt_check(&rt->rt6i_dst, &fl6->daddr, 1104 + np->daddr_cache ? &sk->sk_v6_daddr : NULL) || 1104 1105 #ifdef CONFIG_IPV6_SUBTREES 1105 1106 ip6_rt_check(&rt->rt6i_src, &fl6->saddr, 1106 1107 np->saddr_cache ? &np->saddr : NULL) ||
+1 -2
net/ipv6/route.c
··· 3032 3032 #endif 3033 3033 3034 3034 ip6_dst_store(sk, dst, 3035 - ipv6_addr_equal(&fl6->daddr, &sk->sk_v6_daddr) ? 3036 - &sk->sk_v6_daddr : NULL, 3035 + ipv6_addr_equal(&fl6->daddr, &sk->sk_v6_daddr), 3037 3036 #ifdef CONFIG_IPV6_SUBTREES 3038 3037 ipv6_addr_equal(&fl6->saddr, &np->saddr) ? 3039 3038 true :
+2 -2
net/ipv6/tcp_ipv6.c
··· 299 299 inet->inet_rcv_saddr = LOOPBACK4_IPV6; 300 300 301 301 sk->sk_gso_type = SKB_GSO_TCPV6; 302 - ip6_dst_store(sk, dst, NULL, false); 302 + ip6_dst_store(sk, dst, false, false); 303 303 304 304 icsk->icsk_ext_hdr_len = 0; 305 305 if (opt) ··· 1459 1459 1460 1460 memcpy(newnp, np, sizeof(struct ipv6_pinfo)); 1461 1461 1462 - ip6_dst_store(newsk, dst, NULL, false); 1462 + ip6_dst_store(newsk, dst, false, false); 1463 1463 1464 1464 newnp->saddr = ireq->ir_v6_loc_addr; 1465 1465