summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>2006-02-14 03:10:29 +0000
committerJulian Elischer <julian@FreeBSD.org>2006-02-14 03:10:29 +0000
commit21899082aec753c4d35a104dcad3e63d4471ee2c (patch)
treeb585f3d60d9aec395e3d708769267f32fd425194 /sbin
parent085a0d43caee81deb45157e8e52f56b29a955995 (diff)
Notes
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ipfw/ipfw.83
-rw-r--r--sbin/ipfw/ipfw2.c11
2 files changed, 13 insertions, 1 deletions
diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8
index 8ba94e03823c5..911af5c81977c 100644
--- a/sbin/ipfw/ipfw.8
+++ b/sbin/ipfw/ipfw.8
@@ -232,7 +232,8 @@ commands in a script
.Ql sh\ /etc/rc.firewall ) ,
or by processing a file of many
.Nm
-rules across a remote login session.
+rules across a remote login session. It also stops a table add or delete
+from failing if the entry already exists or is not present.
If a
.Cm flush
is performed in normal (verbose) mode (with the default kernel
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 13e1df365d976..f88ce70c5e96e 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -4815,6 +4815,17 @@ table_handler(int ac, char *av[])
ent.value = 0;
if (do_cmd(do_add ? IP_FW_TABLE_ADD : IP_FW_TABLE_DEL,
&ent, sizeof(ent)) < 0)
+ /* If running silent, don't bomb out on these errors. */
+ if (!(do_quiet && (errno == (do_add ? EEXIST : ESRCH))))
+ err(EX_OSERR, "setsockopt(IP_FW_TABLE_%s)",
+ do_add ? "ADD" : "DEL");
+ /* In silent mode, react to a failed add by deleting */
+ if (do_add)
+ do_cmd(IP_FW_TABLE_DEL, &ent, sizeof(ent));
+ if (do_cmd(IP_FW_TABLE_ADD,
+ &ent, sizeof(ent)) < 0)
+ err(EX_OSERR,
+ "setsockopt(IP_FW_TABLE_ADD)");
err(EX_OSERR, "setsockopt(IP_FW_TABLE_%s)",
do_add ? "ADD" : "DEL");
} else if (_substrcmp(*av, "flush") == 0) {