Skip to content

Commit

Permalink
[dtls] fix DTLS connection issues (#8168)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
simonlingoogle authored Sep 16, 2022
1 parent b5ea9c8 commit 0756d1e
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/core/meshcop/dtls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ThreadNetif>().HasUnicastAddress(aMessageInfo.GetSockAddr()))
{
mMessageInfo.SetSockAddr(aMessageInfo.GetSockAddr());
}

mMessageInfo.SetSockAddr(aMessageInfo.GetSockAddr());
mMessageInfo.SetSockPort(aMessageInfo.GetSockPort());

SuccessOrExit(Setup(false));
Expand Down

0 comments on commit 0756d1e

Please sign in to comment.