The branch main has been updated by kp:

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

commit fb48e6d71b1fa9085245ceb251d7442f460e58e1
Author:     Kristof Provost <k...@freebsd.org>
AuthorDate: 2025-06-27 12:33:09 +0000
Commit:     Kristof Provost <k...@freebsd.org>
CommitDate: 2025-07-02 07:40:53 +0000

    pfctl: Remove unused af argument from unmask()
    
    This has been unused for years.
    
    While here, zap the duplicate function signature from pfctl.h (already
    present in pfctl_parser.h); spotted by sashan, thanks.
    
    OK sashan
    
    Obtained from:  OpenBSD, kn <k...@openbsd.org>, f0bb6ca5dd
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/pfctl/parse.y          |  6 +++---
 sbin/pfctl/pf_print_state.c |  4 ++--
 sbin/pfctl/pfctl.h          |  1 -
 sbin/pfctl/pfctl_optimize.c | 10 +++++-----
 sbin/pfctl/pfctl_parser.c   |  8 ++++----
 sbin/pfctl/pfctl_parser.h   |  2 +-
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 9d2fd35ea4ee..f05e5608ba9d 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -3640,9 +3640,9 @@ host              : STRING                        {
                        if (b->af != e->af ||
                            b->addr.type != PF_ADDR_ADDRMASK ||
                            e->addr.type != PF_ADDR_ADDRMASK ||
-                           unmask(&b->addr.v.a.mask, b->af) !=
+                           unmask(&b->addr.v.a.mask) !=
                            (b->af == AF_INET ? 32 : 128) ||
-                           unmask(&e->addr.v.a.mask, e->af) !=
+                           unmask(&e->addr.v.a.mask) !=
                            (e->af == AF_INET ? 32 : 128) ||
                            b->next != NULL || b->not ||
                            e->next != NULL || e->not) {
@@ -5551,7 +5551,7 @@ expand_label_addr(const char *name, char *label, size_t 
len, sa_family_t af,
                                    sizeof(a)) == NULL)
                                        snprintf(tmp, sizeof(tmp), "?");
                                else {
-                                       bits = unmask(&addr->addr.v.a.mask, af);
+                                       bits = unmask(&addr->addr.v.a.mask);
                                        if ((af == AF_INET && bits < 32) ||
                                            (af == AF_INET6 && bits < 128))
                                                snprintf(tmp, sizeof(tmp),
diff --git a/sbin/pfctl/pf_print_state.c b/sbin/pfctl/pf_print_state.c
index 433d1d4e0b7b..d0882b04f5f6 100644
--- a/sbin/pfctl/pf_print_state.c
+++ b/sbin/pfctl/pf_print_state.c
@@ -113,7 +113,7 @@ print_addr(struct pf_addr_wrap *addr, sa_family_t af, int 
verbose)
        if (addr->type != PF_ADDR_RANGE &&
            !(PF_AZERO(&addr->v.a.addr, AF_INET6) &&
            PF_AZERO(&addr->v.a.mask, AF_INET6))) {
-               int bits = unmask(&addr->v.a.mask, af);
+               int bits = unmask(&addr->v.a.mask);
 
                if (bits < (af == AF_INET ? 32 : 128))
                        printf("/%d", bits);
@@ -450,7 +450,7 @@ print_state(struct pfctl_state *s, int opts)
 }
 
 int
-unmask(struct pf_addr *m, sa_family_t af)
+unmask(struct pf_addr *m)
 {
        int i = 31, j = 0, b = 0;
        u_int32_t tmp;
diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h
index ab24ec7174ec..5abd5ddcdf8f 100644
--- a/sbin/pfctl/pfctl.h
+++ b/sbin/pfctl/pfctl.h
@@ -124,7 +124,6 @@ void         print_addr_str(sa_family_t, struct pf_addr *);
 void    print_host(struct pf_addr *, u_int16_t p, sa_family_t, int);
 void    print_seq(struct pfctl_state_peer *);
 void    print_state(struct pfctl_state *, int);
-int     unmask(struct pf_addr *, sa_family_t);
 
 int     pfctl_cmdline_symset(char *);
 int     pfctl_add_trans(struct pfr_buffer *, int, const char *);
diff --git a/sbin/pfctl/pfctl_optimize.c b/sbin/pfctl/pfctl_optimize.c
index b4ffcbebb1bb..b58bace326c2 100644
--- a/sbin/pfctl/pfctl_optimize.c
+++ b/sbin/pfctl/pfctl_optimize.c
@@ -1267,7 +1267,7 @@ add_opt_table(struct pfctl *pf, struct pf_opt_tbl **tbl, 
sa_family_t af,
 #ifdef OPT_DEBUG
        DEBUG("<%s> adding %s/%d", (*tbl)->pt_name, inet_ntop(af,
            &node_host.addr.v.a.addr, buf, sizeof(buf)),
-           unmask(&node_host.addr.v.a.mask, af));
+           unmask(&node_host.addr.v.a.mask));
 #endif /* OPT_DEBUG */
 
        if (append_addr_host((*tbl)->pt_buf, &node_host, 0, 0)) {
@@ -1602,8 +1602,8 @@ exclude_supersets(struct pfctl_rule *super, struct 
pfctl_rule *sub)
            sub->src.addr.type == PF_ADDR_ADDRMASK &&
            super->src.neg == sub->src.neg &&
            super->af == sub->af &&
-           unmask(&super->src.addr.v.a.mask, super->af) <
-           unmask(&sub->src.addr.v.a.mask, sub->af) &&
+           unmask(&super->src.addr.v.a.mask) <
+           unmask(&sub->src.addr.v.a.mask) &&
            super->src.addr.v.a.addr.addr32[0] ==
            (sub->src.addr.v.a.addr.addr32[0] &
            super->src.addr.v.a.mask.addr32[0]) &&
@@ -1630,8 +1630,8 @@ exclude_supersets(struct pfctl_rule *super, struct 
pfctl_rule *sub)
            sub->dst.addr.type == PF_ADDR_ADDRMASK &&
            super->dst.neg == sub->dst.neg &&
            super->af == sub->af &&
-           unmask(&super->dst.addr.v.a.mask, super->af) <
-           unmask(&sub->dst.addr.v.a.mask, sub->af) &&
+           unmask(&super->dst.addr.v.a.mask) <
+           unmask(&sub->dst.addr.v.a.mask) &&
            super->dst.addr.v.a.addr.addr32[0] ==
            (sub->dst.addr.v.a.addr.addr32[0] &
            super->dst.addr.v.a.mask.addr32[0]) &&
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index 439c75b7c98f..401404865986 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1367,7 +1367,7 @@ check_netmask(struct node_host *h, sa_family_t af)
                if (af == AF_INET &&
                    (m->addr32[1] || m->addr32[2] || m->addr32[3])) {
                        fprintf(stderr, "netmask %u invalid for IPv4 address\n",
-                           unmask(m, AF_INET6));
+                           unmask(m));
                        return (1);
                }
        }
@@ -1392,7 +1392,7 @@ gen_dynnode(struct node_host *h, sa_family_t af)
 
        /* fix up netmask */
        m = &n->addr.v.a.mask;
-       if (af == AF_INET && unmask(m, AF_INET6) > 32)
+       if (af == AF_INET && unmask(m) > 32)
                set_ipmask(n, 32);
 
        return (n);
@@ -1755,7 +1755,7 @@ ifa_lookup(char *ifa_name, int flags)
                        memcpy(&n->addr.v.a.addr, &p->addr.v.a.addr,
                            sizeof(struct pf_addr));
                if (flags & PFI_AFLAG_NETWORK)
-                       set_ipmask(n, unmask(&p->addr.v.a.mask, n->af));
+                       set_ipmask(n, unmask(&p->addr.v.a.mask));
                else {
                        if (n->af == AF_INET &&
                            p->ifa_flags & IFF_LOOPBACK &&
@@ -2055,7 +2055,7 @@ append_addr_host(struct pfr_buffer *b, struct node_host 
*n, int test, int not)
                bzero(&addr, sizeof(addr));
                addr.pfra_not = n->not ^ not;
                addr.pfra_af = n->af;
-               addr.pfra_net = unmask(&n->addr.v.a.mask, n->af);
+               addr.pfra_net = unmask(&n->addr.v.a.mask);
                switch (n->af) {
                case AF_INET:
                        addr.pfra_ip4addr.s_addr = n->addr.v.a.addr.addr32[0];
diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h
index 8ab331561c7d..91c0f655e008 100644
--- a/sbin/pfctl/pfctl_parser.h
+++ b/sbin/pfctl/pfctl_parser.h
@@ -363,7 +363,7 @@ extern const struct pf_timeout pf_timeouts[];
 
 void                    set_ipmask(struct node_host *, int);
 int                     check_netmask(struct node_host *, sa_family_t);
-int                     unmask(struct pf_addr *, sa_family_t);
+int                     unmask(struct pf_addr *);
 struct node_host       *gen_dynnode(struct node_host *, sa_family_t);
 void                    ifa_load(void);
 unsigned int            ifa_nametoindex(const char *);

Reply via email to