From 0756d1ea8fee17eba0cdee42a34ea353413a4f99 Mon Sep 17 00:00:00 2001 From: Simon Lin Date: Fri, 16 Sep 2022 11:55:01 +0800 Subject: [PATCH] [dtls] fix DTLS connection issues (#8168) This commit fixes two DTLS session issues on Posix: - Fix the issue that UDP connect would cause the kernel socket to bind to an address that might be different from the address used by the Commissioner. - Set the socket address to avoid kernel selecting an incorrect source address. --- src/core/meshcop/dtls.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/core/meshcop/dtls.cpp b/src/core/meshcop/dtls.cpp index aae1c5d81..790c78e7d 100644 --- a/src/core/meshcop/dtls.cpp +++ b/src/core/meshcop/dtls.cpp @@ -184,17 +184,11 @@ void Dtls::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageI ExitNow(); case Dtls::kStateOpen: - IgnoreError(mSocket.Connect(Ip6::SockAddr(aMessageInfo.GetPeerAddr(), aMessageInfo.GetPeerPort()))); - mMessageInfo.SetPeerAddr(aMessageInfo.GetPeerAddr()); mMessageInfo.SetPeerPort(aMessageInfo.GetPeerPort()); mMessageInfo.SetIsHostInterface(aMessageInfo.IsHostInterface()); - if (Get().HasUnicastAddress(aMessageInfo.GetSockAddr())) - { - mMessageInfo.SetSockAddr(aMessageInfo.GetSockAddr()); - } - + mMessageInfo.SetSockAddr(aMessageInfo.GetSockAddr()); mMessageInfo.SetSockPort(aMessageInfo.GetSockPort()); SuccessOrExit(Setup(false));