Skip to content

Commit 9ce7bc0

Browse files
edumazetummakynes
authored andcommitted
netfilter: ipv6: nf_defrag: reduce struct net memory waste
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: c038a76 ("ipv6: add a new namespace for nf_conntrack_reasm") Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent ba062eb commit 9ce7bc0

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

include/net/net_namespace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct net {
128128
#endif
129129
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
130130
struct netns_nf_frag nf_frag;
131+
struct ctl_table_header *nf_frag_frags_hdr;
131132
#endif
132133
struct sock *nfnl;
133134
struct sock *nfnl_stash;

include/net/netns/ipv6.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ struct netns_ipv6 {
109109

110110
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
111111
struct netns_nf_frag {
112-
struct netns_sysctl_ipv6 sysctl;
113112
struct netns_frags frags;
114113
};
115114
#endif

net/ipv6/netfilter/nf_conntrack_reasm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
107107
if (hdr == NULL)
108108
goto err_reg;
109109

110-
net->nf_frag.sysctl.frags_hdr = hdr;
110+
net->nf_frag_frags_hdr = hdr;
111111
return 0;
112112

113113
err_reg:
@@ -121,8 +121,8 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
121121
{
122122
struct ctl_table *table;
123123

124-
table = net->nf_frag.sysctl.frags_hdr->ctl_table_arg;
125-
unregister_net_sysctl_table(net->nf_frag.sysctl.frags_hdr);
124+
table = net->nf_frag_frags_hdr->ctl_table_arg;
125+
unregister_net_sysctl_table(net->nf_frag_frags_hdr);
126126
if (!net_eq(net, &init_net))
127127
kfree(table);
128128
}

0 commit comments

Comments
 (0)