summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ip6tables-restore.c21
-rw-r--r--iptables-restore.c21
2 files changed, 30 insertions, 12 deletions
diff --git a/ip6tables-restore.c b/ip6tables-restore.c
index 6909c8d7..cf69a6c7 100644
--- a/ip6tables-restore.c
+++ b/ip6tables-restore.c
@@ -233,12 +233,21 @@ int main(int argc, char *argv[])
}
if (ip6tc_builtin(chain, handle) <= 0) {
- DEBUGP("Creating new chain '%s'\n", chain);
- if (!ip6tc_create_chain(chain, &handle))
- exit_error(PARAMETER_PROBLEM,
- "error creating chain "
- "'%s':%s\n", chain,
- strerror(errno));
+ if (noflush && ip6tc_is_chain(chain, handle)) {
+ DEBUGP("Flushing existing user defined chain '%s'\n", chain);
+ if (!ip6tc_flush_entries(chain, &handle))
+ exit_error(PARAMETER_PROBLEM,
+ "error flushing chain "
+ "'%s':%s\n", chain,
+ strerror(errno));
+ } else {
+ DEBUGP("Creating new chain '%s'\n", chain);
+ if (!ip6tc_create_chain(chain, &handle))
+ exit_error(PARAMETER_PROBLEM,
+ "error creating chain "
+ "'%s':%s\n", chain,
+ strerror(errno));
+ }
}
policy = strtok(NULL, " \t\n");
diff --git a/iptables-restore.c b/iptables-restore.c
index 42aa2a27..e2872cde 100644
--- a/iptables-restore.c
+++ b/iptables-restore.c
@@ -236,12 +236,21 @@ main(int argc, char *argv[])
}
if (iptc_builtin(chain, handle) <= 0) {
- DEBUGP("Creating new chain '%s'\n", chain);
- if (!iptc_create_chain(chain, &handle))
- exit_error(PARAMETER_PROBLEM,
- "error creating chain "
- "'%s':%s\n", chain,
- strerror(errno));
+ if (noflush && iptc_is_chain(chain, handle)) {
+ DEBUGP("Flushing existing user defined chain '%s'\n", chain);
+ if (!iptc_flush_entries(chain, &handle))
+ exit_error(PARAMETER_PROBLEM,
+ "error flushing chain "
+ "'%s':%s\n", chain,
+ strerror(errno));
+ } else {
+ DEBUGP("Creating new chain '%s'\n", chain);
+ if (!iptc_create_chain(chain, &handle))
+ exit_error(PARAMETER_PROBLEM,
+ "error creating chain "
+ "'%s':%s\n", chain,
+ strerror(errno));
+ }
}
policy = strtok(NULL, " \t\n");