svn commit: r353552 - stable/12/sys/netinet6
Mark Johnston
markj at FreeBSD.org
Tue Oct 15 14:18:02 UTC 2019
Author: markj
Date: Tue Oct 15 14:18:01 2019
New Revision: 353552
URL: https://svnweb.freebsd.org/changeset/base/353552
Log:
MFC r353295:
Improve locking in the IPV6_V6ONLY socket option handler.
Modified:
stable/12/sys/netinet6/ip6_output.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/netinet6/ip6_output.c
==============================================================================
--- stable/12/sys/netinet6/ip6_output.c Tue Oct 15 14:13:01 2019 (r353551)
+++ stable/12/sys/netinet6/ip6_output.c Tue Oct 15 14:18:01 2019 (r353552)
@@ -1717,21 +1717,24 @@ do { \
#endif
case IPV6_V6ONLY:
- /*
- * make setsockopt(IPV6_V6ONLY)
- * available only prior to bind(2).
- * see ipng mailing list, Jun 22 2001.
- */
+ INP_WLOCK(inp);
if (in6p->inp_lport ||
!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
+ /*
+ * The socket is already bound.
+ */
+ INP_WUNLOCK(inp);
error = EINVAL;
break;
}
- OPTSET(IN6P_IPV6_V6ONLY);
- if (optval)
+ if (optval) {
+ inp->inp_flags |= IN6P_IPV6_V6ONLY;
in6p->inp_vflag &= ~INP_IPV4;
- else
+ } else {
+ inp->inp_flags &= ~IN6P_IPV6_V6ONLY;
in6p->inp_vflag |= INP_IPV4;
+ }
+ INP_WUNLOCK(inp);
break;
case IPV6_RECVTCLASS:
/* cannot mix with RFC2292 XXX */
More information about the svn-src-all
mailing list