Skip to content

Commit 6e07357

Browse files
edumazetkuba-moo
authored andcommitted
inet: move inet_ehash_secret and udp_ehash_secret into net_hotdata
"struct net_protocol" has a 32bit hole in 32bit arches. Use it to store the 32bit secret used by UDP and TCP, to increase cache locality in rx path. Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Soheil Hassas Yeganeh <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 571bf02 commit 6e07357

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

include/net/hotdata.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ struct net_hotdata {
3636
int dev_rx_weight;
3737
};
3838

39+
#define inet_ehash_secret net_hotdata.tcp_protocol.secret
40+
#define udp_ehash_secret net_hotdata.udp_protocol.secret
41+
3942
extern struct net_hotdata net_hotdata;
4043

4144
#endif /* _NET_HOTDATA_H */

include/net/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct net_protocol {
4646
* socket lookup?
4747
*/
4848
icmp_strict_tag_validation:1;
49+
u32 secret;
4950
};
5051

5152
#if IS_ENABLED(CONFIG_IPV6)

net/ipv4/inet_hashtables.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <net/inet6_hashtables.h>
2525
#endif
2626
#include <net/secure_seq.h>
27+
#include <net/hotdata.h>
2728
#include <net/ip.h>
2829
#include <net/tcp.h>
2930
#include <net/sock_reuseport.h>
@@ -32,8 +33,6 @@ u32 inet_ehashfn(const struct net *net, const __be32 laddr,
3233
const __u16 lport, const __be32 faddr,
3334
const __be16 fport)
3435
{
35-
static u32 inet_ehash_secret __read_mostly;
36-
3736
net_get_random_once(&inet_ehash_secret, sizeof(inet_ehash_secret));
3837

3938
return __inet_ehashfn(laddr, lport, faddr, fport,

net/ipv4/udp.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ INDIRECT_CALLABLE_SCOPE
411411
u32 udp_ehashfn(const struct net *net, const __be32 laddr, const __u16 lport,
412412
const __be32 faddr, const __be16 fport)
413413
{
414-
static u32 udp_ehash_secret __read_mostly;
415-
416414
net_get_random_once(&udp_ehash_secret, sizeof(udp_ehash_secret));
417415

418416
return __inet_ehashfn(laddr, lport, faddr, fport,

0 commit comments

Comments
 (0)