From nobody Wed Mar 02 16:01:09 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 618AF19E1C98; Wed, 2 Mar 2022 16:01:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K7zPM2bvZz3NZr; Wed, 2 Mar 2022 16:01:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646236872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SUWxvFswzWMUB3gPDSztN7VJD88ibwaKRd4VrEOM7Jk=; b=bKArpOhA9DOIChqjxw7gOG0EMSA2mkvlcmIHpgEhWl+vLVJ2qCMtSc+TYZhHR39SqTKV0V 8WZevHFSXZeMQZiu1VoDhb4x6iChPeZr0rWj9LksEoA1mAfmxRHIKO9UXSXSQIlO6KmnaQ BUfjWHMp7AtnT179f3OA6y9Tkwzz4nqX0BCp+je90w7DOqOXXYCLVugPtLPF9eyxxW5x// u7oNDQ38IzmKeyLT36i6sorPde+L8bMMIxIPgGUXIBFNJQc3qMawq6CiRTV21wZuI3vnFM +Y1DAvl9FO1BmSm6kiiVGSyl31UQ2H86heUsKQNtQBgbOAa1IR9EFBGOwuHJ4Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E700326348; Wed, 2 Mar 2022 16:01:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 222G19MY091583; Wed, 2 Mar 2022 16:01:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 222G19Rn091582; Wed, 2 Mar 2022 16:01:09 GMT (envelope-from git) Date: Wed, 2 Mar 2022 16:01:09 GMT Message-Id: <202203021601.222G19Rn091582@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: c32cd18055c0 - main - pfctl: print ethernet rules when called with '-n' List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c32cd18055c01f2460950351accfe79f87a24c43 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646236871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SUWxvFswzWMUB3gPDSztN7VJD88ibwaKRd4VrEOM7Jk=; b=PGltbBnX75eYo/8nLVG2BKnBrEAABWuNX8jPrbWXgN5Q3zi1stGdOaKPpuG6Q4KzoJL8Cm POpIR7/X6vd3mZdzQlNUhTdzqdzt7JnjhJHPVEmtTtLLIV6PJfrhr6vUn0ia3h4BlACnw6 WZvmd7BW8IuOl4KuwsE6ukO+58l3wK7j8NTqG0D7Gtvei6uyI6B7q+ndKpydDoJcfvDPt+ nPyISnHSTvaUXOhsbCN9SlMKT1wRXHtLQWNG77GpwL43NhF9svLc3pQhUIm67HGc51CP+R 7rALAFY+vxH4yQtc5vS96QqVGhFnT0yQ1WFrVS7pi1y4O3ggatZsBh+h+TWOgg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646236871; a=rsa-sha256; cv=none; b=GqUMfuuvymxle2InE7rOjjSu8Wd0hbh6JoXz9mHilkSTe2lLFPS4Y6Naq4jBPRYgHYx195 nLwKujpqGNCsZWWzZegNbeJDZgSe0UlNY8slCz2clws2IlUWwx75j3rTDPuOk4sP65l8oh TzsPMOVY0xqOZGbDT1BD+sgpnYmNVouNfH0H32SQ1eTTpH23LouZ3xsFg8hZ7gIgL9Nfob 1Tu6rHAWght0ShhBmnB31cYrZPkEch9NoKoYak5jR2Y8MqTSBDfXXLsoViGZXKYIH+qU+P WmGTsNIycAKg/GN308r8BAh7QfPNB92X/kNGqjK5s15P789anO57Frt3zuUTHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=c32cd18055c01f2460950351accfe79f87a24c43 commit c32cd18055c01f2460950351accfe79f87a24c43 Author: Kristof Provost AuthorDate: 2022-01-21 15:37:21 +0000 Commit: Kristof Provost CommitDate: 2022-03-02 16:00:08 +0000 pfctl: print ethernet rules when called with '-n' Just as pfctl already does for other rules we print the ethernet rules we would have loaded if '-n' is specified. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/parse.y | 3 +++ sbin/pfctl/pfctl.c | 9 ++++++++- sbin/pfctl/pfctl_parser.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 346ec9d9a587..8a0aa4279337 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -5749,9 +5749,11 @@ expand_eth_rule(struct pfctl_eth_rule *r, bcopy(src->mac, r->src.addr, ETHER_ADDR_LEN); bcopy(src->mask, r->src.mask, ETHER_ADDR_LEN); r->src.neg = src->neg; + r->src.isset = src->isset; bcopy(dst->mac, r->dst.addr, ETHER_ADDR_LEN); bcopy(dst->mask, r->dst.mask, ETHER_ADDR_LEN); r->dst.neg = dst->neg; + r->dst.isset = dst->isset; r->nr = pf->eastack[pf->asd]->match++; pfctl_append_eth_rule(pf, r, anchor_call); @@ -6926,6 +6928,7 @@ node_mac_from_string(const char *str) } memset(m->mask, 0xff, ETHER_ADDR_LEN); + m->isset = true; m->next = NULL; m->tail = m; diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 89b546a1b9e2..4ff1bd25e0eb 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1698,7 +1698,8 @@ pfctl_load_eth_ruleset(struct pfctl *pf, char *path, if ((error = pfctl_load_eth_ruleset(pf, path, &r->anchor->ruleset, depth + 1))) return (error); - } + } else if (pf->opts & PF_OPT_VERBOSE) + printf("\n"); free(r); } if (brace && pf->opts & PF_OPT_VERBOSE) { @@ -1743,6 +1744,12 @@ pfctl_load_eth_rule(struct pfctl *pf, char *path, struct pfctl_eth_rule *r, pf->eth_ticket)) err(1, "DIOCADDETHRULENV"); + if (pf->opts & PF_OPT_VERBOSE) { + INDENT(depth, !(pf->opts & PF_OPT_VERBOSE2)); + print_eth_rule(r, r->anchor ? r->anchor->name : "", + pf->opts & (PF_OPT_VERBOSE2 | PF_OPT_DEBUG)); + } + path[len] = '\0'; return (0); diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 60bbae7a3fcd..13151cc33829 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -140,6 +140,7 @@ struct node_mac { u_int8_t mac[ETHER_ADDR_LEN]; u_int8_t mask[ETHER_ADDR_LEN]; bool neg; + bool isset; struct node_mac *next; struct node_mac *tail; };