changeset 2578:a7f8f269f741

6967937: Scope id no longer being set after 6931566 Reviewed-by: alanb, dsamersoff
author chegar
date Mon, 12 Jul 2010 18:13:40 +0100
parents da8526047e5f
children 1371a2d5f3a8
files src/solaris/native/java/net/NetworkInterface.c test/java/net/Inet6Address/B6214234.java
diffstat 2 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/net/NetworkInterface.c	Fri Jul 09 18:55:25 2010 -0700
+++ b/src/solaris/native/java/net/NetworkInterface.c	Mon Jul 12 18:13:40 2010 +0100
@@ -129,7 +129,7 @@
 
 static struct  sockaddr *getBroadcast(JNIEnv *env, int sock, const char *name, struct sockaddr *brdcast_store);
 static short   getSubnet(JNIEnv *env, int sock, const char *ifname);
-static int     getIndex(JNIEnv *env, int sock, const char *ifname);
+static int     getIndex(int sock, const char *ifname);
 
 static int     getFlags(JNIEnv *env, int sock, const char *ifname);
 static int     getMacAddress(JNIEnv *env, int sock,  const char* ifname, const struct in_addr* addr, unsigned char *buf);
@@ -911,7 +911,7 @@
          CHECKED_MALLOC3(currif, netif *, sizeof(netif)+IFNAMSIZ );
          currif->name = (char *) currif+sizeof(netif);
          strcpy(currif->name, name);
-         currif->index = getIndex(env,sock,name);
+         currif->index = getIndex(sock, name);
          currif->addr = NULL;
          currif->childs = NULL;
          currif->virtual = isVirtual;
@@ -946,7 +946,7 @@
             CHECKED_MALLOC3(currif, netif *, sizeof(netif)+ IFNAMSIZ );
             currif->name = (char *) currif + sizeof(netif);
             strcpy(currif->name, vname);
-            currif->index = getIndex(env,sock,vname);
+            currif->index = getIndex(sock, vname);
             currif->addr = NULL;
            /* Need to duplicate the addr entry? */
             currif->virtual = 1;
@@ -1133,7 +1133,7 @@
 #endif
 
 
-static int getIndex(JNIEnv *env, int sock, const char *name){
+static int getIndex(int sock, const char *name){
      /*
       * Try to get the interface index
       * (Not supported on Solaris 2.6 or 7)
@@ -1390,6 +1390,13 @@
             continue;
         }
 
+#ifdef AF_INET6
+        if (ifr->lifr_addr.ss_family == AF_INET6) {
+            struct sockaddr_in6 *s6= (struct sockaddr_in6 *)&(ifr->lifr_addr);
+            s6->sin6_scope_id = getIndex(sock, ifr->lifr_name);
+        }
+#endif
+
         /* add to the list */
         ifs = addif(env, sock,ifr->lifr_name, ifs, (struct sockaddr *)&(ifr->lifr_addr),family, (short) ifr->lifr_addrlen);
 
@@ -1407,7 +1414,7 @@
     return ifs;
 }
 
-static int getIndex(JNIEnv *env, int sock, const char *name){
+static int getIndex(int sock, const char *name){
    /*
     * Try to get the interface index
     * (Not supported on Solaris 2.6 or 7)
--- a/test/java/net/Inet6Address/B6214234.java	Fri Jul 09 18:55:25 2010 -0700
+++ b/test/java/net/Inet6Address/B6214234.java	Mon Jul 12 18:13:40 2010 +0100
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 6214234
+ * @bug 6214234 6967937
  * @summary IPv6 scope_id for local addresses not set in Solaris 10
  */
 
@@ -51,6 +51,7 @@
             return;
         }
         if (addr.getScopeId() == 0) {
+            System.out.println("addr: "+ addr);
             throw new RuntimeException ("Non zero scope_id expected");
         }
     }