From owner-svn-src-all@freebsd.org Thu Aug 23 13:07:23 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 7E6B8108D6DE; Thu, 23 Aug 2018 13:07:23 +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 354D07171F; Thu, 23 Aug 2018 13:07:23 +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 16704225B2; Thu, 23 Aug 2018 13:07:23 +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 w7ND7Mme008163; Thu, 23 Aug 2018 13:07:22 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7ND7MXn008162; Thu, 23 Aug 2018 13:07:22 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201808231307.w7ND7MXn008162@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 23 Aug 2018 13:07:22 +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: r338244 - stable/11/sbin/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sbin/ipfw X-SVN-Commit-Revision: 338244 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, 23 Aug 2018 13:07:23 -0000 Author: ae Date: Thu Aug 23 13:07:22 2018 New Revision: 338244 URL: https://svnweb.freebsd.org/changeset/base/338244 Log: MFC r337536: 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. MFC r337574: Restore the behaviour changed in r337536, when bad `ipfw delete` command returns error. Now -q option only makes it quiet. And when -f flag is specified, the command will ignore errors and continue executing with next batched command. Obtained from: Yandex LLC Sponsored by: Yandex LLC Modified: stable/11/sbin/ipfw/ipfw.8 stable/11/sbin/ipfw/ipfw2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ipfw/ipfw.8 ============================================================================== --- stable/11/sbin/ipfw/ipfw.8 Thu Aug 23 10:38:59 2018 (r338243) +++ stable/11/sbin/ipfw/ipfw.8 Thu Aug 23 13:07:22 2018 (r338244) @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 9, 2018 +.Dd August 10, 2018 .Dt IPFW 8 .Os .Sh NAME @@ -315,10 +315,15 @@ When listing and .Fl d is specified, also show expired dynamic rules. .It Fl f -Do not ask for confirmation for commands that can cause problems -if misused, i.e., +Run without prompting for confirmation for commands that can cause problems if misused, +i.e., .Cm flush . If there is no tty associated with the process, this is implied. +The +.Cm delete +command with this flag ignores possible errors, +i.e., nonexistent rule number. +And for batched commands execution continues with the next command. .It Fl i When listing a table (see the .Sx LOOKUP TABLES Modified: stable/11/sbin/ipfw/ipfw2.c ============================================================================== --- stable/11/sbin/ipfw/ipfw2.c Thu Aug 23 10:38:59 2018 (r338243) +++ stable/11/sbin/ipfw/ipfw2.c Thu Aug 23 13:07:22 2018 (r338244) @@ -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_force == 0) exit(exitval); }