From 964b303f7784fac1ab453c96117bb7485daccc9b Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 30 Apr 2013 20:59:35 +0200 Subject: [PATCH] Don't track family of ipsets --- ipsets.c | 17 ++++++----------- ipsets.h | 2 +- main.c | 21 ++++++++++----------- utils.c | 17 ----------------- 4 files changed, 17 insertions(+), 40 deletions(-) diff --git a/ipsets.c b/ipsets.c index 7278c50..637af7e 100644 --- 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); } } diff --git a/ipsets.h b/ipsets.h index cbab741..929f311 100644 --- 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 5580c7d..fc2eb72 100644 --- 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 3558450..aef1cc6 100644 --- 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"; -- 2.25.1