From owner-svn-src-all@FreeBSD.ORG Mon Oct 13 11:26:18 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9F4D042F; Mon, 13 Oct 2014 11:26:18 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 87A6861B; Mon, 13 Oct 2014 11:26:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9DBQI8S087388; Mon, 13 Oct 2014 11:26:18 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9DBQI4k087387; Mon, 13 Oct 2014 11:26:18 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <201410131126.s9DBQI4k087387@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Mon, 13 Oct 2014 11:26:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273032 - head/sbin/ipfw X-SVN-Group: head 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.18-1 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: Mon, 13 Oct 2014 11:26:18 -0000 Author: melifaro Date: Mon Oct 13 11:26:17 2014 New Revision: 273032 URL: https://svnweb.freebsd.org/changeset/base/273032 Log: * Fix zeroing individual entries via ipfw(8). * Report error and return non-zero exit code if zeroing non-matched entries Found by: Oleg Ginzburg Modified: head/sbin/ipfw/ipfw2.c Modified: head/sbin/ipfw/ipfw2.c ============================================================================== --- head/sbin/ipfw/ipfw2.c Mon Oct 13 11:16:44 2014 (r273031) +++ head/sbin/ipfw/ipfw2.c Mon Oct 13 11:26:17 2014 (r273032) @@ -2111,13 +2111,19 @@ static int do_range_cmd(int cmd, ipfw_range_tlv *rt) { ipfw_range_header rh; + size_t sz; memset(&rh, 0, sizeof(rh)); memcpy(&rh.range, rt, sizeof(*rt)); rh.range.head.length = sizeof(*rt); rh.range.head.type = IPFW_TLV_RANGE; + sz = sizeof(rh); - return (do_set3(cmd, &rh.opheader, sizeof(rh))); + if (do_get3(cmd, &rh.opheader, &sz) != 0) + return (-1); + /* Save number of matched objects */ + rt->new_set = rh.range.new_set; + return (0); } /* @@ -4792,6 +4798,9 @@ ipfw_zero(int ac, char *av[], int optnam warn("rule %u: setsockopt(IP_FW_X%s)", arg, name); failed = EX_UNAVAILABLE; + } else if (rt.new_set == 0) { + printf("Entry %d not found\n", arg); + failed = EX_UNAVAILABLE; } else if (!co.do_quiet) printf("Entry %d %s.\n", arg, optname == IP_FW_XZERO ? @@ -4799,6 +4808,7 @@ ipfw_zero(int ac, char *av[], int optnam } else { errx(EX_USAGE, "invalid rule number ``%s''", *av); } + av++; ac--; } if (failed != EX_OK) exit(failed);