diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2016-10-25 06:26:04 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2016-10-25 06:26:04 +0000 |
commit | 9f52a893878b4ecee5f8b45de43395dccb39a26c (patch) | |
tree | 4ba9350bcb0d526a5522a6c9fc808fe19fe5711e /sys | |
parent | 0711c8b9635c47ced6e3e598c8a4046314e1d681 (diff) |
Fix bind(2)ing link local addresses to raw sockets by calling
in6_pcbaddrisavail() which does all the checking for us instead of
hand rolling half of it.
Input & OK bluhm@
bluhm@ also points out that this relaxes the check for valid addresses
a bit, deprecated addresses become valid for raw sockets. This should
be fine, it brings raw sockets in line with udp/tcp sockets and it
might be particularly interesting for debugging purposes.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet6/raw_ip6.c | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index d244d977709..c0a89af00ff 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.96 2016/09/19 18:09:09 tedu Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.97 2016/10/25 06:26:03 florian Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -640,7 +640,6 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, case PRU_BIND: { struct sockaddr_in6 *addr = mtod(nam, struct sockaddr_in6 *); - struct ifaddr *ifa = NULL; if (nam->m_len != sizeof(*addr)) { error = EINVAL; @@ -650,34 +649,10 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, error = EADDRNOTAVAIL; break; } - /* - * we don't support mapped address here, it would confuse - * users so reject it - */ - if (IN6_IS_ADDR_V4MAPPED(&addr->sin6_addr)) { - error = EADDRNOTAVAIL; - break; - } - /* - * Currently, ifa_ifwithaddr tends to fail for a link-local - * address, since it implicitly expects that the link ID - * for the address is embedded in the sin6_addr part. - * For now, we'd rather keep this "as is". We'll eventually fix - * this in a more natural way. - */ - if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr) && - !(so->so_options & SO_BINDANY) && - (ifa = ifa_ifwithaddr(sin6tosa(addr), - in6p->inp_rtableid)) == 0) { - error = EADDRNOTAVAIL; - break; - } - if (ifa && ifatoia6(ifa)->ia6_flags & - (IN6_IFF_ANYCAST|IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED| - IN6_IFF_DETACHED|IN6_IFF_DEPRECATED)) { - error = EADDRNOTAVAIL; + + if ((error = in6_pcbaddrisavail(in6p, addr, 0, p))) break; - } + in6p->inp_laddr6 = addr->sin6_addr; break; } |