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
This commit is contained in:
parent
4ad2fb1d62
commit
24f451b374
@ -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 *second)
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user