aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2022-01-21 15:37:21 +0000
committerKristof Provost <kp@FreeBSD.org>2022-03-02 16:00:08 +0000
commitc32cd18055c01f2460950351accfe79f87a24c43 (patch)
treed31ff61c406a8856d09a53bff2d58cc4731f8ff3
parent0d889267408e85a1e37baa8d2d660c32dc11ceef (diff)
downloadsrc-c32cd18055c01f2460950351accfe79f87a24c43.tar.gz
src-c32cd18055c01f2460950351accfe79f87a24c43.zip
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")
-rw-r--r--sbin/pfctl/parse.y3
-rw-r--r--sbin/pfctl/pfctl.c9
-rw-r--r--sbin/pfctl/pfctl_parser.h1
3 files changed, 12 insertions, 1 deletions
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;
};