svn commit: r296984 - head/sys/netinet6
Andrey V. Elsukov
ae at FreeBSD.org
Thu Mar 17 10:59:31 UTC 2016
Author: ae
Date: Thu Mar 17 10:59:30 2016
New Revision: 296984
URL: https://svnweb.freebsd.org/changeset/base/296984
Log:
Change in6_selectsrc() to allow usage of non-local IPv6 addresses in
IPV6_PKTINFO ancillary data when IPV6_BINDANY socket option is set.
Submitted by: n_hibma
MFC after: 2 weeks
Modified:
head/sys/netinet6/in6_src.c
Modified: head/sys/netinet6/in6_src.c
==============================================================================
--- head/sys/netinet6/in6_src.c Thu Mar 17 09:04:07 2016 (r296983)
+++ head/sys/netinet6/in6_src.c Thu Mar 17 10:59:30 2016 (r296984)
@@ -256,19 +256,27 @@ in6_selectsrc(uint32_t fibnum, struct so
(inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
return (error);
- ia6 = (struct in6_ifaddr *)ifa_ifwithaddr(
- (struct sockaddr *)&srcsock);
- if (ia6 == NULL ||
- (ia6->ia6_flags & (IN6_IFF_ANYCAST | IN6_IFF_NOTREADY))) {
- if (ia6 != NULL)
- ifa_free(&ia6->ia_ifa);
- return (EADDRNOTAVAIL);
- }
+ /*
+ * If IPV6_BINDANY socket option is set, we allow to specify
+ * non local addresses as source address in IPV6_PKTINFO
+ * ancillary data.
+ */
+ if ((inp->inp_flags & INP_BINDANY) == 0) {
+ ia6 = (struct in6_ifaddr *)ifa_ifwithaddr(
+ (struct sockaddr *)&srcsock);
+ if (ia6 == NULL || (ia6->ia6_flags & (IN6_IFF_ANYCAST |
+ IN6_IFF_NOTREADY))) {
+ if (ia6 != NULL)
+ ifa_free(&ia6->ia_ifa);
+ return (EADDRNOTAVAIL);
+ }
+ bcopy(&ia6->ia_addr.sin6_addr, srcp, sizeof(*srcp));
+ ifa_free(&ia6->ia_ifa);
+ } else
+ bcopy(&srcsock.sin6_addr, srcp, sizeof(*srcp));
pi->ipi6_addr = srcsock.sin6_addr; /* XXX: this overrides pi */
if (ifpp)
*ifpp = ifp;
- bcopy(&ia6->ia_addr.sin6_addr, srcp, sizeof(*srcp));
- ifa_free(&ia6->ia_ifa);
return (0);
}
More information about the svn-src-head
mailing list