1 /* nf_sysctl.c netfilter sysctl registration/unregistation
3 * Copyright (c) 2006 Patrick McHardy <kaber@trash.net>
5 #include <linux/module.h>
6 #include <linux/sysctl.h>
7 #include <linux/string.h>
8 #include <linux/slab.h>
11 path_free(struct ctl_table
*path
, struct ctl_table
*table
)
13 struct ctl_table
*t
, *next
;
15 for (t
= path
; t
!= NULL
&& t
!= table
; t
= next
) {
21 static struct ctl_table
*
22 path_dup(struct ctl_table
*path
, struct ctl_table
*table
)
24 struct ctl_table
*t
, *last
= NULL
, *tmp
;
26 for (t
= path
; t
!= NULL
; t
= t
->child
) {
27 /* twice the size since path elements are terminated by an
29 tmp
= kmemdup(t
, 2 * sizeof(*t
), GFP_KERNEL
);
32 path_free(path
, table
);
51 struct ctl_table_header
*
52 nf_register_sysctl_table(struct ctl_table
*path
, struct ctl_table
*table
)
54 struct ctl_table_header
*header
;
56 path
= path_dup(path
, table
);
59 header
= register_sysctl_table(path
);
61 path_free(path
, table
);
64 EXPORT_SYMBOL_GPL(nf_register_sysctl_table
);
67 nf_unregister_sysctl_table(struct ctl_table_header
*header
,
68 struct ctl_table
*table
)
70 struct ctl_table
*path
= header
->ctl_table
;
72 unregister_sysctl_table(header
);
73 path_free(path
, table
);
75 EXPORT_SYMBOL_GPL(nf_unregister_sysctl_table
);
78 static struct ctl_table nf_net_netfilter_table
[] = {
80 .ctl_name
= NET_NETFILTER
,
81 .procname
= "netfilter",
88 struct ctl_table nf_net_netfilter_sysctl_path
[] = {
93 .child
= nf_net_netfilter_table
,
99 EXPORT_SYMBOL_GPL(nf_net_netfilter_sysctl_path
);
101 /* net/ipv4/netfilter */
102 static struct ctl_table nf_net_ipv4_netfilter_table
[] = {
104 .ctl_name
= NET_IPV4_NETFILTER
,
105 .procname
= "netfilter",
112 static struct ctl_table nf_net_ipv4_table
[] = {
114 .ctl_name
= NET_IPV4
,
117 .child
= nf_net_ipv4_netfilter_table
,
123 struct ctl_table nf_net_ipv4_netfilter_sysctl_path
[] = {
128 .child
= nf_net_ipv4_table
,
134 EXPORT_SYMBOL_GPL(nf_net_ipv4_netfilter_sysctl_path
);