diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2009-06-08 00:50:31 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2009-06-08 00:50:31 +0000 |
commit | 2a1aa8c953716703ff203fa59e61bccab2fcf54d (patch) | |
tree | e3d574e93148041b27b0c5cf94e86f5af15761a7 | |
parent | ad9fb623e2cf4d4e368b46623597799672029cab (diff) |
unfuck PF_AEQ PF_ANEQ PF_AZERO macos that got fucked when v6 support
was added in 2001. yes i got bitten by inet6 shit again.
in the ANEQ case, if af == AF_INET, (a)->addr32[0] != (b)->addr32[0]
is false when the adresses ARE equal. now it goes right in the
intended-for-v6 case and starts to compare the other addr32 fields -
in the v4 case I have garbage in them, so it reports all v4 as different
when they are in fact the same. fix by adding explicit af == INET6 test
before going on to compare the rest.
found the really hard way (many hours wasted, thought the bug was in my
new code) by me. ok sthen markus claudio
-rw-r--r-- | sys/net/pfvar.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index d60d52983c4..0ba6edbb1cf 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfvar.h,v 1.286 2009/05/18 20:37:13 bluhm Exp $ */ +/* $OpenBSD: pfvar.h,v 1.287 2009/06/08 00:50:30 henning Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -220,21 +220,24 @@ struct pfi_dynaddr { #define PF_AEQ(a, b, c) \ ((c == AF_INET && (a)->addr32[0] == (b)->addr32[0]) || \ - ((a)->addr32[3] == (b)->addr32[3] && \ + (c == AF_INET6 && \ + (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) \ ((c == AF_INET && (a)->addr32[0] != (b)->addr32[0]) || \ + (c == AF_INET6 && \ ((a)->addr32[3] != (b)->addr32[3] || \ (a)->addr32[2] != (b)->addr32[2] || \ (a)->addr32[1] != (b)->addr32[1] || \ - (a)->addr32[0] != (b)->addr32[0])) \ + (a)->addr32[0] != (b)->addr32[0]))) \ #define PF_AZERO(a, c) \ ((c == AF_INET && !(a)->addr32[0]) || \ - (!(a)->addr32[0] && !(a)->addr32[1] && \ + (c == AF_INET6 && \ + !(a)->addr32[0] && !(a)->addr32[1] && \ !(a)->addr32[2] && !(a)->addr32[3] )) \ #define PF_MATCHA(n, a, m, b, f) \ |