8048212: Two tests failed with "java.net.SocketException: Bad protocol option" on Windows after 8029607
authormichaelm
Mon, 07 Jul 2014 12:42:14 +0100
changeset 25388 65f81ea02187
parent 25387 7a8733b181f7
child 25389 6f994d9e1b57
8048212: Two tests failed with "java.net.SocketException: Bad protocol option" on Windows after 8029607 Reviewed-by: alanb
jdk/src/windows/native/java/net/net_util_md.c
jdk/src/windows/native/sun/nio/ch/Net.c
--- a/jdk/src/windows/native/java/net/net_util_md.c	Sun Jul 06 20:12:44 2014 -0400
+++ b/jdk/src/windows/native/java/net/net_util_md.c	Mon Jul 07 12:42:14 2014 +0100
@@ -443,6 +443,13 @@
 {
     int rv;
 
+    if (level == IPPROTO_IPV6 && optname == IPV6_TCLASS) {
+        int *intopt = (int *)optval;
+        *intopt = 0;
+        *optlen = sizeof(*intopt);
+        return 0;
+    }
+
     rv = getsockopt(s, level, optname, optval, optlen);
 
 
--- a/jdk/src/windows/native/sun/nio/ch/Net.c	Sun Jul 06 20:12:44 2014 -0400
+++ b/jdk/src/windows/native/sun/nio/ch/Net.c	Mon Jul 07 12:42:14 2014 +0100
@@ -295,9 +295,9 @@
     /**
      * HACK: IP_TOS is deprecated on Windows and querying the option
      * returns a protocol error. NET_GetSockOpt handles this and uses
-     * a fallback mechanism.
+     * a fallback mechanism. Same applies to IPV6_TCLASS
      */
-    if (level == IPPROTO_IP && opt == IP_TOS) {
+    if ((level == IPPROTO_IP && opt == IP_TOS) || (level == IPPROTO_IPV6 && opt == IPV6_TCLASS)) {
         mayNeedConversion = JNI_TRUE;
     }
 
@@ -340,6 +340,11 @@
         arglen = sizeof(arg);
     }
 
+    if (level == IPPROTO_IPV6 && opt == IPV6_TCLASS) {
+        /* No op */
+        return;
+    }
+
     if (mayNeedConversion) {
         n = NET_SetSockOpt(fdval(env, fdo), level, opt, parg, arglen);
     } else {