提交 f51218f1 编写于 作者: C chegar

7107883: getNetworkPrefixLength() does not return correct prefix length

Reviewed-by: alanb, michaelm
上级 14cf8bf6
......@@ -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;
}
}
/**
......
......@@ -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;
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册