From owner-svn-src-stable@freebsd.org Thu Aug 4 11:26:54 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F68FBAE1F4; Thu, 4 Aug 2016 11:26:54 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CDA801C33; Thu, 4 Aug 2016 11:26:53 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u74BQrIa092405; Thu, 4 Aug 2016 11:26:53 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u74BQre9092404; Thu, 4 Aug 2016 11:26:53 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201608041126.u74BQre9092404@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 4 Aug 2016 11:26:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r303741 - stable/11/sbin/ipfw X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2016 11:26:54 -0000 Author: ae Date: Thu Aug 4 11:26:52 2016 New Revision: 303741 URL: https://svnweb.freebsd.org/changeset/base/303741 Log: MFC r303615: 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 Approved by: re (kib) Modified: stable/11/sbin/ipfw/tables.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ipfw/tables.c ============================================================================== --- stable/11/sbin/ipfw/tables.c Thu Aug 4 11:22:51 2016 (r303740) +++ stable/11/sbin/ipfw/tables.c Thu Aug 4 11:26:52 2016 (r303741) @@ -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: