Alexey Serbin has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/18223


Change subject: KUDU-3352 fix handling sockaddr_in in Sockaddr
......................................................................

KUDU-3352 fix handling sockaddr_in in Sockaddr

Since the Sockaddr class has been updated to handle various address
families, an issue with uninitialized memory in the storage_.in.sin_zero
started affecting the behavior of the Sockaddr::HashCode() method.
As the result, ReactorThread::FindOrStartConnection() could create a new
connection to the specified remote even if a connection with the
required credentials policy had already been established.

This patch addresses the issue by zeroing the padding 'sin_zero' field
of the sockaddr_in structure stored in the Sockaddr::storage_ field for
sockets of the AF_INET family.  I also added a new test scenario to
reproduce the issue, verifying that the scenario fails if not applying
the corresponding part of this patch to src/kudu/util/net/sockaddr.cc:

  [ RUN      ] SockaddrHashTest.ZeroPadding
  src/kudu/util/net/socket-test.cc:68: Failure
  Expected equality of these values:
    s_in.HashCode()
      Which is: 4164645418
    s_un.HashCode()
      Which is: 3759279765
  [  FAILED  ] SockaddrHashTest.ZeroPadding (1 ms)

Credit goes to Wenzhe Zhou for detecting and troubleshooting the issue.

This is a follow-up to 79079b6b64295b06c5a0f05ed200a55d89bccc47.

Change-Id: I96fee11a4191a4f4240c460db22742880eebe7b5
---
M src/kudu/util/net/sockaddr.cc
M src/kudu/util/net/socket-test.cc
2 files changed, 52 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/23/18223/1
--
To view, visit http://gerrit.cloudera.org:8080/18223
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I96fee11a4191a4f4240c460db22742880eebe7b5
Gerrit-Change-Number: 18223
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <[email protected]>

Reply via email to