Skip to content

Commit 4ea0875

Browse files
edumazetkuba-moo
authored andcommitted
ipv6: move tcpv6_protocol and udpv6_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 6a55ca6 commit 4ea0875

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

include/net/hotdata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ struct net_hotdata {
1414
struct net_offload udpv4_offload;
1515
struct packet_offload ipv6_packet_offload;
1616
struct net_offload tcpv6_offload;
17+
#if IS_ENABLED(CONFIG_IPV6)
18+
struct inet6_protocol tcpv6_protocol;
19+
struct inet6_protocol udpv6_protocol;
20+
#endif
1721
struct net_offload udpv6_offload;
1822
#endif
1923
struct list_head offload_base;

net/ipv6/tcp_ipv6.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include <net/timewait_sock.h>
5959
#include <net/inet_common.h>
6060
#include <net/secure_seq.h>
61+
#include <net/hotdata.h>
6162
#include <net/busy_poll.h>
6263

6364
#include <linux/proc_fs.h>
@@ -2367,11 +2368,6 @@ struct proto tcpv6_prot = {
23672368
};
23682369
EXPORT_SYMBOL_GPL(tcpv6_prot);
23692370

2370-
static const struct inet6_protocol tcpv6_protocol = {
2371-
.handler = tcp_v6_rcv,
2372-
.err_handler = tcp_v6_err,
2373-
.flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
2374-
};
23752371

23762372
static struct inet_protosw tcpv6_protosw = {
23772373
.type = SOCK_STREAM,
@@ -2408,7 +2404,12 @@ int __init tcpv6_init(void)
24082404
{
24092405
int ret;
24102406

2411-
ret = inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP);
2407+
net_hotdata.tcpv6_protocol = (struct inet6_protocol) {
2408+
.handler = tcp_v6_rcv,
2409+
.err_handler = tcp_v6_err,
2410+
.flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
2411+
};
2412+
ret = inet6_add_protocol(&net_hotdata.tcpv6_protocol, IPPROTO_TCP);
24122413
if (ret)
24132414
goto out;
24142415

@@ -2433,13 +2434,13 @@ int __init tcpv6_init(void)
24332434
out_tcpv6_protosw:
24342435
inet6_unregister_protosw(&tcpv6_protosw);
24352436
out_tcpv6_protocol:
2436-
inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
2437+
inet6_del_protocol(&net_hotdata.tcpv6_protocol, IPPROTO_TCP);
24372438
goto out;
24382439
}
24392440

24402441
void tcpv6_exit(void)
24412442
{
24422443
unregister_pernet_subsys(&tcpv6_net_ops);
24432444
inet6_unregister_protosw(&tcpv6_protosw);
2444-
inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
2445+
inet6_del_protocol(&net_hotdata.tcpv6_protocol, IPPROTO_TCP);
24452446
}

net/ipv6/udp.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,11 +1702,6 @@ int udpv6_getsockopt(struct sock *sk, int level, int optname,
17021702
return ipv6_getsockopt(sk, level, optname, optval, optlen);
17031703
}
17041704

1705-
static const struct inet6_protocol udpv6_protocol = {
1706-
.handler = udpv6_rcv,
1707-
.err_handler = udpv6_err,
1708-
.flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
1709-
};
17101705

17111706
/* ------------------------------------------------------------------------ */
17121707
#ifdef CONFIG_PROC_FS
@@ -1803,7 +1798,12 @@ int __init udpv6_init(void)
18031798
{
18041799
int ret;
18051800

1806-
ret = inet6_add_protocol(&udpv6_protocol, IPPROTO_UDP);
1801+
net_hotdata.udpv6_protocol = (struct inet6_protocol) {
1802+
.handler = udpv6_rcv,
1803+
.err_handler = udpv6_err,
1804+
.flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
1805+
};
1806+
ret = inet6_add_protocol(&net_hotdata.udpv6_protocol, IPPROTO_UDP);
18071807
if (ret)
18081808
goto out;
18091809

@@ -1814,12 +1814,12 @@ int __init udpv6_init(void)
18141814
return ret;
18151815

18161816
out_udpv6_protocol:
1817-
inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
1817+
inet6_del_protocol(&net_hotdata.udpv6_protocol, IPPROTO_UDP);
18181818
goto out;
18191819
}
18201820

18211821
void udpv6_exit(void)
18221822
{
18231823
inet6_unregister_protosw(&udpv6_protosw);
1824-
inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
1824+
inet6_del_protocol(&net_hotdata.udpv6_protocol, IPPROTO_UDP);
18251825
}

0 commit comments

Comments
 (0)