mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[tmf] TMF not to use platform udp (#5910)
This commit fixes TMF issues related to the Host tun interface.
- Do not pass TMF messages to Host tun interface
- Backbone TMF (also using port 61631) keeps passing TMF messages to
Host tun interface
- Re-enable packet filters for ALOC/RLOC destined and TMF packets for
PLAT_NETIF and PLAT_UDP
This commit is contained in:
+12
-6
@@ -129,6 +129,12 @@ send "ipaddr\r\n"
|
||||
expect "Done"
|
||||
send "coex\r\n"
|
||||
expect "Done"
|
||||
send "coap start\r\n"
|
||||
expect "Done"
|
||||
send "coap resource TestResource\r\n"
|
||||
expect "Done"
|
||||
send "coap set TestContent\r\n"
|
||||
expect "Done"
|
||||
wait
|
||||
EOF
|
||||
|
||||
@@ -142,7 +148,7 @@ EOF
|
||||
fi
|
||||
done
|
||||
|
||||
netstat -an | grep -q 61631 || die 'TMF port is not available!'
|
||||
netstat -an | grep -q 5683 || die 'Application CoAP port is not available!'
|
||||
|
||||
extaddr=$(grep -aoE '[0-9a-z]{16}' $OT_OUTPUT)
|
||||
echo "Extended address is: ${extaddr}"
|
||||
@@ -157,15 +163,15 @@ EOF
|
||||
fi
|
||||
|
||||
LEADER_ALOC=fdde:ad00:beef::ff:fe00:fc00
|
||||
# Retrievie extended address through network diagnostic get
|
||||
coap_response=$(echo -n '120100' | xxd -r -p | coap-client -m POST coap://[${LEADER_ALOC}]:61631/d/dg -f- | xxd -p | grep 0008)
|
||||
# Retrievie test resource through application CoAP
|
||||
coap_response=$(coap-client -B 5 -m GET coap://[${LEADER_ALOC}]:5683/TestResource)
|
||||
echo "CoAP response is: ${coap_response}"
|
||||
|
||||
# Verify CoAP response contains the extended address
|
||||
if [[ ${coap_response} == *${extaddr}* ]]; then
|
||||
# Verify CoAP response contains the test content
|
||||
if [[ ${coap_response} == *TestContent* ]]; then
|
||||
echo 'Success'
|
||||
else
|
||||
die 'Failed to get extended address'
|
||||
die 'Failed to access application CoAP'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -1004,13 +1004,11 @@ otError Ip6::ProcessReceiveCallback(Message & aMessage,
|
||||
if (mIsReceiveIp6FilterEnabled)
|
||||
{
|
||||
// do not pass messages sent to an RLOC/ALOC, except Service Locator
|
||||
#if !OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||
bool isLocator = Get<Mle::Mle>().IsMeshLocalAddress(aMessageInfo.GetSockAddr()) &&
|
||||
aMessageInfo.GetSockAddr().GetIid().IsLocator();
|
||||
|
||||
VerifyOrExit(!isLocator || aMessageInfo.GetSockAddr().GetIid().IsAnycastServiceLocator(),
|
||||
error = OT_ERROR_NO_ROUTE);
|
||||
#endif
|
||||
|
||||
switch (aIpProto)
|
||||
{
|
||||
@@ -1041,13 +1039,11 @@ otError Ip6::ProcessReceiveCallback(Message & aMessage,
|
||||
// do not pass MLE messages
|
||||
ExitNow(error = OT_ERROR_NO_ROUTE);
|
||||
}
|
||||
#if !OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
|
||||
else if ((destPort == Tmf::kUdpPort) && Get<Tmf::TmfAgent>().IsTmfMessage(aMessageInfo))
|
||||
{
|
||||
// do not pass TMF messages
|
||||
ExitNow(error = OT_ERROR_NO_ROUTE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
if (destPort == Get<MeshCoP::JoinerRouter>().GetJoinerUdpPort())
|
||||
|
||||
+36
-12
@@ -242,7 +242,7 @@ otError Udp::Bind(SocketHandle &aSocket, const SockAddr &aSockAddr)
|
||||
} while (error != OT_ERROR_NONE);
|
||||
}
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
|
||||
else if (!IsMlePort(aSocket.mSockName.mPort))
|
||||
else if (ShouldUsePlatformUdp(aSocket))
|
||||
{
|
||||
error = otPlatUdpBind(&aSocket);
|
||||
}
|
||||
@@ -275,10 +275,26 @@ void Udp::SetBackboneSocket(SocketHandle &aSocket)
|
||||
}
|
||||
}
|
||||
|
||||
const Udp::SocketHandle *Udp::GetBackboneSockets(void)
|
||||
const Udp::SocketHandle *Udp::GetBackboneSockets(void) const
|
||||
{
|
||||
return mPrevBackboneSockets != nullptr ? mPrevBackboneSockets->GetNext() : mSockets.GetHead();
|
||||
}
|
||||
|
||||
bool Udp::IsBackboneSocket(const SocketHandle &aSocket) const
|
||||
{
|
||||
bool retval = false;
|
||||
|
||||
for (const SocketHandle *sock = GetBackboneSockets(); sock != nullptr; sock = sock->GetNext())
|
||||
{
|
||||
if (sock == &aSocket)
|
||||
{
|
||||
ExitNow(retval = true);
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
otError Udp::Connect(SocketHandle &aSocket, const SockAddr &aSockAddr)
|
||||
@@ -293,7 +309,7 @@ otError Udp::Connect(SocketHandle &aSocket, const SockAddr &aSockAddr)
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
|
||||
if (!IsMlePort(aSocket.mSockName.mPort))
|
||||
if (ShouldUsePlatformUdp(aSocket))
|
||||
{
|
||||
error = otPlatUdpConnect(&aSocket);
|
||||
}
|
||||
@@ -356,8 +372,7 @@ otError Udp::SendTo(SocketHandle &aSocket, Message &aMessage, const MessageInfo
|
||||
messageInfoLocal.SetSockPort(aSocket.GetSockName().mPort);
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
|
||||
if (!IsMlePort(aSocket.mSockName.mPort) &&
|
||||
!(aSocket.mSockName.mPort == Tmf::kUdpPort && aMessage.GetSubType() == Message::kSubTypeJoinerEntrust))
|
||||
if (ShouldUsePlatformUdp(aSocket))
|
||||
{
|
||||
// Replace anycast address with a valid unicast address since response messages typically copy the peer address
|
||||
if (Get<Mle::Mle>().IsAnycastLocator(messageInfoLocal.GetSockAddr()))
|
||||
@@ -483,7 +498,7 @@ otError Udp::HandleMessage(Message &aMessage, MessageInfo &aMessageInfo)
|
||||
aMessageInfo.mSockPort = udpHeader.GetDestinationPort();
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
|
||||
VerifyOrExit(IsMlePort(aMessageInfo.mSockPort));
|
||||
VerifyOrExit(!ShouldUsePlatformUdp(aMessageInfo.mSockPort));
|
||||
#endif
|
||||
|
||||
for (Receiver *receiver = mReceivers.GetHead(); receiver; receiver = receiver->GetNext())
|
||||
@@ -533,16 +548,25 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
bool Udp::IsMlePort(uint16_t aPort) const
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
|
||||
bool Udp::ShouldUsePlatformUdp(uint16_t aPort) const
|
||||
{
|
||||
bool isMlePort = (aPort == Mle::kUdpPort);
|
||||
|
||||
return (aPort != Mle::kUdpPort && aPort != Tmf::kUdpPort
|
||||
#if OPENTHREAD_FTD
|
||||
isMlePort = isMlePort || (aPort == Get<MeshCoP::JoinerRouter>().GetJoinerUdpPort());
|
||||
&& aPort != Get<MeshCoP::JoinerRouter>().GetJoinerUdpPort()
|
||||
#endif
|
||||
|
||||
return isMlePort;
|
||||
);
|
||||
}
|
||||
|
||||
bool Udp::ShouldUsePlatformUdp(const Udp::SocketHandle &aSocket) const
|
||||
{
|
||||
return (ShouldUsePlatformUdp(aSocket.mSockName.mPort)
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
|
||||
|| IsBackboneSocket(aSocket)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace Ip6
|
||||
} // namespace ot
|
||||
|
||||
@@ -595,11 +595,15 @@ private:
|
||||
|
||||
void AddSocket(SocketHandle &aSocket);
|
||||
void RemoveSocket(SocketHandle &aSocket);
|
||||
bool IsMlePort(uint16_t aPort) const;
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE
|
||||
bool ShouldUsePlatformUdp(uint16_t aPort) const;
|
||||
bool ShouldUsePlatformUdp(const SocketHandle &aSocket) const;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
|
||||
void SetBackboneSocket(SocketHandle &aSocket);
|
||||
const SocketHandle *GetBackboneSockets(void);
|
||||
const SocketHandle *GetBackboneSockets(void) const;
|
||||
bool IsBackboneSocket(const SocketHandle &aSocket) const;
|
||||
#endif
|
||||
|
||||
uint16_t mEphemeralPort;
|
||||
|
||||
Reference in New Issue
Block a user