Commit 52d9c42e authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NETFILTER]: x_tables: add helpers for mass match/target registration

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 90528e6f
...@@ -290,8 +290,13 @@ struct xt_table_info ...@@ -290,8 +290,13 @@ struct xt_table_info
extern int xt_register_target(struct xt_target *target); extern int xt_register_target(struct xt_target *target);
extern void xt_unregister_target(struct xt_target *target); extern void xt_unregister_target(struct xt_target *target);
extern int xt_register_targets(struct xt_target *target, unsigned int n);
extern void xt_unregister_targets(struct xt_target *target, unsigned int n);
extern int xt_register_match(struct xt_match *target); extern int xt_register_match(struct xt_match *target);
extern void xt_unregister_match(struct xt_match *target); extern void xt_unregister_match(struct xt_match *target);
extern int xt_register_matches(struct xt_match *match, unsigned int n);
extern void xt_unregister_matches(struct xt_match *match, unsigned int n);
extern int xt_check_match(const struct xt_match *match, unsigned short family, extern int xt_check_match(const struct xt_match *match, unsigned short family,
unsigned int size, const char *table, unsigned int hook, unsigned int size, const char *table, unsigned int hook,
......
...@@ -86,6 +86,36 @@ xt_unregister_target(struct xt_target *target) ...@@ -86,6 +86,36 @@ xt_unregister_target(struct xt_target *target)
} }
EXPORT_SYMBOL(xt_unregister_target); EXPORT_SYMBOL(xt_unregister_target);
int
xt_register_targets(struct xt_target *target, unsigned int n)
{
unsigned int i;
int err = 0;
for (i = 0; i < n; i++) {
err = xt_register_target(&target[i]);
if (err)
goto err;
}
return err;
err:
if (i > 0)
xt_unregister_targets(target, i);
return err;
}
EXPORT_SYMBOL(xt_register_targets);
void
xt_unregister_targets(struct xt_target *target, unsigned int n)
{
unsigned int i;
for (i = 0; i < n; i++)
xt_unregister_target(&target[i]);
}
EXPORT_SYMBOL(xt_unregister_targets);
int int
xt_register_match(struct xt_match *match) xt_register_match(struct xt_match *match)
{ {
...@@ -113,6 +143,36 @@ xt_unregister_match(struct xt_match *match) ...@@ -113,6 +143,36 @@ xt_unregister_match(struct xt_match *match)
} }
EXPORT_SYMBOL(xt_unregister_match); EXPORT_SYMBOL(xt_unregister_match);
int
xt_register_matches(struct xt_match *match, unsigned int n)
{
unsigned int i;
int err = 0;
for (i = 0; i < n; i++) {
err = xt_register_match(&match[i]);
if (err)
goto err;
}
return err;
err:
if (i > 0)
xt_unregister_matches(match, i);
return err;
}
EXPORT_SYMBOL(xt_register_matches);
void
xt_unregister_matches(struct xt_match *match, unsigned int n)
{
unsigned int i;
for (i = 0; i < n; i++)
xt_unregister_match(&match[i]);
}
EXPORT_SYMBOL(xt_unregister_matches);
/* /*
* These are weird, but module loading must not be done with mutex * These are weird, but module loading must not be done with mutex
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment