Don't track family of ipsets
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 30 Apr 2013 18:59:35 +0000 (20:59 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 30 Apr 2013 19:00:32 +0000 (21:00 +0200)
ipsets.c
ipsets.h
main.c
utils.c

index 7278c50cd6a3b519db0e6ba87117af0d94404a86..637af7e8b76f9356d19db40737da9d07ff26066c 100644 (file)
--- a/ipsets.c
+++ b/ipsets.c
@@ -348,21 +348,16 @@ fw3_create_ipsets(struct fw3_state *state)
 }
 
 void
-fw3_destroy_ipsets(struct fw3_state *state, enum fw3_family family)
+fw3_destroy_ipsets(struct fw3_state *state)
 {
-       struct fw3_ipset *s, *tmp;
+       struct fw3_ipset *s;
 
-       list_for_each_entry_safe(s, tmp, &state->ipsets, list)
+       list_for_each_entry(s, &state->ipsets, list)
        {
-               del(s->flags, family, family);
+               info(" * Deleting ipset %s", s->name);
 
-               if (fw3_no_family(s->flags[family == FW3_FAMILY_V6]))
-               {
-                       info(" * Deleting ipset %s", s->name);
-
-                       fw3_pr("flush %s\n", s->name);
-                       fw3_pr("destroy %s\n", s->name);
-               }
+               fw3_pr("flush %s\n", s->name);
+               fw3_pr("destroy %s\n", s->name);
        }
 }
 
index cbab741d4dadc1b0c87b66e7da3b5cbee80453c4..929f31194627c7a20b9659fd2a7872f81a67d280 100644 (file)
--- a/ipsets.h
+++ b/ipsets.h
@@ -27,7 +27,7 @@ extern const struct fw3_option fw3_ipset_opts[];
 struct fw3_ipset * fw3_alloc_ipset(void);
 void fw3_load_ipsets(struct fw3_state *state, struct uci_package *p);
 void fw3_create_ipsets(struct fw3_state *state);
-void fw3_destroy_ipsets(struct fw3_state *state, enum fw3_family family);
+void fw3_destroy_ipsets(struct fw3_state *state);
 
 struct fw3_ipset * fw3_lookup_ipset(struct fw3_state *state, const char *name);
 
diff --git a/main.c b/main.c
index 5580c7d144a38dd605ab5499b1c6e54c900ee35c..fc2eb7230552798912f9f44fea1aa8cb3c1fcf7c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -233,20 +233,19 @@ stop(bool complete, bool reload)
                }
 
                fw3_command_close();
+               family_set(run_state, family, false);
+               family_set(cfg_state, family, false);
 
-               if (!reload && run_state)
-               {
-                       if (fw3_command_pipe(false, "ipset", "-exist", "-"))
-                       {
-                               fw3_destroy_ipsets(run_state, family);
-                               fw3_command_close();
-                       }
+               rv = 0;
+       }
 
-                       family_set(run_state, family, false);
-                       family_set(cfg_state, family, false);
+       if (!reload && run_state)
+       {
+               if (fw3_command_pipe(false, "ipset", "-exist", "-"))
+               {
+                       fw3_destroy_ipsets(run_state);
+                       fw3_command_close();
                }
-
-               rv = 0;
        }
 
        if (complete && (ct = fopen("/proc/net/nf_conntrack", "w")) != NULL)
diff --git a/utils.c b/utils.c
index 3558450d8831a96aa2a9ffa0763ea2a6a0eaf464..aef1cc68b77d342a91e77f890126908ecb0e06b5 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -490,8 +490,6 @@ static void
 write_ipset_uci(struct uci_context *ctx, struct fw3_ipset *s,
                 struct uci_package *dest)
 {
-       enum fw3_family fam = FW3_FAMILY_ANY;
-
        char buf[sizeof("0xffffffff\0")];
 
        struct uci_ptr ptr = { .p = dest };
@@ -499,13 +497,6 @@ write_ipset_uci(struct uci_context *ctx, struct fw3_ipset *s,
        if (!s->enabled || (s->external && *s->external))
                return;
 
-       if (fw3_no_family(s->flags[0]) && !fw3_no_family(s->flags[1]))
-               fam = FW3_FAMILY_V6;
-       else if (!fw3_no_family(s->flags[0]) && fw3_no_family(s->flags[1]))
-               fam = FW3_FAMILY_V4;
-       else if (fw3_no_family(s->flags[0]) && fw3_no_family(s->flags[1]))
-               return;
-
        uci_add_section(ctx, dest, "ipset", &ptr.s);
 
        ptr.o      = NULL;
@@ -513,14 +504,6 @@ write_ipset_uci(struct uci_context *ctx, struct fw3_ipset *s,
        ptr.value  = s->name;
        uci_set(ctx, &ptr);
 
-       if (fam != FW3_FAMILY_ANY)
-       {
-               ptr.o      = NULL;
-               ptr.option = "family";
-               ptr.value  = fw3_flag_names[fam];
-               uci_set(ctx, &ptr);
-       }
-
        sprintf(buf, "0x%x", s->flags[0]);
        ptr.o      = NULL;
        ptr.option = "__flags_v4";