From f0bb6ca5dd99693590fea0d9be3547a3318048b5 Mon Sep 17 00:00:00 2001 From: kn Date: Thu, 6 Sep 2018 15:07:33 +0000 Subject: [PATCH] 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 --- sbin/pfctl/parse.y | 8 ++++---- sbin/pfctl/pf_print_state.c | 6 +++--- sbin/pfctl/pfctl.h | 3 +-- sbin/pfctl/pfctl_optimize.c | 12 ++++++------ sbin/pfctl/pfctl_parser.c | 10 +++++----- sbin/pfctl/pfctl_parser.h | 4 ++-- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 7792c66f3dc..9c1a6293709 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.682 2018/07/16 08:29:08 kn Exp $ */ +/* $OpenBSD: parse.y,v 1.683 2018/09/06 15:07:33 kn Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -2663,9 +2663,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) { @@ -4192,7 +4192,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(&h->addr.v.a.mask, af); + bits = unmask(&h->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 0516796c660..4ac6af15f5e 100644 --- a/sbin/pfctl/pf_print_state.c +++ b/sbin/pfctl/pf_print_state.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_print_state.c,v 1.66 2018/09/06 14:46:36 kn Exp $ */ +/* $OpenBSD: pf_print_state.c,v 1.67 2018/09/06 15:07:33 kn Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -111,7 +111,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); @@ -356,7 +356,7 @@ print_state(struct pfsync_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 7e6a967fe15..c810eadb2a0 100644 --- a/sbin/pfctl/pfctl.h +++ b/sbin/pfctl/pfctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.h,v 1.56 2018/07/24 09:48:04 kn Exp $ */ +/* $OpenBSD: pfctl.h,v 1.57 2018/09/06 15:07:33 kn Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -96,7 +96,6 @@ void print_addr_str(sa_family_t, struct pf_addr *); void print_host(struct pf_addr *, u_int16_t p, sa_family_t, u_int16_t, const char *, int); void print_seq(struct pfsync_state_peer *); void print_state(struct pfsync_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 15e26d7002e..ae3e92d4833 100644 --- a/sbin/pfctl/pfctl_optimize.c +++ b/sbin/pfctl/pfctl_optimize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_optimize.c,v 1.38 2017/11/25 22:20:06 sashan Exp $ */ +/* $OpenBSD: pfctl_optimize.c,v 1.39 2018/09/06 15:07:33 kn Exp $ */ /* * Copyright (c) 2004 Mike Frantzen @@ -1235,7 +1235,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)) { @@ -1559,8 +1559,8 @@ exclude_supersets(struct pf_rule *super, struct pf_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]) && @@ -1587,8 +1587,8 @@ exclude_supersets(struct pf_rule *super, struct pf_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 58fb63577c7..fe9989a3dbb 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.c,v 1.329 2018/09/05 21:16:26 kn Exp $ */ +/* $OpenBSD: pfctl_parser.c,v 1.330 2018/09/06 15:07:33 kn Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -1301,7 +1301,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); } } @@ -1326,7 +1326,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)) set_ipmask(n, 32); return (n); @@ -1582,7 +1582,7 @@ ifa_lookup(const 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 && @@ -1930,7 +1930,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); if (n->ifname) { if (strlcpy(addr.pfra_ifname, n->ifname, sizeof(addr.pfra_ifname)) >= sizeof(addr.pfra_ifname)) diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 16ebc28b593..3c5d6c31068 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.h,v 1.111 2018/09/05 21:16:26 kn Exp $ */ +/* $OpenBSD: pfctl_parser.h,v 1.112 2018/09/06 15:07:34 kn Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -285,7 +285,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 *); -- 2.20.1