summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-09-20 19:56:02 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-09-20 19:56:02 +0000
commitac6b68bea9d8dd94f4505e8aac4f55d84e0d59aa (patch)
tree45e7c5cc794a176a6e44bc0ee9d75808e7ee0274
parentaa901d694c8e9153b427a0c438e25eb587bfff70 (diff)
pf_routable(), used for the no-route keyword, was a v4 only implementation,
and behaved incorrectly when used with v6. impliment the v6 case too. ok canacar mcbride
-rw-r--r--sys/net/pf.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c
index ac07334887e..6d09c6b9598 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.458 2004/09/17 21:49:15 mcbride Exp $ */
+/* $OpenBSD: pf.c,v 1.459 2004/09/20 19:56:01 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -4927,22 +4927,41 @@ int
pf_routable(struct pf_addr *addr, sa_family_t af)
{
struct sockaddr_in *dst;
+#ifdef INET6
+ struct sockaddr_in6 *dst6;
+ struct route_in6 ro;
+#else
struct route ro;
- int ret = 0;
+#endif
bzero(&ro, sizeof(ro));
- dst = satosin(&ro.ro_dst);
- dst->sin_family = af;
- dst->sin_len = sizeof(*dst);
- dst->sin_addr = addr->v4;
- rtalloc_noclone(&ro, NO_CLONING);
+ switch (af) {
+ case AF_INET:
+ dst = satosin(&ro.ro_dst);
+ dst->sin_family = AF_INET;
+ dst->sin_len = sizeof(*dst);
+ dst->sin_addr = addr->v4;
+ break;
+#ifdef INET6
+ case AF_INET6:
+ dst6 = (struct sockaddr_in6 *)&ro.ro_dst;
+ dst6->sin6_family = AF_INET6;
+ dst6->sin6_len = sizeof(*dst6);
+ dst6->sin6_addr = addr->v6;
+ break;
+#endif /* INET6 */
+ default:
+ return (0);
+ }
+
+ rtalloc_noclone((struct route *)&ro, NO_CLONING);
if (ro.ro_rt != NULL) {
- ret = 1;
RTFREE(ro.ro_rt);
+ return (1);
}
- return (ret);
+ return (0);
}
#ifdef INET