Alexey Serbin has submitted this change and it was merged. ( 
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 BytewiseCompare() and HashCode()
methods.  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 not counting the padding 'sin_zero'
field of the sockaddr_in structure in the length of Sockaddr::storage_
which is passed to Sockaddr::{BytewiseCompare,HashCode}().

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:69: Failure
  Expected equality of these values:
    s_in.HashCode()
      Which is: 2868988679
    s_un.HashCode()
      Which is: 1786951233
  [  FAILED  ] SockaddrHashTest.ZeroPadding (0 ms)

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

This is a follow-up to 79079b6b64295b06c5a0f05ed200a55d89bccc47.

Change-Id: I96fee11a4191a4f4240c460db22742880eebe7b5
Reviewed-on: http://gerrit.cloudera.org:8080/18223
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Wenzhe Zhou <[email protected]>
Reviewed-by: Attila Bukor <[email protected]>
---
M src/kudu/util/net/sockaddr.cc
M src/kudu/util/net/sockaddr.h
M src/kudu/util/net/socket-test.cc
3 files changed, 79 insertions(+), 6 deletions(-)

Approvals:
  Alexey Serbin: Verified
  Wenzhe Zhou: Looks good to me, but someone else must approve
  Attila Bukor: Looks good to me, approved

--
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: merged
Gerrit-Change-Id: I96fee11a4191a4f4240c460db22742880eebe7b5
Gerrit-Change-Number: 18223
Gerrit-PatchSet: 6
Gerrit-Owner: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Abhishek Chennaka <[email protected]>
Gerrit-Reviewer: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Andrew Wong <[email protected]>
Gerrit-Reviewer: Attila Bukor <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Wenzhe Zhou <[email protected]>

Reply via email to