From 282971e00a93f941441d8bc14537cbffd96c1b25 Mon Sep 17 00:00:00 2001 From: Tigran Mkrtchyan Date: Sun, 5 Jun 2016 13:05:45 +0200 Subject: [PATCH] rpcbind: skip IPv6 netids when using protocol version 2 Motivation: the rfc 1833 specifies only TCP (6) and UDP (17) transports. Any other transport will be mapped to '-1'. Nevertheless, missing mapping was ignored and sent to rpcbind. Modification: du not sent mapping request to rpcbind if transport is not supported. Result: no weird entries in portmap v2; Fixes: #44 Acked-by: Target: master, 2.5 --- .../java/org/dcache/xdr/portmap/PortmapV2Client.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/oncrpc4j-core/src/main/java/org/dcache/xdr/portmap/PortmapV2Client.java b/oncrpc4j-core/src/main/java/org/dcache/xdr/portmap/PortmapV2Client.java index 74e85310..147e2564 100644 --- a/oncrpc4j-core/src/main/java/org/dcache/xdr/portmap/PortmapV2Client.java +++ b/oncrpc4j-core/src/main/java/org/dcache/xdr/portmap/PortmapV2Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 - 2012 Deutsches Elektronen-Synchroton, + * Copyright (c) 2009 - 2016 Deutsches Elektronen-Synchroton, * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY * * This library is free software; you can redistribute it and/or modify @@ -44,7 +44,7 @@ public class PortmapV2Client implements OncPortmapClient { public PortmapV2Client(RpcCall call) { _call = call; } - + public List dump() throws OncRpcException, IOException, TimeoutException { _log.debug("portmap dump"); pmaplist list_reply = new pmaplist(); @@ -77,8 +77,12 @@ public boolean setPort(int program, int version, String netids, String addr, Str _log.debug("portmap set port: prog: {} vers: {}, netid: {} addr: {}, owner: {}", new Object[]{program, version, netids, addr, owner}); + int protocol = netid.idOf(netids); + if (protocol == -1) { + return false; + } InetSocketAddress address = org.dcache.xdr.netid.toInetSocketAddress(addr); - mapping m1 = new mapping(program, version, netid.idOf(netids), address.getPort()); + mapping m1 = new mapping(program, version, protocol, address.getPort()); XdrBoolean isSet = new XdrBoolean(); _call.call(OncRpcPortmap.PMAPPROC_SET, m1, isSet);