Skip to content

Commit 571bf02

Browse files
edumazetkuba-moo
authored andcommitted
inet: move tcp_protocol and udp_protocol to net_hotdata
These structures are read in rx path, move them to net_hotdata for better cache locality. 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 4ea0875 commit 571bf02

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

include/net/hotdata.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ struct net_hotdata {
1111
#if IS_ENABLED(CONFIG_INET)
1212
struct packet_offload ip_packet_offload;
1313
struct net_offload tcpv4_offload;
14+
struct net_protocol tcp_protocol;
1415
struct net_offload udpv4_offload;
16+
struct net_protocol udp_protocol;
1517
struct packet_offload ipv6_packet_offload;
1618
struct net_offload tcpv6_offload;
1719
#if IS_ENABLED(CONFIG_IPV6)

net/ipv4/af_inet.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,19 +1751,6 @@ static const struct net_protocol igmp_protocol = {
17511751
};
17521752
#endif
17531753

1754-
static const struct net_protocol tcp_protocol = {
1755-
.handler = tcp_v4_rcv,
1756-
.err_handler = tcp_v4_err,
1757-
.no_policy = 1,
1758-
.icmp_strict_tag_validation = 1,
1759-
};
1760-
1761-
static const struct net_protocol udp_protocol = {
1762-
.handler = udp_rcv,
1763-
.err_handler = udp_err,
1764-
.no_policy = 1,
1765-
};
1766-
17671754
static const struct net_protocol icmp_protocol = {
17681755
.handler = icmp_rcv,
17691756
.err_handler = icmp_err,
@@ -1992,9 +1979,22 @@ static int __init inet_init(void)
19921979

19931980
if (inet_add_protocol(&icmp_protocol, IPPROTO_ICMP) < 0)
19941981
pr_crit("%s: Cannot add ICMP protocol\n", __func__);
1995-
if (inet_add_protocol(&udp_protocol, IPPROTO_UDP) < 0)
1982+
1983+
net_hotdata.udp_protocol = (struct net_protocol) {
1984+
.handler = udp_rcv,
1985+
.err_handler = udp_err,
1986+
.no_policy = 1,
1987+
};
1988+
if (inet_add_protocol(&net_hotdata.udp_protocol, IPPROTO_UDP) < 0)
19961989
pr_crit("%s: Cannot add UDP protocol\n", __func__);
1997-
if (inet_add_protocol(&tcp_protocol, IPPROTO_TCP) < 0)
1990+
1991+
net_hotdata.tcp_protocol = (struct net_protocol) {
1992+
.handler = tcp_v4_rcv,
1993+
.err_handler = tcp_v4_err,
1994+
.no_policy = 1,
1995+
.icmp_strict_tag_validation = 1,
1996+
};
1997+
if (inet_add_protocol(&net_hotdata.tcp_protocol, IPPROTO_TCP) < 0)
19981998
pr_crit("%s: Cannot add TCP protocol\n", __func__);
19991999
#ifdef CONFIG_IP_MULTICAST
20002000
if (inet_add_protocol(&igmp_protocol, IPPROTO_IGMP) < 0)

0 commit comments

Comments
 (0)