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 /iptables-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 'iptables-restore.c')
-rw-r--r-- | iptables-restore.c | 21 |
1 files changed, 15 insertions, 6 deletions
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"); |