diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2015-07-20 01:18:34 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2015-07-20 01:18:34 +0000 |
commit | e093d7f46b3cdce4bb5f793c435692e3eee82bbb (patch) | |
tree | 1aca3ff03e8431208dcaa67aa2c221650d8e328d /sys | |
parent | 2a83ec1224b6c00903840a97139bbc603bb3063c (diff) |
INET6 is here to stay, so stop hauling around never-compiled code
to optimize for an INET-only kernel, as well as the fantasy unicorn
INET6-only kernel. (INET-only kernel still works)
prompted by deraadt
ok bluhm sashan
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/pf.c | 18 | ||||
-rw-r--r-- | sys/net/pfvar.h | 93 |
2 files changed, 14 insertions, 97 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c index 2c68f9f5738..0a739c769bd 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.932 2015/07/19 23:13:58 sashan Exp $ */ +/* $OpenBSD: pf.c,v 1.933 2015/07/20 01:18:33 mcbride Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -349,7 +349,6 @@ pf_src_compare(struct pf_src_node *a, struct pf_src_node *b) return (0); } -#ifdef INET6 void pf_addrcpy(struct pf_addr *dst, struct pf_addr *src, sa_family_t af) { @@ -357,15 +356,18 @@ pf_addrcpy(struct pf_addr *dst, struct pf_addr *src, sa_family_t af) case AF_INET: dst->addr32[0] = src->addr32[0]; break; +#ifdef INET6 case AF_INET6: dst->addr32[0] = src->addr32[0]; dst->addr32[1] = src->addr32[1]; dst->addr32[2] = src->addr32[2]; dst->addr32[3] = src->addr32[3]; break; +#endif /* INET6 */ + default: + unhandled_af(af); } } -#endif /* INET6 */ void pf_init_threshold(struct pf_threshold *threshold, @@ -2682,7 +2684,6 @@ pf_step_out_of_anchor(int *depth, struct pf_ruleset **rs, return (quick); } -#ifdef INET6 void pf_poolmask(struct pf_addr *naddr, struct pf_addr *raddr, struct pf_addr *rmask, struct pf_addr *saddr, sa_family_t af) @@ -2692,6 +2693,7 @@ pf_poolmask(struct pf_addr *naddr, struct pf_addr *raddr, naddr->addr32[0] = (raddr->addr32[0] & rmask->addr32[0]) | ((rmask->addr32[0] ^ 0xffffffff ) & saddr->addr32[0]); break; +#ifdef INET6 case AF_INET6: naddr->addr32[0] = (raddr->addr32[0] & rmask->addr32[0]) | ((rmask->addr32[0] ^ 0xffffffff ) & saddr->addr32[0]); @@ -2702,6 +2704,9 @@ pf_poolmask(struct pf_addr *naddr, struct pf_addr *raddr, naddr->addr32[3] = (raddr->addr32[3] & rmask->addr32[3]) | ((rmask->addr32[3] ^ 0xffffffff ) & saddr->addr32[3]); break; +#endif /* INET6 */ + default: + unhandled_af(af); } } @@ -2712,6 +2717,7 @@ pf_addr_inc(struct pf_addr *addr, sa_family_t af) case AF_INET: addr->addr32[0] = htonl(ntohl(addr->addr32[0]) + 1); break; +#ifdef INET6 case AF_INET6: if (addr->addr32[3] == 0xffffffff) { addr->addr32[3] = 0; @@ -2731,9 +2737,11 @@ pf_addr_inc(struct pf_addr *addr, sa_family_t af) addr->addr32[3] = htonl(ntohl(addr->addr32[3]) + 1); break; +#endif /* INET6 */ + default: + unhandled_af(af); } } -#endif /* INET6 */ int pf_socket_lookup(struct pf_pdesc *pd) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index a6b7ab0f124..529791d8936 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfvar.h,v 1.418 2015/07/19 01:58:19 sashan Exp $ */ +/* $OpenBSD: pfvar.h,v 1.419 2015/07/20 01:18:33 mcbride Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -225,27 +225,6 @@ struct pfi_dynaddr { * Address manipulation macros */ -#ifdef _KERNEL -#ifndef INET6 -#define PF_INET_ONLY -#endif /* ! INET6 */ - -#ifdef INET6 -#endif /* INET6 */ - -#ifdef INET6 -#define PF_INET_INET6 -#endif /* INET6 */ - -#else - -#define PF_INET_INET6 - -#endif /* _KERNEL */ - -/* Both IPv4 and IPv6 */ -#ifdef PF_INET_INET6 - #define PF_AEQ(a, b, c) \ ((c == AF_INET && (a)->addr32[0] == (b)->addr32[0]) || \ (c == AF_INET6 && \ @@ -280,76 +259,6 @@ struct pfi_dynaddr { #define PF_POOLMASK(a, b, c, d, f) \ pf_poolmask(a, b, c, d, f) -#else - -/* Just IPv6 */ - -#ifdef PF_INET6_ONLY - -#define PF_AEQ(a, b, c) \ - ((a)->addr32[3] == (b)->addr32[3] && \ - (a)->addr32[2] == (b)->addr32[2] && \ - (a)->addr32[1] == (b)->addr32[1] && \ - (a)->addr32[0] == (b)->addr32[0]) \ - -#define PF_ANEQ(a, b, c) \ - ((a)->addr32[3] != (b)->addr32[3] || \ - (a)->addr32[2] != (b)->addr32[2] || \ - (a)->addr32[1] != (b)->addr32[1] || \ - (a)->addr32[0] != (b)->addr32[0]) \ - -#define PF_AZERO(a, c) \ - (!(a)->addr32[0] && \ - !(a)->addr32[1] && \ - !(a)->addr32[2] && \ - !(a)->addr32[3] ) \ - -#define PF_MATCHA(n, a, m, b, f) \ - pf_match_addr(n, a, m, b, f) - -#define PF_ACPY(a, b, f) \ - pf_addrcpy(a, b, f) - -#define PF_AINC(a, f) \ - pf_addr_inc(a, f) - -#define PF_POOLMASK(a, b, c, d, f) \ - pf_poolmask(a, b, c, d, f) - -#else - -/* Just IPv4 */ -#ifdef PF_INET_ONLY - -#define PF_AEQ(a, b, c) \ - ((a)->addr32[0] == (b)->addr32[0]) - -#define PF_ANEQ(a, b, c) \ - ((a)->addr32[0] != (b)->addr32[0]) - -#define PF_AZERO(a, c) \ - (!(a)->addr32[0]) - -#define PF_MATCHA(n, a, m, b, f) \ - pf_match_addr(n, a, m, b, f) - -#define PF_ACPY(a, b, f) \ - (a)->v4.s_addr = (b)->v4.s_addr - -#define PF_AINC(a, f) \ - do { \ - (a)->addr32[0] = htonl(ntohl((a)->addr32[0]) + 1); \ - } while (0) - -#define PF_POOLMASK(a, b, c, d, f) \ - do { \ - (a)->addr32[0] = ((b)->addr32[0] & (c)->addr32[0]) | \ - (((c)->addr32[0] ^ 0xffffffff ) & (d)->addr32[0]); \ - } while (0) - -#endif /* PF_INET_ONLY */ -#endif /* PF_INET6_ONLY */ -#endif /* PF_INET_INET6 */ #define PF_MISMATCHAW(aw, x, af, neg, ifp, rtid) \ ( \ |