summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2003-04-18 05:26:14 +0000
committerJason Wright <jason@cvs.openbsd.org>2003-04-18 05:26:14 +0000
commit403edb5c18a7a15a126fd917400bc794c694359c (patch)
tree0c01291c98ff23d1f358d8f879f1b69bf66a63c5 /sys/net
parent6c5a3cfa5a4f4eb081abb1b3d4326c17054b8b1d (diff)
Add code to set the TUN_* flags for INET6 addresses too. This allows a
tun with ipv6 only to actually send/recv packets. itojun "looks ok to me" (after helping correct several iterations =)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_tun.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 6ff8d974943..62046c91162 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.45 2003/01/07 09:00:34 kjc Exp $ */
+/* $OpenBSD: if_tun.c,v 1.46 2003/04/18 05:26:13 jason Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -299,6 +299,23 @@ tuninit(tp)
tp->tun_flags &= ~TUN_BRDADDR;
}
#endif
+#ifdef INET6
+ if (ifa->ifa_addr->sa_family == AF_INET6) {
+ struct sockaddr_in6 *sin;
+
+ sin = (struct sockaddr_in6 *)ifa->ifa_addr;
+ if (!IN6_IS_ADDR_UNSPECIFIED(&sin->sin6_addr))
+ tp->tun_flags |= TUN_IASET;
+
+ if (ifp->if_flags & IFF_POINTOPOINT) {
+ sin = (struct sockaddr_in6 *)ifa->ifa_dstaddr;
+ if (sin &&
+ !IN6_IS_ADDR_UNSPECIFIED(&sin->sin6_addr))
+ tp->tun_flags |= TUN_DSTADDR;
+ } else
+ tp->tun_flags &= ~TUN_DSTADDR;
+ }
+#endif /* INET6 */
}
return 0;