diff options
author | Charlie Brady <charlieb-netfilter-devel@budge.apana.org.au> | 2005-06-12 15:54:15 +0000 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2005-06-12 15:54:15 +0000 |
commit | 595e493649a97a738dd84699f65207735b9567e7 (patch) | |
tree | 9c683bc27b90eecb4ef6e1ed05c4369e0768cad7 /ip6tables-restore.c | |
parent | 38eb730cc867a470f3e5468e804b553e96272ccf (diff) |
Flush chain with noflush when it is redefined (Charlie Brady <charlieb-netfilter-devel@budge.apana.org.au>)
Diffstat (limited to 'ip6tables-restore.c')
-rw-r--r-- | ip6tables-restore.c | 21 |
1 files changed, 15 insertions, 6 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"); |