git: 4f642f569b47 - main - pfctl: match broadcast address behaviour to the kernel

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Sat, 03 May 2025 08:14:29 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=4f642f569b47692a53ce142a6b64c506122b0c22

commit 4f642f569b47692a53ce142a6b64c506122b0c22
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-05-02 12:26:37 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-05-03 08:13:53 +0000

    pfctl: match broadcast address behaviour to the kernel
    
    When using a /32 IPv4 interface address, pfctl(8) reports a 0.0.0.0
    as broadcast address.  The kernel does not consider this a broadcast
    address and ifconfig(8) has a check to exclude it.  Use the same
    check in pfctl(8).
    Found by regress/sbin/pfctl pfi2; OK mikeb@
    
    Obtained from:  OpenBSD, bluhm <bluhm@openbsd.org>, cf181e999d
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/pfctl/pfctl_parser.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index 8a64578b136d..d814b5f200e1 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1715,6 +1715,8 @@ ifa_lookup(char *ifa_name, int flags)
 		if ((flags & PFI_AFLAG_BROADCAST) &&
 		    !(p->ifa_flags & IFF_BROADCAST))
 			continue;
+		if ((flags & PFI_AFLAG_BROADCAST) && p->bcast.v4.s_addr == 0)
+			continue;
 		if ((flags & PFI_AFLAG_PEER) &&
 		    !(p->ifa_flags & IFF_POINTOPOINT))
 			continue;