svn commit: r303615 - head/sbin/ipfw
Andrey V. Elsukov
ae at FreeBSD.org
Mon Aug 1 13:38:49 UTC 2016
Author: ae
Date: Mon Aug 1 13:38:48 2016
New Revision: 303615
URL: https://svnweb.freebsd.org/changeset/base/303615
Log:
An old tables implementation had all tables preallocated,
so when user did `ipfw table N flush` it always worked, but now
when table N doesn't exist the kernel returns ESRCH error.
This isn't fatal error for flush and destroy commands. Do not
call err(3) when errno is equal to ESRCH. Also warn only when
quiet mode isn't enabled. This fixes a regression in behavior,
when old rules are loaded from file.
Also use correct value for switch in the table_swap().
Reported by: Kevin Oberman
MFC after: 3 days
Modified:
head/sbin/ipfw/tables.c
Modified: head/sbin/ipfw/tables.c
==============================================================================
--- head/sbin/ipfw/tables.c Mon Aug 1 12:17:44 2016 (r303614)
+++ head/sbin/ipfw/tables.c Mon Aug 1 13:38:48 2016 (r303615)
@@ -225,18 +225,30 @@ ipfw_table_handler(int ac, char *av[])
table_modify(&oh, ac, av);
break;
case TOK_DESTROY:
- if (table_destroy(&oh) != 0)
+ if (table_destroy(&oh) == 0)
+ break;
+ if (errno != ESRCH)
err(EX_OSERR, "failed to destroy table %s", tablename);
+ /* ESRCH isn't fatal, warn if not quiet mode */
+ if (co.do_quiet == 0)
+ warn("failed to destroy table %s", tablename);
break;
case TOK_FLUSH:
if (is_all == 0) {
- if ((error = table_flush(&oh)) != 0)
+ if ((error = table_flush(&oh)) == 0)
+ break;
+ if (errno != ESRCH)
err(EX_OSERR, "failed to flush table %s info",
tablename);
+ /* ESRCH isn't fatal, warn if not quiet mode */
+ if (co.do_quiet == 0)
+ warn("failed to flush table %s info",
+ tablename);
} else {
error = tables_foreach(table_flush_one, &oh, 1);
if (error != 0)
err(EX_OSERR, "failed to flush tables list");
+ /* XXX: we ignore errors here */
}
break;
case TOK_SWAP:
@@ -593,14 +605,14 @@ table_do_swap(ipfw_obj_header *oh, char
static int
table_swap(ipfw_obj_header *oh, char *second)
{
- int error;
if (table_check_name(second) != 0)
errx(EX_USAGE, "table name %s is invalid", second);
- error = table_do_swap(oh, second);
+ if (table_do_swap(oh, second) == 0)
+ return (0);
- switch (error) {
+ switch (errno) {
case EINVAL:
errx(EX_USAGE, "Unable to swap table: check types");
case EFBIG:
More information about the svn-src-head
mailing list