diff options
author | Patrick McHardy <kaber@trash.net> | 2006-08-22 03:33:45 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 17:55:31 -0400 |
commit | 52d9c42ef2563d2c420eb23b96bf5a4cae9e167b (patch) | |
tree | 003022136c43ea48a2d5dcde5c06c261b1705e86 | |
parent | 90528e6fe92ee1a353d6a639930e7d70d85b5c85 (diff) |
[NETFILTER]: x_tables: add helpers for mass match/target registration
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/netfilter/x_tables.h | 5 | ||||
-rw-r--r-- | net/netfilter/x_tables.c | 60 |
2 files changed, 65 insertions, 0 deletions
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 48cc32d83f77..9a9912430e3a 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h | |||
@@ -290,8 +290,13 @@ struct xt_table_info | |||
290 | 290 | ||
291 | extern int xt_register_target(struct xt_target *target); | 291 | extern int xt_register_target(struct xt_target *target); |
292 | extern void xt_unregister_target(struct xt_target *target); | 292 | extern void xt_unregister_target(struct xt_target *target); |
293 | extern int xt_register_targets(struct xt_target *target, unsigned int n); | ||
294 | extern void xt_unregister_targets(struct xt_target *target, unsigned int n); | ||
295 | |||
293 | extern int xt_register_match(struct xt_match *target); | 296 | extern int xt_register_match(struct xt_match *target); |
294 | extern void xt_unregister_match(struct xt_match *target); | 297 | extern void xt_unregister_match(struct xt_match *target); |
298 | extern int xt_register_matches(struct xt_match *match, unsigned int n); | ||
299 | extern void xt_unregister_matches(struct xt_match *match, unsigned int n); | ||
295 | 300 | ||
296 | extern int xt_check_match(const struct xt_match *match, unsigned short family, | 301 | extern int xt_check_match(const struct xt_match *match, unsigned short family, |
297 | unsigned int size, const char *table, unsigned int hook, | 302 | unsigned int size, const char *table, unsigned int hook, |
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 174e8f970095..8037ba63d587 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -87,6 +87,36 @@ xt_unregister_target(struct xt_target *target) | |||
87 | EXPORT_SYMBOL(xt_unregister_target); | 87 | EXPORT_SYMBOL(xt_unregister_target); |
88 | 88 | ||
89 | int | 89 | int |
90 | xt_register_targets(struct xt_target *target, unsigned int n) | ||
91 | { | ||
92 | unsigned int i; | ||
93 | int err = 0; | ||
94 | |||
95 | for (i = 0; i < n; i++) { | ||
96 | err = xt_register_target(&target[i]); | ||
97 | if (err) | ||
98 | goto err; | ||
99 | } | ||
100 | return err; | ||
101 | |||
102 | err: | ||
103 | if (i > 0) | ||
104 | xt_unregister_targets(target, i); | ||
105 | return err; | ||
106 | } | ||
107 | EXPORT_SYMBOL(xt_register_targets); | ||
108 | |||
109 | void | ||
110 | xt_unregister_targets(struct xt_target *target, unsigned int n) | ||
111 | { | ||
112 | unsigned int i; | ||
113 | |||
114 | for (i = 0; i < n; i++) | ||
115 | xt_unregister_target(&target[i]); | ||
116 | } | ||
117 | EXPORT_SYMBOL(xt_unregister_targets); | ||
118 | |||
119 | int | ||
90 | xt_register_match(struct xt_match *match) | 120 | xt_register_match(struct xt_match *match) |
91 | { | 121 | { |
92 | int ret, af = match->family; | 122 | int ret, af = match->family; |
@@ -113,6 +143,36 @@ xt_unregister_match(struct xt_match *match) | |||
113 | } | 143 | } |
114 | EXPORT_SYMBOL(xt_unregister_match); | 144 | EXPORT_SYMBOL(xt_unregister_match); |
115 | 145 | ||
146 | int | ||
147 | xt_register_matches(struct xt_match *match, unsigned int n) | ||
148 | { | ||
149 | unsigned int i; | ||
150 | int err = 0; | ||
151 | |||
152 | for (i = 0; i < n; i++) { | ||
153 | err = xt_register_match(&match[i]); | ||
154 | if (err) | ||
155 | goto err; | ||
156 | } | ||
157 | return err; | ||
158 | |||
159 | err: | ||
160 | if (i > 0) | ||
161 | xt_unregister_matches(match, i); | ||
162 | return err; | ||
163 | } | ||
164 | EXPORT_SYMBOL(xt_register_matches); | ||
165 | |||
166 | void | ||
167 | xt_unregister_matches(struct xt_match *match, unsigned int n) | ||
168 | { | ||
169 | unsigned int i; | ||
170 | |||
171 | for (i = 0; i < n; i++) | ||
172 | xt_unregister_match(&match[i]); | ||
173 | } | ||
174 | EXPORT_SYMBOL(xt_unregister_matches); | ||
175 | |||
116 | 176 | ||
117 | /* | 177 | /* |
118 | * These are weird, but module loading must not be done with mutex | 178 | * These are weird, but module loading must not be done with mutex |