Commit ee9e6702 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

nfsv4: return correct netid for ipv6

parent 659fd786
......@@ -177,7 +177,8 @@ public class DeviceManager implements NFSv41DeviceManager {
file_type.nflda_multipath_ds_list[i].value[0] = new netaddr4();
file_type.nflda_multipath_ds_list[i].value[0].na_r_addr =
InetSocketAddresses.uaddrOf(deviceAddress[i]);
file_type.nflda_multipath_ds_list[i].value[0].na_r_netid = "tcp";
file_type.nflda_multipath_ds_list[i].value[0].na_r_netid =
InetSocketAddresses.tcpNetidOf(deviceAddress[i].getAddress());
}
file_type.nflda_stripe_indices = stripingPattern.getPattern(deviceAddress);
......
......@@ -17,6 +17,8 @@
package org.dcache.utils.net;
import java.net.InetAddress;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import com.google.common.net.InetAddresses;
......@@ -56,7 +58,7 @@ public class InetSocketAddresses {
* Additionally, the two alternative forms specified in Section 2.2
* of RFC 4291 are also acceptable.
* </pre>
* @param address
* @param uaddr
* @return socket address
* @throws UnknownHostException
*/
......@@ -123,4 +125,21 @@ public class InetSocketAddresses {
public static String uaddrOf(String host, int port) {
return uaddrOf( new InetSocketAddress(host, port));
}
/**
* Get netid type for given {@link InetAddress}.
*
* @param address
* @return string corresponding to netid.
* @throws IllegalArgumentException in case of address type is unsupported.
*/
public static String tcpNetidOf(InetAddress address) {
if( address instanceof Inet4Address ){
return "tcp";
}else if( address instanceof Inet6Address ){
return "tcp6";
}
throw new IllegalArgumentException("unsupported inet type: " + address.getClass().getName());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment