summaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2001-01-06 16:07:46 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2001-01-06 16:07:46 +0000
commit11576f3b84aa808f98ae31158505c13f61a8d3c4 (patch)
treec9d9c05fc8095078c76e617b435ee0f9ce5d2c2c /sys/netinet6
parent0edfe847c9bb3c2d0778b85ed8446210e92148cf (diff)
prohibited binding to an anycast, notready, or detached IPv6 address.
sync with kame 1.46 -> 1.47
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6_pcb.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 9fcdff824f8..fcfecb8ee3f 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_pcb.c,v 1.21 2000/12/21 00:54:11 itojun Exp $ */
+/* $OpenBSD: in6_pcb.c,v 1.22 2001/01/06 16:07:45 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -203,6 +203,30 @@ in6_pcbbind(inp, nam)
*/
if (so->so_options & SO_REUSEADDR)
reuseport = SO_REUSEADDR | SO_REUSEPORT;
+ } else if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
+ struct ifaddr *ia = NULL;
+
+ sin6->sin6_port = 0; /*
+ * Yechhhh, because of upcoming
+ * call to ifa_ifwithaddr(), which
+ * does bcmp's over the PORTS as
+ * well. (What about flow?)
+ */
+ sin6->sin6_flowinfo = 0;
+ if ((ia = ifa_ifwithaddr((struct sockaddr *)sin6))
+ == NULL)
+ return EADDRNOTAVAIL;
+
+ /*
+ * XXX: bind to an anycast address might accidentally
+ * cause sending a packet with anycast source address.
+ * We should allow to bind to a deprecated address, since
+ * the application dare to use it.
+ */
+ if (ia &&
+ ((struct in6_ifaddr *)ia)->ia6_flags &
+ (IN6_IFF_ANYCAST|IN6_IFF_NOTREADY|IN6_IFF_DETACHED))
+ return(EADDRNOTAVAIL);
}
#if 0 /* we don't support it */
else if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {