diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-01-09 03:34:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:01:11 -0500 |
commit | b3fd3ffe39d830e7c24ef63b7f28703b485da2e3 (patch) | |
tree | 2fb8fc3ac2ffb79b481e1e3762da593910ebbe8c | |
parent | 3d7cc2ba628dcc6b55a2bafc7eaf35019fdcc201 (diff) |
[NETFILTER]: Use the ctl paths instead of hand-made analogue
The conntracks subsystem has a similar infrastructure
to maintain ctl_paths, but since we already have it
on the generic level, I think it's OK to switch to
using it.
So, basically, this patch just replaces the ctl_table-s
with ctl_path-s, nf_register_sysctl_table with
register_sysctl_paths() and removes no longer needed code.
After this the net/netfilter/nf_sysctl.c file contains
the paths only.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/netfilter.h | 8 | ||||
-rw-r--r-- | include/net/netfilter/nf_conntrack_l3proto.h | 2 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto.c | 7 | ||||
-rw-r--r-- | net/netfilter/nf_sysctl.c | 127 |
4 files changed, 16 insertions, 128 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index d190d560de61..c41f6438095d 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h | |||
@@ -120,12 +120,8 @@ void nf_unregister_sockopt(struct nf_sockopt_ops *reg); | |||
120 | 120 | ||
121 | #ifdef CONFIG_SYSCTL | 121 | #ifdef CONFIG_SYSCTL |
122 | /* Sysctl registration */ | 122 | /* Sysctl registration */ |
123 | struct ctl_table_header *nf_register_sysctl_table(struct ctl_table *path, | 123 | extern struct ctl_path nf_net_netfilter_sysctl_path[]; |
124 | struct ctl_table *table); | 124 | extern struct ctl_path nf_net_ipv4_netfilter_sysctl_path[]; |
125 | void nf_unregister_sysctl_table(struct ctl_table_header *header, | ||
126 | struct ctl_table *table); | ||
127 | extern struct ctl_table nf_net_netfilter_sysctl_path[]; | ||
128 | extern struct ctl_table nf_net_ipv4_netfilter_sysctl_path[]; | ||
129 | #endif /* CONFIG_SYSCTL */ | 125 | #endif /* CONFIG_SYSCTL */ |
130 | 126 | ||
131 | extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS]; | 127 | extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS]; |
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h index 15888fc7b72d..875c6d41eaab 100644 --- a/include/net/netfilter/nf_conntrack_l3proto.h +++ b/include/net/netfilter/nf_conntrack_l3proto.h | |||
@@ -73,7 +73,7 @@ struct nf_conntrack_l3proto | |||
73 | 73 | ||
74 | #ifdef CONFIG_SYSCTL | 74 | #ifdef CONFIG_SYSCTL |
75 | struct ctl_table_header *ctl_table_header; | 75 | struct ctl_table_header *ctl_table_header; |
76 | struct ctl_table *ctl_table_path; | 76 | struct ctl_path *ctl_table_path; |
77 | struct ctl_table *ctl_table; | 77 | struct ctl_table *ctl_table; |
78 | #endif /* CONFIG_SYSCTL */ | 78 | #endif /* CONFIG_SYSCTL */ |
79 | 79 | ||
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c index 6d947068c58f..8595b5946acf 100644 --- a/net/netfilter/nf_conntrack_proto.c +++ b/net/netfilter/nf_conntrack_proto.c | |||
@@ -36,11 +36,11 @@ static DEFINE_MUTEX(nf_ct_proto_mutex); | |||
36 | 36 | ||
37 | #ifdef CONFIG_SYSCTL | 37 | #ifdef CONFIG_SYSCTL |
38 | static int | 38 | static int |
39 | nf_ct_register_sysctl(struct ctl_table_header **header, struct ctl_table *path, | 39 | nf_ct_register_sysctl(struct ctl_table_header **header, struct ctl_path *path, |
40 | struct ctl_table *table, unsigned int *users) | 40 | struct ctl_table *table, unsigned int *users) |
41 | { | 41 | { |
42 | if (*header == NULL) { | 42 | if (*header == NULL) { |
43 | *header = nf_register_sysctl_table(path, table); | 43 | *header = register_sysctl_paths(path, table); |
44 | if (*header == NULL) | 44 | if (*header == NULL) |
45 | return -ENOMEM; | 45 | return -ENOMEM; |
46 | } | 46 | } |
@@ -55,7 +55,8 @@ nf_ct_unregister_sysctl(struct ctl_table_header **header, | |||
55 | { | 55 | { |
56 | if (users != NULL && --*users > 0) | 56 | if (users != NULL && --*users > 0) |
57 | return; | 57 | return; |
58 | nf_unregister_sysctl_table(*header, table); | 58 | |
59 | unregister_sysctl_table(*header); | ||
59 | *header = NULL; | 60 | *header = NULL; |
60 | } | 61 | } |
61 | #endif | 62 | #endif |
diff --git a/net/netfilter/nf_sysctl.c b/net/netfilter/nf_sysctl.c index ee34589e48a4..d9fcc893301d 100644 --- a/net/netfilter/nf_sysctl.c +++ b/net/netfilter/nf_sysctl.c | |||
@@ -7,128 +7,19 @@ | |||
7 | #include <linux/string.h> | 7 | #include <linux/string.h> |
8 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
9 | 9 | ||
10 | static void | ||
11 | path_free(struct ctl_table *path, struct ctl_table *table) | ||
12 | { | ||
13 | struct ctl_table *t, *next; | ||
14 | |||
15 | for (t = path; t != NULL && t != table; t = next) { | ||
16 | next = t->child; | ||
17 | kfree(t); | ||
18 | } | ||
19 | } | ||
20 | |||
21 | static struct ctl_table * | ||
22 | path_dup(struct ctl_table *path, struct ctl_table *table) | ||
23 | { | ||
24 | struct ctl_table *t, *last = NULL, *tmp; | ||
25 | |||
26 | for (t = path; t != NULL; t = t->child) { | ||
27 | /* twice the size since path elements are terminated by an | ||
28 | * empty element */ | ||
29 | tmp = kmemdup(t, 2 * sizeof(*t), GFP_KERNEL); | ||
30 | if (tmp == NULL) { | ||
31 | if (last != NULL) | ||
32 | path_free(path, table); | ||
33 | return NULL; | ||
34 | } | ||
35 | |||
36 | if (last != NULL) | ||
37 | last->child = tmp; | ||
38 | else | ||
39 | path = tmp; | ||
40 | last = tmp; | ||
41 | } | ||
42 | |||
43 | if (last != NULL) | ||
44 | last->child = table; | ||
45 | else | ||
46 | path = table; | ||
47 | |||
48 | return path; | ||
49 | } | ||
50 | |||
51 | struct ctl_table_header * | ||
52 | nf_register_sysctl_table(struct ctl_table *path, struct ctl_table *table) | ||
53 | { | ||
54 | struct ctl_table_header *header; | ||
55 | |||
56 | path = path_dup(path, table); | ||
57 | if (path == NULL) | ||
58 | return NULL; | ||
59 | header = register_sysctl_table(path); | ||
60 | if (header == NULL) | ||
61 | path_free(path, table); | ||
62 | return header; | ||
63 | } | ||
64 | EXPORT_SYMBOL_GPL(nf_register_sysctl_table); | ||
65 | |||
66 | void | ||
67 | nf_unregister_sysctl_table(struct ctl_table_header *header, | ||
68 | struct ctl_table *table) | ||
69 | { | ||
70 | struct ctl_table *path = header->ctl_table; | ||
71 | |||
72 | unregister_sysctl_table(header); | ||
73 | path_free(path, table); | ||
74 | } | ||
75 | EXPORT_SYMBOL_GPL(nf_unregister_sysctl_table); | ||
76 | |||
77 | /* net/netfilter */ | 10 | /* net/netfilter */ |
78 | static struct ctl_table nf_net_netfilter_table[] = { | 11 | struct ctl_path nf_net_netfilter_sysctl_path[] = { |
79 | { | 12 | { .procname = "net", .ctl_name = CTL_NET, }, |
80 | .ctl_name = NET_NETFILTER, | 13 | { .procname = "netfilter", .ctl_name = NET_NETFILTER, }, |
81 | .procname = "netfilter", | 14 | { } |
82 | .mode = 0555, | ||
83 | }, | ||
84 | { | ||
85 | .ctl_name = 0 | ||
86 | } | ||
87 | }; | ||
88 | struct ctl_table nf_net_netfilter_sysctl_path[] = { | ||
89 | { | ||
90 | .ctl_name = CTL_NET, | ||
91 | .procname = "net", | ||
92 | .mode = 0555, | ||
93 | .child = nf_net_netfilter_table, | ||
94 | }, | ||
95 | { | ||
96 | .ctl_name = 0 | ||
97 | } | ||
98 | }; | 15 | }; |
99 | EXPORT_SYMBOL_GPL(nf_net_netfilter_sysctl_path); | 16 | EXPORT_SYMBOL_GPL(nf_net_netfilter_sysctl_path); |
100 | 17 | ||
101 | /* net/ipv4/netfilter */ | 18 | /* net/ipv4/netfilter */ |
102 | static struct ctl_table nf_net_ipv4_netfilter_table[] = { | 19 | struct ctl_path nf_net_ipv4_netfilter_sysctl_path[] = { |
103 | { | 20 | { .procname = "net", .ctl_name = CTL_NET, }, |
104 | .ctl_name = NET_IPV4_NETFILTER, | 21 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, |
105 | .procname = "netfilter", | 22 | { .procname = "netfilter", .ctl_name = NET_IPV4_NETFILTER, }, |
106 | .mode = 0555, | 23 | { } |
107 | }, | ||
108 | { | ||
109 | .ctl_name = 0 | ||
110 | } | ||
111 | }; | ||
112 | static struct ctl_table nf_net_ipv4_table[] = { | ||
113 | { | ||
114 | .ctl_name = NET_IPV4, | ||
115 | .procname = "ipv4", | ||
116 | .mode = 0555, | ||
117 | .child = nf_net_ipv4_netfilter_table, | ||
118 | }, | ||
119 | { | ||
120 | .ctl_name = 0 | ||
121 | } | ||
122 | }; | ||
123 | struct ctl_table nf_net_ipv4_netfilter_sysctl_path[] = { | ||
124 | { | ||
125 | .ctl_name = CTL_NET, | ||
126 | .procname = "net", | ||
127 | .mode = 0555, | ||
128 | .child = nf_net_ipv4_table, | ||
129 | }, | ||
130 | { | ||
131 | .ctl_name = 0 | ||
132 | } | ||
133 | }; | 24 | }; |
134 | EXPORT_SYMBOL_GPL(nf_net_ipv4_netfilter_sysctl_path); | 25 | EXPORT_SYMBOL_GPL(nf_net_ipv4_netfilter_sysctl_path); |