[ https://issues.apache.org/jira/browse/HDFS-16495?focusedWorklogId=740195&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-740195 ]
ASF GitHub Bot logged work on HDFS-16495: ----------------------------------------- Author: ASF GitHub Bot Created on: 11/Mar/22 18:11 Start Date: 11/Mar/22 18:11 Worklog Time Spent: 10m Work Description: hchaverri commented on a change in pull request #4054: URL: https://github.com/apache/hadoop/pull/4054#discussion_r824956894 ########## File path: hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java ########## @@ -590,17 +590,26 @@ private Object invokeMethod( * It adds trace info "clientIp:ip" and "clientPort:port" * to caller context if they are absent. */ - private void appendClientIpPortToCallerContextIfAbsent() { + private void addClientIpToCallerContext() { CallerContext ctx = CallerContext.getCurrent(); String origContext = ctx == null ? null : ctx.getContext(); byte[] origSignature = ctx == null ? null : ctx.getSignature(); - CallerContext.setCurrent( - new CallerContext.Builder(origContext, contextFieldSeparator) - .appendIfAbsent(CLIENT_IP_STR, Server.getRemoteAddress()) - .appendIfAbsent(CLIENT_PORT_STR, + CallerContext.Builder builder = + new CallerContext.Builder("", contextFieldSeparator) + .append(CLIENT_IP_STR, Server.getRemoteAddress()) + .append(CLIENT_PORT_STR, Integer.toString(Server.getRemotePort())) - .setSignature(origSignature) - .build()); + .setSignature(origSignature); + // Append the original caller context + if (origContext != null) { + for (String part : origContext.split(contextFieldSeparator)) { + if (!part.startsWith(CLIENT_IP_STR) && Review comment: We should try to leverage Builder#appendIfAbsent as that will do the comparison up to the KEY_VALUE_SEPARATOR. In the current form, new fields that start with "clientIp" (e.g. someone adding a field "clientIpV6" in the future) will be dropped. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 740195) Time Spent: 40m (was: 0.5h) > RBF should prepend the client ip rather than append it. > ------------------------------------------------------- > > Key: HDFS-16495 > URL: https://issues.apache.org/jira/browse/HDFS-16495 > Project: Hadoop HDFS > Issue Type: Improvement > Reporter: Owen O'Malley > Assignee: Owen O'Malley > Priority: Major > Labels: pull-request-available > Time Spent: 40m > Remaining Estimate: 0h > > Currently the Routers append the client ip to the caller context if and only > if it is not already set. This would allow the user to fake their ip by > setting the caller context. Much better is to prepend it unconditionally. > The NN must be able to trust the client ip from the caller context. -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org