From 595e493649a97a738dd84699f65207735b9567e7 Mon Sep 17 00:00:00 2001 From: Charlie Brady Date: Sun, 12 Jun 2005 15:54:15 +0000 Subject: Flush chain with noflush when it is redefined (Charlie Brady ) --- ip6tables-restore.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'ip6tables-restore.c') 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"); -- cgit v1.2.3