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

ipv6: make ipv6_pinfo.saddr_cache a boolean

ipv6_pinfo.saddr_cache is either NULL or &np->saddr.

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-2-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
3fbb2a6f b127e355

+12 -11
+2 -2
include/linux/ipv6.h
··· 216 216 struct ipv6_pinfo { 217 217 struct in6_addr saddr; 218 218 struct in6_pktinfo sticky_pktinfo; 219 - const struct in6_addr *daddr_cache; 220 219 #ifdef CONFIG_IPV6_SUBTREES 221 - const struct in6_addr *saddr_cache; 220 + bool saddr_cache; 222 221 #endif 222 + const struct in6_addr *daddr_cache; 223 223 224 224 __be32 flow_label; 225 225 __u32 frag_size;
+2 -2
include/net/ip6_route.h
··· 230 230 */ 231 231 static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst, 232 232 const struct in6_addr *daddr, 233 - const struct in6_addr *saddr) 233 + bool saddr_set) 234 234 { 235 235 struct ipv6_pinfo *np = inet6_sk(sk); 236 236 ··· 238 238 sk_setup_caps(sk, dst); 239 239 np->daddr_cache = daddr; 240 240 #ifdef CONFIG_IPV6_SUBTREES 241 - np->saddr_cache = saddr; 241 + np->saddr_cache = saddr_set; 242 242 #endif 243 243 } 244 244
+1 -1
net/ipv6/af_inet6.c
··· 857 857 return PTR_ERR(dst); 858 858 } 859 859 860 - ip6_dst_store(sk, dst, NULL, NULL); 860 + ip6_dst_store(sk, dst, NULL, 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, NULL); 94 + ip6_dst_store(sk, dst, NULL, false); 95 95 } 96 96 return dst; 97 97 }
+2 -1
net/ipv6/ip6_output.c
··· 1102 1102 */ 1103 1103 if (ip6_rt_check(&rt->rt6i_dst, &fl6->daddr, np->daddr_cache) || 1104 1104 #ifdef CONFIG_IPV6_SUBTREES 1105 - ip6_rt_check(&rt->rt6i_src, &fl6->saddr, np->saddr_cache) || 1105 + ip6_rt_check(&rt->rt6i_src, &fl6->saddr, 1106 + np->saddr_cache ? &np->saddr : NULL) || 1106 1107 #endif 1107 1108 (fl6->flowi6_oif && fl6->flowi6_oif != dst_dev(dst)->ifindex)) { 1108 1109 dst_release(dst);
+2 -2
net/ipv6/route.c
··· 3036 3036 &sk->sk_v6_daddr : NULL, 3037 3037 #ifdef CONFIG_IPV6_SUBTREES 3038 3038 ipv6_addr_equal(&fl6->saddr, &np->saddr) ? 3039 - &np->saddr : 3039 + true : 3040 3040 #endif 3041 - NULL); 3041 + false); 3042 3042 } 3043 3043 3044 3044 static bool ip6_redirect_nh_match(const struct fib6_result *res,
+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, NULL); 302 + ip6_dst_store(sk, dst, NULL, 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, NULL); 1462 + ip6_dst_store(newsk, dst, NULL, false); 1463 1463 1464 1464 newnp->saddr = ireq->ir_v6_loc_addr; 1465 1465