diff --git a/src/solaris/native/java/net/NetworkInterface.c b/src/solaris/native/java/net/NetworkInterface.c index f887bbc6319b91321130c0f3a258372f5912c9e0..68633db5a18fedc5caa1c5186a44d8faccf8585b 100644 --- a/src/solaris/native/java/net/NetworkInterface.c +++ b/src/solaris/native/java/net/NetworkInterface.c @@ -658,9 +658,9 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs) { if (ia2Obj) { setInetAddress_addr(env, ia2Obj, htonl(((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr)); (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj); - (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask); } } + (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask); (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj); } } @@ -887,15 +887,12 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, addrP->mask = prefix; addrP->next = 0; if (family == AF_INET) { - /* - * Deal with broadcast addr & subnet mask - */ + // Deal with broadcast addr & subnet mask struct sockaddr * brdcast_to = (struct sockaddr *) ((char *) addrP + sizeof(netaddr) + addr_size); addrP->brdcast = getBroadcast(env, sock, name, brdcast_to ); - if (addrP->brdcast && (mask = getSubnet(env, sock, name)) != -1) { + if ((mask = getSubnet(env, sock, name)) != -1) addrP->mask = mask; - } } /** diff --git a/test/java/net/InterfaceAddress/NetworkPrefixLength.java b/test/java/net/InterfaceAddress/NetworkPrefixLength.java index 211086e73988ed3bb2607579dcec3ec92a3b58e2..448973eb03c252264af8f873c07db4d5d0fa7971 100644 --- a/test/java/net/InterfaceAddress/NetworkPrefixLength.java +++ b/test/java/net/InterfaceAddress/NetworkPrefixLength.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 6707289 + * @bug 6707289 7107883 * @summary InterfaceAddress.getNetworkPrefixLength() does not conform to Javadoc */ @@ -47,6 +47,14 @@ public class NetworkPrefixLength { passed = false; debug(nic.getName(), iaddr); } + InetAddress ia = iaddr.getAddress(); + if (ia.isLoopbackAddress() && ia instanceof Inet4Address) { + // assumption: prefix length will always be 8 + if (iaddr.getNetworkPrefixLength() != 8) { + out.println("Expected prefix of 8, got " + iaddr); + passed = false; + } + } } }