[tmf] add local IPv6 DSCP values to indicate TMF message priority (#7869)

This commit adds new IPv6 header DSCP values which indicate a TMF
message priority. This allows intermediate routers forwarding TMF
message to be able to determine and use the TMF message priority that
originator of the message selects (e.g., address query/notification
use net-level priority whereas network diagnostics message use normal
priority). This replaces the previous behavior where on intermediate
routers all TMF messages were treated as net-level priority.

The new DSCP values are allocated from local codepoint range
`0bxxxx11` (per RFC 2474 - section 6). If the sender does not use
TMF-specific DSCP values, we use `kPriorityNet` as default on
intermediate router. This ensures that senders that are using older
code (do not use the new) experience the same behavior as before.
This commit is contained in:
Abtin Keshavarzian
2023-04-07 12:23:01 -07:00
committed by GitHub
parent cb40a45298
commit d9ea37a3bb
5 changed files with 93 additions and 3 deletions
+13 -1
View File
@@ -428,10 +428,22 @@ Error Ip6::SendDatagram(Message &aMessage, MessageInfo &aMessageInfo, uint8_t aI
{
Error error = kErrorNone;
Header header;
uint8_t dscp;
uint16_t payloadLength = aMessage.GetLength();
if ((aIpProto == kProtoUdp) &&
Get<Tmf::Agent>().IsTmfMessage(aMessageInfo.GetSockAddr(), aMessageInfo.GetPeerAddr(),
aMessageInfo.GetPeerPort()))
{
dscp = Tmf::Agent::PriorityToDscp(aMessage.GetPriority());
}
else
{
dscp = PriorityToDscp(aMessage.GetPriority());
}
header.InitVersionTrafficClassFlow();
header.SetDscp(PriorityToDscp(aMessage.GetPriority()));
header.SetDscp(dscp);
header.SetEcn(aMessageInfo.GetEcn());
header.SetPayloadLength(payloadLength);
header.SetNextHeader(aIpProto);
+7 -1
View File
@@ -89,7 +89,13 @@ enum IpDscpCs : uint8_t
kDscpCs5 = 40, ///< Class selector codepoint 40
kDscpCs6 = 48, ///< Class selector codepoint 48
kDscpCs7 = 56, ///< Class selector codepoint 56
kDscpCsMask = 0x38, ///< Class selector mask
kDscpCsMask = 0x38, ///< Class selector mask (0b111000)
// DSCP values to use within Thread mesh (from local codepoint space 0bxxxx11 [RFC 2474 - section 6]).
kDscpTmfNetPriority = 0x07, ///< TMF network priority (0b000111).
kDscpTmfNormalPriority = 0x0f, ///< TMF normal priority (0b001111).
kDscpTmfLowPriority = 0x17, ///< TMF low priority (0b010111).
};
/**
+5 -1
View File
@@ -1626,10 +1626,14 @@ Error MeshForwarder::GetFramePriority(const FrameData &aFrameData,
{
uint16_t destPort = headers.GetUdpHeader().GetDestinationPort();
if ((destPort == Mle::kUdpPort) || (destPort == Tmf::kUdpPort))
if (destPort == Mle::kUdpPort)
{
aPriority = Message::kPriorityNet;
}
else if (Get<Tmf::Agent>().IsTmfMessage(headers.GetSourceAddress(), headers.GetDestinationAddress(), destPort))
{
aPriority = Tmf::Agent::DscpToPriority(headers.GetIp6Header().GetDscp());
}
}
exit:
+48
View File
@@ -34,6 +34,7 @@
#include "thread/tmf.hpp"
#include "common/locator_getters.hpp"
#include "net/ip6_types.hpp"
namespace ot {
namespace Tmf {
@@ -222,6 +223,53 @@ exit:
return isTmf;
}
uint8_t Agent::PriorityToDscp(Message::Priority aPriority)
{
uint8_t dscp = Ip6::kDscpTmfNormalPriority;
switch (aPriority)
{
case Message::kPriorityNet:
dscp = Ip6::kDscpTmfNetPriority;
break;
case Message::kPriorityHigh:
case Message::kPriorityNormal:
break;
case Message::kPriorityLow:
dscp = Ip6::kDscpTmfLowPriority;
break;
}
return dscp;
}
Message::Priority Agent::DscpToPriority(uint8_t aDscp)
{
Message::Priority priority = Message::kPriorityNet;
// If the sender does not use TMF specific DSCP value, we use
// `kPriorityNet`. This ensures that senders that do not use the
// new value (older firmware) experience the same behavior as
// before where all TMF message were treated as `kPriorityNet`.
switch (aDscp)
{
case Ip6::kDscpTmfNetPriority:
default:
break;
case Ip6::kDscpTmfNormalPriority:
priority = Message::kPriorityNormal;
break;
case Ip6::kDscpTmfLowPriority:
priority = Message::kPriorityLow;
break;
}
return priority;
}
#if OPENTHREAD_CONFIG_DTLS_ENABLE
SecureAgent::SecureAgent(Instance &aInstance)
+20
View File
@@ -182,6 +182,26 @@ public:
*/
bool IsTmfMessage(const Ip6::Address &aSourceAddress, const Ip6::Address &aDestAddress, uint16_t aDestPort) const;
/**
* This static method converts a TMF message priority to IPv6 header DSCP value.
*
* @param[in] aPriority The message priority to convert.
*
* @returns The DSCP value corresponding to @p aPriority.
*
*/
static uint8_t PriorityToDscp(Message::Priority aPriority);
/**
* This static method converts a IPv6 header DSCP value to message priority for TMF message.
*
* @param[in] aDscp The IPv6 header DSCP value in a TMF message.
*
* @returns The message priority corresponding to the @p aDscp.
*
*/
static Message::Priority DscpToPriority(uint8_t aDscp);
private:
template <Uri kUri> void HandleTmf(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);