Commit b66d6e8e authored by Eric Dumazet's avatar Eric Dumazet Committed by Kleber Sacilotto de Souza

netfilter: ipv6: nf_defrag: reduce struct net memory waste

BugLink: https://bugs.launchpad.net/bugs/1792377

[ Upstream commit 9ce7bc03 ]

It is a waste of memory to use a full "struct netns_sysctl_ipv6"
while only one pointer is really used, considering netns_sysctl_ipv6
keeps growing.

Also, since "struct netns_frags" has cache line alignment,
it is better to move the frags_hdr pointer outside, otherwise
we spend a full cache line for this pointer.

This saves 192 bytes of memory per netns.

Fixes: c038a767 ("ipv6: add a new namespace for nf_conntrack_reasm")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 074ee719
...@@ -115,6 +115,7 @@ struct net { ...@@ -115,6 +115,7 @@ struct net {
#endif #endif
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
struct netns_nf_frag nf_frag; struct netns_nf_frag nf_frag;
struct ctl_table_header *nf_frag_frags_hdr;
#endif #endif
struct sock *nfnl; struct sock *nfnl;
struct sock *nfnl_stash; struct sock *nfnl_stash;
......
...@@ -86,7 +86,6 @@ struct netns_ipv6 { ...@@ -86,7 +86,6 @@ struct netns_ipv6 {
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
struct netns_nf_frag { struct netns_nf_frag {
struct netns_sysctl_ipv6 sysctl;
struct netns_frags frags; struct netns_frags frags;
}; };
#endif #endif
......
...@@ -118,7 +118,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net) ...@@ -118,7 +118,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
if (hdr == NULL) if (hdr == NULL)
goto err_reg; goto err_reg;
net->nf_frag.sysctl.frags_hdr = hdr; net->nf_frag_frags_hdr = hdr;
return 0; return 0;
err_reg: err_reg:
...@@ -132,8 +132,8 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net) ...@@ -132,8 +132,8 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
{ {
struct ctl_table *table; struct ctl_table *table;
table = net->nf_frag.sysctl.frags_hdr->ctl_table_arg; table = net->nf_frag_frags_hdr->ctl_table_arg;
unregister_net_sysctl_table(net->nf_frag.sysctl.frags_hdr); unregister_net_sysctl_table(net->nf_frag_frags_hdr);
if (!net_eq(net, &init_net)) if (!net_eq(net, &init_net))
kfree(table); kfree(table);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment