diff options
author | Kristof Provost <kp@FreeBSD.org> | 2021-02-17 16:38:04 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2022-03-02 16:00:05 +0000 |
commit | c696d5c72fe1426f26f798260f8cdc97e6f8cee5 (patch) | |
tree | 74495896eac727b4eeeaf594b5a21de92aebfc97 /sbin | |
parent | 30087aa2e00ac8ba7cc487ddc9fccfdd2cd330ea (diff) | |
download | src-c696d5c72fe1426f26f798260f8cdc97e6f8cee5.tar.gz src-c696d5c72fe1426f26f798260f8cdc97e6f8cee5.zip |
pfctl: Don't print (ether) to / from if they're not set
If we're not filtering on a specific MAC address don't print it at all,
rather than showing an all-zero address.
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31749
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/pfctl/pfctl_parser.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 8814dc38b23c..c7e980103fad 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -694,6 +694,16 @@ print_src_node(struct pf_src_node *sn, int opts) static void print_eth_addr(const struct pfctl_eth_addr *a) { + int i; + for (i = 0; i < ETHER_ADDR_LEN; i++) { + if (a->addr[i] != 0) + break; + } + + /* Unset, so don't print anything. */ + if (i == ETHER_ADDR_LEN) + return; + printf("%s%02x:%02x:%02x:%02x:%02x:%02x", a->neg ? "! " : "", a->addr[0], a->addr[1], a->addr[2], a->addr[3], a->addr[4], a->addr[5]); @@ -724,10 +734,14 @@ print_eth_rule(struct pfctl_eth_rule *r, int rule_numbers) if (r->proto) printf(" proto 0x%04x", r->proto); - printf(" from "); - print_eth_addr(&r->src); - printf(" to "); - print_eth_addr(&r->dst); + if (r->src.isset) { + printf(" from "); + print_eth_addr(&r->src); + } + if (r->dst.isset) { + printf(" to "); + print_eth_addr(&r->dst); + } if (r->qname[0]) printf(" queue %s", r->qname); |