pfctl: improve bitmask printing

In some cases the netmask gets set to a full 128 bit mask even if no
address family is selected; don't print the v6 mask if it's a v4 address.

Obtained from:	OpenBSD, mcbride <mcbride@openbsd.org>, f6d7b41f07
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46584
This commit is contained in:
Kristof Provost 2024-08-29 13:48:41 +02:00
parent 03d11291d8
commit e044f67a66

View File

@ -128,7 +128,7 @@ print_addr(struct pf_addr_wrap *addr, sa_family_t af, int verbose)
PF_AZERO(&addr->v.a.mask, AF_INET6))) {
int bits = unmask(&addr->v.a.mask, af);
if (bits != (af == AF_INET ? 32 : 128))
if (bits < (af == AF_INET ? 32 : 128))
printf("/%d", bits);
}
}