12 #include <linux/types.h>
13 #include <linux/netfilter.h>
14 #include <linux/module.h>
15 #include <linux/slab.h>
18 #include <linux/stddef.h>
22 #include <linux/kernel.h>
23 #include <linux/netdevice.h>
38 nf_ct_register_sysctl(
struct net *
net,
43 if (*header ==
NULL) {
85 p = __nf_ct_l3proto_find(l3proto);
86 if (!try_module_get(p->
me))
108 ret = request_module(
"nf_conntrack-%d", l3proto);
127 p = __nf_ct_l3proto_find(l3proto);
140 if (!try_module_get(p->
me))
163 return nf_ct_protonum(i) == l4proto->
l4proto &&
164 nf_ct_l3num(i) == l4proto->
l3proto;
167 static struct nf_ip_net *nf_ct_l3proto_net(
struct net *net,
171 return &net->ct.nf_ct_proto;
176 static int nf_ct_l3proto_register_sysctl(
struct net *net,
180 struct nf_ip_net *
in = nf_ct_l3proto_net(net, l3proto);
185 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
186 if (in->ctl_table !=
NULL) {
187 err = nf_ct_register_sysctl(net,
188 &in->ctl_table_header,
189 l3proto->ctl_table_path,
192 kfree(in->ctl_table);
193 in->ctl_table =
NULL;
200 static void nf_ct_l3proto_unregister_sysctl(
struct net *net,
203 struct nf_ip_net *in = nf_ct_l3proto_net(net, l3proto);
207 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
208 if (in->ctl_table_header !=
NULL)
209 nf_ct_unregister_sysctl(&in->ctl_table_header,
229 lockdep_is_held(&nf_ct_proto_mutex));
230 if (old != &nf_conntrack_l3proto_generic) {
257 ret = nf_ct_l3proto_register_sysctl(net, proto);
262 ret = nf_conntrack_l3proto_register_net(proto);
264 nf_ct_l3proto_unregister_sysctl(net, proto);
278 lockdep_is_held(&nf_ct_proto_mutex)
281 &nf_conntrack_l3proto_generic);
291 nf_conntrack_l3proto_unregister_net(proto);
293 nf_ct_l3proto_unregister_sysctl(net, proto);
300 static struct nf_proto_net *nf_ct_l4proto_net(
struct net *net,
306 }
else if (l4proto->
net_id) {
314 int nf_ct_l4proto_register_sysctl(
struct net *net,
321 if (pn->ctl_table !=
NULL) {
322 err = nf_ct_register_sysctl(net,
323 &pn->ctl_table_header,
328 kfree(pn->ctl_table);
329 pn->ctl_table =
NULL;
333 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
336 nf_ct_kfree_compat_sysctl_table(pn);
339 err = nf_ct_register_sysctl(net,
340 &pn->ctl_compat_header,
341 "net/ipv4/netfilter",
342 pn->ctl_compat_table);
346 nf_ct_kfree_compat_sysctl_table(pn);
347 nf_ct_unregister_sysctl(&pn->ctl_table_header,
358 void nf_ct_l4proto_unregister_sysctl(
struct net *net,
363 if (pn->ctl_table_header !=
NULL)
364 nf_ct_unregister_sysctl(&pn->ctl_table_header,
368 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
370 nf_ct_unregister_sysctl(&pn->ctl_compat_header,
371 &pn->ctl_compat_table,
392 if (!nf_ct_protos[l4proto->
l3proto]) {
400 if (proto_array ==
NULL) {
413 nf_ct_protos[l4proto->
l3proto] = proto_array;
416 lockdep_is_held(&nf_ct_proto_mutex)
417 ) != &nf_conntrack_l4proto_generic) {
447 pn = nf_ct_l4proto_net(net, l4proto);
451 ret = nf_ct_l4proto_register_sysctl(net, pn, l4proto);
456 ret = nf_conntrack_l4proto_register_net(l4proto);
458 nf_ct_l4proto_unregister_sysctl(net, pn, l4proto);
477 lockdep_is_held(&nf_ct_proto_mutex)
480 &nf_conntrack_l4proto_generic);
492 nf_conntrack_l4proto_unregister_net(l4proto);
494 pn = nf_ct_l4proto_net(net, l4proto);
499 nf_ct_l4proto_unregister_sysctl(net, pn, l4proto);
517 err = nf_ct_l4proto_register_sysctl(net,
524 for (i = 0; i <
AF_MAX; i++)
540 nf_ct_l4proto_unregister_sysctl(net,
545 for (i = 0; i <
PF_MAX; i++)
546 kfree(nf_ct_protos[i]);