aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGao feng <gaofeng@cn.fujitsu.com>2012-06-21 00:36:47 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2012-06-27 13:13:31 -0400
commit22ac03772f2b7cedbd531f588f0b77a77d943585 (patch)
tree75cd298f4f5ec686565e3e7bfe1e1479c8ea5e69 /net
parentf42c4183c781733b1947ae79916849574d86aced (diff)
netfilter: nf_ct_generic: add generic_kmemdup_sysctl_table function
This patch is a cleanup. It adds generic_kmemdup_sysctl_table to split code into smaller chunks. Yet it prepares introduction of nf_conntrack_proto_*_sysctl.c. Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nf_conntrack_proto_generic.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
index d1ed7b44e079..7c11c5444194 100644
--- a/net/netfilter/nf_conntrack_proto_generic.c
+++ b/net/netfilter/nf_conntrack_proto_generic.c
@@ -135,34 +135,57 @@ static struct ctl_table generic_compat_sysctl_table[] = {
135#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */ 135#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
136#endif /* CONFIG_SYSCTL */ 136#endif /* CONFIG_SYSCTL */
137 137
138static int generic_init_net(struct net *net, u_int16_t proto) 138static int generic_kmemdup_sysctl_table(struct nf_proto_net *pn,
139 struct nf_generic_net *gn)
139{ 140{
140 struct nf_generic_net *gn = generic_pernet(net);
141 struct nf_proto_net *pn = (struct nf_proto_net *)gn;
142 gn->timeout = nf_ct_generic_timeout;
143#ifdef CONFIG_SYSCTL 141#ifdef CONFIG_SYSCTL
144 pn->ctl_table = kmemdup(generic_sysctl_table, 142 pn->ctl_table = kmemdup(generic_sysctl_table,
145 sizeof(generic_sysctl_table), 143 sizeof(generic_sysctl_table),
146 GFP_KERNEL); 144 GFP_KERNEL);
147 if (!pn->ctl_table) 145 if (!pn->ctl_table)
148 return -ENOMEM; 146 return -ENOMEM;
147
149 pn->ctl_table[0].data = &gn->timeout; 148 pn->ctl_table[0].data = &gn->timeout;
149#endif
150 return 0;
151}
150 152
153static int generic_kmemdup_compat_sysctl_table(struct nf_proto_net *pn,
154 struct nf_generic_net *gn)
155{
156#ifdef CONFIG_SYSCTL
151#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT 157#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
152 pn->ctl_compat_table = kmemdup(generic_compat_sysctl_table, 158 pn->ctl_compat_table = kmemdup(generic_compat_sysctl_table,
153 sizeof(generic_compat_sysctl_table), 159 sizeof(generic_compat_sysctl_table),
154 GFP_KERNEL); 160 GFP_KERNEL);
155 if (!pn->ctl_compat_table) { 161 if (!pn->ctl_compat_table)
156 kfree(pn->ctl_table);
157 pn->ctl_table = NULL;
158 return -ENOMEM; 162 return -ENOMEM;
159 } 163
160 pn->ctl_compat_table[0].data = &gn->timeout; 164 pn->ctl_compat_table[0].data = &gn->timeout;
161#endif 165#endif
162#endif 166#endif
163 return 0; 167 return 0;
164} 168}
165 169
170static int generic_init_net(struct net *net, u_int16_t proto)
171{
172 int ret;
173 struct nf_generic_net *gn = generic_pernet(net);
174 struct nf_proto_net *pn = &gn->pn;
175
176 gn->timeout = nf_ct_generic_timeout;
177
178 ret = generic_kmemdup_compat_sysctl_table(pn, gn);
179 if (ret < 0)
180 return ret;
181
182 ret = generic_kmemdup_sysctl_table(pn, gn);
183 if (ret < 0)
184 nf_ct_kfree_compat_sysctl_table(pn);
185
186 return ret;
187}
188
166struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly = 189struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly =
167{ 190{
168 .l3proto = PF_UNSPEC, 191 .l3proto = PF_UNSPEC,