From owner-svn-src-all@freebsd.org Thu Aug 9 12:46:31 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1272910651BC; Thu, 9 Aug 2018 12:46:31 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BB35371655; Thu, 9 Aug 2018 12:46:30 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9768D19947; Thu, 9 Aug 2018 12:46:30 +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 w79CkU7u012088; Thu, 9 Aug 2018 12:46:30 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w79CkU84012087; Thu, 9 Aug 2018 12:46:30 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201808091246.w79CkU84012087@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 9 Aug 2018 12:46:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337536 - head/sbin/ipfw X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/sbin/ipfw X-SVN-Commit-Revision: 337536 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2018 12:46:31 -0000 Author: ae Date: Thu Aug 9 12:46:30 2018 New Revision: 337536 URL: https://svnweb.freebsd.org/changeset/base/337536 Log: If -q flag is specified, do not complain when we are trying to delete nonexistent NAT instance or nonexistent rule. This allows execute batched `delete` commands and do not fail when found nonexistent rule. Obtained from: Yandex LLC MFC after: 2 weeks Sponsored by: Yandex LLC Modified: head/sbin/ipfw/ipfw2.c Modified: head/sbin/ipfw/ipfw2.c ============================================================================== --- head/sbin/ipfw/ipfw2.c Thu Aug 9 12:17:03 2018 (r337535) +++ head/sbin/ipfw/ipfw2.c Thu Aug 9 12:46:30 2018 (r337536) @@ -3271,9 +3271,11 @@ ipfw_delete(char *av[]) exitval = do_cmd(IP_FW_NAT_DEL, &i, sizeof i); if (exitval) { exitval = EX_UNAVAILABLE; - warn("rule %u not available", i); + if (co.do_quiet) + continue; + warn("nat %u not available", i); } - } else if (co.do_pipe) { + } else if (co.do_pipe) { exitval = ipfw_delete_pipe(co.do_pipe, i); } else { memset(&rt, 0, sizeof(rt)); @@ -3295,10 +3297,14 @@ ipfw_delete(char *av[]) i = do_range_cmd(IP_FW_XDEL, &rt); if (i != 0) { exitval = EX_UNAVAILABLE; + if (co.do_quiet) + continue; warn("rule %u: setsockopt(IP_FW_XDEL)", rt.start_rule); } else if (rt.new_set == 0 && do_set == 0) { exitval = EX_UNAVAILABLE; + if (co.do_quiet) + continue; if (rt.start_rule != rt.end_rule) warnx("no rules rules in %u-%u range", rt.start_rule, rt.end_rule); @@ -3308,7 +3314,7 @@ ipfw_delete(char *av[]) } } } - if (exitval != EX_OK) + if (exitval != EX_OK && co.do_quiet == 0) exit(exitval); }