提交 0b34da48 编写于 作者: C chegar

7193520: Removed references to Linux kernel version 2.2

Summary: Linux kernel version 2.2 isn't supported anymore.
Reviewed-by: chegar, dsamersoff, alanb
Contributed-by: NJohn Zavgren <john.zavgren@oracle.com>
上级 da9ef682
......@@ -48,11 +48,6 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
protected InetAddress connectedAddress = null;
private int connectedPort = -1;
/* cached socket options */
private int multicastInterface = 0;
private boolean loopbackMode = true;
private int ttl = -1;
private static final String os = AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("os.name")
);
......
......@@ -647,9 +647,10 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
#ifdef __linux__
if (errno != EINVAL && errno != EHOSTUNREACH)
/*
* On some Linuxes, when bound to the loopback interface, sendto
* will fail and errno will be set to EINVAL or EHOSTUNREACH.
* When that happens, don't throw an exception, just return false.
* On some Linux versions, when a socket is bound to the loopback
* interface, sendto will fail and errno will be set to
* EINVAL or EHOSTUNREACH. When that happens, don't throw an
* exception, just return false.
*/
#endif /*__linux__ */
NET_ThrowNew(env, errno, "Can't send ICMP packet");
......@@ -813,9 +814,10 @@ Java_java_net_Inet4AddressImpl_isReachable0(JNIEnv *env, jobject this,
case EINVAL:
case EHOSTUNREACH:
/*
* On some Linuxes, when bound to the loopback interface, connect
* will fail and errno will be set to EINVAL or EHOSTUNREACH.
* When that happens, don't throw an exception, just return false.
* On some Linux versions, when a socket is bound to the loopback
* interface, connect will fail and errno will be set to EINVAL
* or EHOSTUNREACH. When that happens, don't throw an exception,
* just return false.
*/
#endif /* __linux__ */
close(fd);
......
......@@ -336,13 +336,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
}
(*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
(jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
#ifdef __linux__
if (!kernelIsV22()) {
scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
}
#else
scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
#endif
if (scope != 0) { /* zero is default value, no need to set */
(*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
(*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
......@@ -507,8 +501,9 @@ ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
#ifdef __linux__
if (errno != EINVAL && errno != EHOSTUNREACH)
/*
* On some Linuxes, when bound to the loopback interface, sendto
* will fail and errno will be set to EINVAL or EHOSTUNREACH.
* On some Linux versions, when a socket is bound to the
* loopback interface, sendto will fail and errno will be
* set to EINVAL or EHOSTUNREACH.
* When that happens, don't throw an exception, just return false.
*/
#endif /*__linux__ */
......@@ -623,7 +618,7 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
* If we can create a RAW socket, then when can use the ICMP ECHO_REQUEST
* otherwise we'll try a tcp socket to the Echo port (7).
* Note that this is empiric, and not connecting could mean it's blocked
* or the echo servioe has been disabled.
* or the echo service has been disabled.
*/
fd = JVM_Socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
......@@ -680,9 +675,10 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
case EINVAL:
case EHOSTUNREACH:
/*
* On some Linuxes, when bound to the loopback interface, connect
* will fail and errno will be set to EINVAL or EHOSTUNREACH.
* When that happens, don't throw an exception, just return false.
* On some Linux versions, when a socket is bound to the
* loopback interface, connect will fail and errno will
* be set to EINVAL or EHOSTUNREACH. When that happens,
* don't throw an exception, just return false.
*/
#endif /* __linux__ */
close(fd);
......
......@@ -769,14 +769,14 @@ static netif *enumInterfaces(JNIEnv *env) {
return NULL;
}
/* return partial list if exception occure in the middle of process ???*/
/* return partial list if an exception occurs in the middle of process ???*/
/*
* If IPv6 is available then enumerate IPv6 addresses.
*/
#ifdef AF_INET6
/* User can disable ipv6 expicitly by -Djava.net.preferIPv4Stack=true,
/* User can disable ipv6 explicitly by -Djava.net.preferIPv4Stack=true,
* so we have to call ipv6_available()
*/
if (ipv6_available()) {
......@@ -887,7 +887,7 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct soc
addrP->next = 0;
if (family == AF_INET) {
/*
* Deal with brodcast 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 );
......@@ -898,7 +898,7 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct soc
}
/**
* Deal with virtual interface with colon notaion e.g. eth0:1
* Deal with virtual interface with colon notation e.g. eth0:1
*/
name_colonP = strchr(name, ':');
if (name_colonP != NULL) {
......@@ -1327,13 +1327,13 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname){
}
/**
* Solaris requires that we have IPv6 socket to query an
* interface without IPv4 address - check it here
* POSIX 1 require the kernell to return ENOTTY if the call is
* unappropriate for device e.g. NETMASK for device having IPv6
* only address but not all devices follows the standart so
* fallback on any error. It's not an ecology friendly but more
* reliable.
* Solaris requires that we have an IPv6 socket to query an
* interface without an IPv4 address - check it here.
* POSIX 1 require the kernel to return ENOTTY if the call is
* inappropriate for a device e.g. the NETMASK for a device having IPv6
* only address but not all devices follow the standard so
* fall back on any error. It's not an ecologically friendly gesture
* but more reliable.
*/
if (! alreadyV6 ){
......@@ -1359,7 +1359,7 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname){
/*
* Enumerates and returns all IPv4 interfaces
* (linux verison)
* (linux verision)
*/
static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
......
......@@ -128,7 +128,7 @@ static int getFD(JNIEnv *env, jobject this) {
/*
* The initroto function is called whenever PlainSocketImpl is
* loaded, to cache fieldIds for efficiency. This is called everytime
* loaded, to cache field IDs for efficiency. This is called every time
* the Java class is loaded.
*
* Class: java_net_PlainSocketImpl
......@@ -589,7 +589,7 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
/* set the address */
(*env)->SetObjectField(env, this, psi_addressID, iaObj);
/* intialize the local port */
/* initialize the local port */
if (localport == 0) {
/* Now that we're a connected socket, let's extract the port number
* that the system chose for us and store it in the Socket object.
......@@ -909,7 +909,7 @@ Java_java_net_PlainSocketImpl_socketSetOption(JNIEnv *env, jobject this,
}
/*
* SO_TIMEOUT is a no-op on Solaris/Linux
* SO_TIMEOUT is a NOOP on Solaris/Linux
*/
if (cmd == java_net_SocketOptions_SO_TIMEOUT) {
return;
......
......@@ -67,14 +67,14 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
jint fd, nread;
if (IS_NULL(fdObj)) {
/* should't this be a NullPointerException? -br */
/* shouldn't this be a NullPointerException? -br */
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
return -1;
} else {
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
/* Bug 4086704 - If the Socket associated with this file descriptor
* was closed (sysCloseFD), the the file descriptor is set to -1.
* was closed (sysCloseFD), then the file descriptor is set to -1.
*/
if (fd == -1) {
JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
......
......@@ -68,7 +68,7 @@ static int fdCount;
/*
* This limit applies if getlimit() returns unlimited.
* Unfortunately, this means if someone wants a higher limt
* Unfortunately, this means if someone wants a higher limit
* then they have to set an explicit limit, higher than this,
* which is probably counter-intuitive.
*/
......
......@@ -169,7 +169,7 @@ getParam(char *driver, char *param)
* for Solaris versions that do not support the ioctl() in getParam().
* Ugly, but only called once (for each sotype).
*
* As an optimisation, we make a guess using the default values for Solaris
* As an optimization, we make a guess using the default values for Solaris
* assuming they haven't been modified with ndd.
*/
......@@ -217,23 +217,7 @@ static int findMaxBuf(int fd, int opt, int sotype) {
#endif
#ifdef __linux__
static int kernelV22 = 0;
static int vinit = 0;
int kernelIsV22 () {
if (!vinit) {
struct utsname sysinfo;
if (uname(&sysinfo) == 0) {
sysinfo.release[3] = '\0';
if (strcmp(sysinfo.release, "2.2") == 0) {
kernelV22 = JNI_TRUE;
}
}
vinit = 1;
}
return kernelV22;
}
static int kernelV24 = 0;
static int vinit24 = 0;
......@@ -253,17 +237,11 @@ int kernelIsV24 () {
int getScopeID (struct sockaddr *him) {
struct sockaddr_in6 *hext = (struct sockaddr_in6 *)him;
if (kernelIsV22()) {
return 0;
}
return hext->sin6_scope_id;
}
int cmpScopeID (unsigned int scope, struct sockaddr *him) {
struct sockaddr_in6 *hext = (struct sockaddr_in6 *)him;
if (kernelIsV22()) {
return 1; /* scope is ignored for comparison in 2.2 kernel */
}
return hext->sin6_scope_id == scope;
}
......@@ -843,15 +821,14 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
* address needs to be routed via the loopback interface. In this case,
* we override the specified value with that of the loopback interface.
* If no cached value exists and no value was specified by user, then
* we try to determine a value ffrom the routing table. In all these
* we try to determine a value from the routing table. In all these
* cases the used value is cached for further use.
*/
#ifdef __linux__
if (IN6_IS_ADDR_LINKLOCAL(&(him6->sin6_addr))) {
int cached_scope_id = 0, scope_id = 0;
int old_kernel = kernelIsV22();
if (ia6_cachedscopeidID && !old_kernel) {
if (ia6_cachedscopeidID) {
cached_scope_id = (int)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID);
/* if cached value exists then use it. Otherwise, check
* if scope is set in the address.
......@@ -891,13 +868,11 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
* of sockaddr_in6.
*/
if (!old_kernel) {
struct sockaddr_in6 *him6 =
(struct sockaddr_in6 *)him;
him6->sin6_scope_id = cached_scope_id != 0 ?
cached_scope_id : scope_id;
*len = sizeof(struct sockaddr_in6);
}
struct sockaddr_in6 *him6 =
(struct sockaddr_in6 *)him;
him6->sin6_scope_id = cached_scope_id != 0 ?
cached_scope_id : scope_id;
*len = sizeof(struct sockaddr_in6);
}
#else
/* handle scope_id for solaris */
......@@ -1208,7 +1183,7 @@ int getDefaultIPv6Interface(struct in6_addr *target_addr) {
/*
* Wrapper for getsockopt system routine - does any necessary
* pre/post processing to deal with OS specific oddies :-
* pre/post processing to deal with OS specific oddities :-
*
* IP_TOS is a no-op with IPv6 sockets as it's setup when
* the connection is established.
......@@ -1287,7 +1262,7 @@ NET_GetSockOpt(int fd, int level, int opt, void *result,
*
* For IP_TOS socket option need to mask off bits as this
* aren't automatically masked by the kernel and results in
* an error. In addition IP_TOS is a noop with IPv6 as it
* an error. In addition IP_TOS is a NOOP with IPv6 as it
* should be setup as connection time.
*/
int
......@@ -1321,7 +1296,7 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg,
/*
* IPPROTO/IP_TOS :-
* 1. IPv6 on Solaris/Mac OS: no-op and will be set
* 1. IPv6 on Solaris/Mac OS: NOOP and will be set
* in flowinfo field when connecting TCP socket,
* or sending UDP packet.
* 2. IPv6 on Linux: By default Linux ignores flowinfo
......
......@@ -144,7 +144,6 @@ extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
* Utilities
*/
#ifdef __linux__
extern int kernelIsV22();
extern int kernelIsV24();
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册