Skip to content

Commit

Permalink
ipv6: move tcp_ipv6_hash_secret and udp_ipv6_hash_secret to net_hotdata
Browse files Browse the repository at this point in the history
Use a 32bit hole in "struct net_offload" to store
the remaining 32bit secrets used by TCPv6 and UDPv6.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240306160031.874438-17-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Mar 8, 2024
1 parent 5af674b commit df51b84
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions include/net/hotdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ struct net_hotdata {
#define inet_ehash_secret net_hotdata.tcp_protocol.secret
#define udp_ehash_secret net_hotdata.udp_protocol.secret
#define inet6_ehash_secret net_hotdata.tcpv6_protocol.secret
#define tcp_ipv6_hash_secret net_hotdata.tcpv6_offload.secret
#define udp6_ehash_secret net_hotdata.udpv6_protocol.secret
#define udp_ipv6_hash_secret net_hotdata.udpv6_offload.secret

extern struct net_hotdata net_hotdata;

Expand Down
1 change: 1 addition & 0 deletions include/net/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct inet6_protocol {
struct net_offload {
struct offload_callbacks callbacks;
unsigned int flags; /* Flags used by IPv6 for now */
u32 secret;
};
/* This should be set for any extension header which is compatible with GSO. */
#define INET6_PROTO_GSO_EXTHDR 0x1
Expand Down
6 changes: 2 additions & 4 deletions net/ipv6/inet6_hashtables.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ u32 inet6_ehashfn(const struct net *net,
const struct in6_addr *laddr, const u16 lport,
const struct in6_addr *faddr, const __be16 fport)
{
static u32 ipv6_hash_secret __read_mostly;

u32 lhash, fhash;

net_get_random_once(&inet6_ehash_secret, sizeof(inet6_ehash_secret));
net_get_random_once(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
net_get_random_once(&tcp_ipv6_hash_secret, sizeof(tcp_ipv6_hash_secret));

lhash = (__force u32)laddr->s6_addr32[3];
fhash = __ipv6_addr_jhash(faddr, ipv6_hash_secret);
fhash = __ipv6_addr_jhash(faddr, tcp_ipv6_hash_secret);

return __inet6_ehashfn(lhash, lport, fhash, fport,
inet6_ehash_secret + net_hash_mix(net));
Expand Down
2 changes: 0 additions & 2 deletions net/ipv6/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ u32 udp6_ehashfn(const struct net *net,
const struct in6_addr *faddr,
const __be16 fport)
{
static u32 udp_ipv6_hash_secret __read_mostly;

u32 lhash, fhash;

net_get_random_once(&udp6_ehash_secret,
Expand Down

0 comments on commit df51b84

Please sign in to comment.