summaryrefslogtreecommitdiff
path: root/src/iptables.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2013-02-21 17:42:33 +0100
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-22 12:42:56 +0200
commit896120bead9a86ee1528cd6f1ff8949d183b9ed4 (patch)
tree0706c6d3ec2e9c40d1fa6d104556ba143aa4039d /src/iptables.c
parent18fd922f6253daf6275186f6db1c1248106b35fb (diff)
downloadconnman-896120bead9a86ee1528cd6f1ff8949d183b9ed4.tar.gz
connman-896120bead9a86ee1528cd6f1ff8949d183b9ed4.tar.bz2
connman-896120bead9a86ee1528cd6f1ff8949d183b9ed4.zip
iptables: Merge clear_tables_flags() and reset_xtables()
Both function reset the xtables library. So let's do this at the same place.
Diffstat (limited to 'src/iptables.c')
-rw-r--r--src/iptables.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/iptables.c b/src/iptables.c
index 0662f02a..c5776b1c 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -1653,24 +1653,6 @@ static struct connman_iptables *pre_load_table(const char *table_name,
return iptables_init(table_name);
}
-static void clear_tables_flags(void)
-{
- struct xtables_match *xt_m;
- struct xtables_target *xt_t;
-
- /*
- * Clear all flags because the flags are only valid
- * for one rule.
- */
- for (xt_m = xtables_matches; xt_m != NULL; xt_m = xt_m->next)
- xt_m->mflags = 0;
-
- for (xt_t = xtables_targets; xt_t != NULL; xt_t = xt_t->next) {
- xt_t->tflags = 0;
- xt_t->used = 0;
- }
-}
-
struct parse_context {
int argc;
char **argv;
@@ -1916,13 +1898,6 @@ static int parse_rule_spec(struct connman_iptables *table,
return -ENOMEM;
/*
- * As side effect parsing a rule sets some global flags
- * which will be evaluated/verified. Let's reset them
- * to ensure we can parse more than one rule.
- */
- clear_tables_flags();
-
- /*
* Tell getopt_long not to generate error messages for unknown
* options and also reset optind back to 0.
*/
@@ -2034,6 +2009,25 @@ out:
static void reset_xtables(void)
{
+ struct xtables_match *xt_m;
+ struct xtables_target *xt_t;
+
+ /*
+ * As side effect parsing a rule sets some global flags
+ * which will be evaluated/verified. Let's reset them
+ * to ensure we can parse more than one rule.
+ *
+ * Clear all flags because the flags are only valid
+ * for one rule.
+ */
+ for (xt_m = xtables_matches; xt_m != NULL; xt_m = xt_m->next)
+ xt_m->mflags = 0;
+
+ for (xt_t = xtables_targets; xt_t != NULL; xt_t = xt_t->next) {
+ xt_t->tflags = 0;
+ xt_t->used = 0;
+ }
+
/*
* We need also to free the memory implicitly allocated
* during parsing (see xtables_options_xfrm()).