-fix hang issue exposed when intensive traffic in dense network (#991)

-mSockAddr should not be reset when send response for CoAP CON message
-other code refinements
This commit is contained in:
rongli
2016-11-19 15:35:55 +00:00
committed by Jonathan Hui
parent 050365e4fc
commit 9de7f12c24
8 changed files with 36 additions and 37 deletions
+15 -3
View File
@@ -364,6 +364,12 @@ void readFrame(void)
sReceiveFrame.mLength = length;
sReceiveFrame.mLqi = crcCorr & CC2538_LQI_BIT_MASK;
}
else
{
// resets rxfifo
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
}
// check for rxfifo overflow
if ((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_FIFOP) != 0 &&
@@ -382,8 +388,7 @@ void cc2538RadioProcess(otInstance *aInstance)
readFrame();
if ((sState == kStateReceive && sReceiveFrame.mLength > 0) ||
(sState == kStateTransmit && sReceiveFrame.mLength > 0 &&
(sReceiveFrame.mPsdu[0] & IEEE802154_FRAME_TYPE_MASK) != IEEE802154_FRAME_TYPE_ACK))
(sState == kStateTransmit && sReceiveFrame.mLength > IEEE802154_ACK_LENGTH))
{
#if OPENTHREAD_ENABLE_DIAG
@@ -394,7 +399,14 @@ void cc2538RadioProcess(otInstance *aInstance)
else
#endif
{
otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
// signal MAC layer for each received frame if promiscous is enabled
// otherwise only signal MAC layer for non-ACK frame
if (((HWREG(RFCORE_XREG_FRMFILT0) & RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN) == 0) ||
(sReceiveFrame.mLength > IEEE802154_ACK_LENGTH))
{
otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
}
}
}
+1
View File
@@ -937,6 +937,7 @@ void Mac::SentFrame(ThreadError aError)
}
mTransmitAttempts = 0;
mCsmaAttempts = 0;
if (sendFrame.GetAckRequest())
{
+7 -1
View File
@@ -117,6 +117,12 @@ bool Address::IsRoutingLocator(void) const
mFields.m16[6] == HostSwap16(0xfe00));
}
bool Address::IsAnycastRoutingLocator(void) const
{
return (mFields.m16[4] == HostSwap16(0x0000) && mFields.m16[5] == HostSwap16(0x00ff) &&
mFields.m16[6] == HostSwap16(0xfe00) && mFields.m8[14] == 0xfc);
}
bool Address::IsSubnetRouterAnycast(void) const
{
return (mFields.m32[2] == 0 && mFields.m32[3] == 0);
@@ -130,7 +136,7 @@ bool Address::IsReservedSubnetAnycast(void) const
bool Address::IsIidReserved(void) const
{
return IsSubnetRouterAnycast() || IsReservedSubnetAnycast();
return IsSubnetRouterAnycast() || IsReservedSubnetAnycast() || IsAnycastRoutingLocator();
}
+9
View File
@@ -197,6 +197,15 @@ public:
*/
bool IsRoutingLocator(void) const;
/**
* This method indicates whether or not the IPv6 address is an Anycast RLOC address.
*
* @retval TRUE If the IPv6 address is an Anycast RLOC address.
* @retval FALSE If the IPv6 address is not an Anycast RLOC address.
*
*/
bool IsAnycastRoutingLocator(void) const;
/**
* This method indicates whether or not the IPv6 address is Subnet-Router Anycast (RFC 4291),
*
+1 -1
View File
@@ -396,7 +396,7 @@ public:
* @returns The offset from the the transmission time to the end of trickle interval.
*
*/
uint32_t GetIntervalOffset() const { return mIntervalOffset; }
uint8_t GetIntervalOffset() const { return mIntervalOffset; }
/**
* This method sets the offset from the transmission time to the end of trickle interval.
-2
View File
@@ -305,7 +305,6 @@ void AddressResolver::SendAddressNotificationResponse(const Coap::Header &aReque
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
otLogInfoArp("Sent address notification acknowledgment");
@@ -378,7 +377,6 @@ void AddressResolver::SendAddressErrorResponse(const Coap::Header &aRequestHeade
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
otLogInfoArp("Sent address error notification acknowledgment");
+3 -29
View File
@@ -451,35 +451,10 @@ exit:
return error;
}
void MeshForwarder::MoveToResolving(const Ip6::Address &aDestination)
{
Message *cur, *next;
Ip6::Address ip6Dst;
for (cur = mSendQueue.GetHead(); cur; cur = next)
{
next = cur->GetNext();
if (cur->GetType() != Message::kTypeIp6)
{
continue;
}
cur->Read(Ip6::Header::GetDestinationOffset(), sizeof(ip6Dst), &ip6Dst);
if (memcmp(&ip6Dst, &aDestination, sizeof(ip6Dst)) == 0)
{
mSendQueue.Dequeue(*cur);
mResolvingQueue.Enqueue(*cur);
}
}
}
Message *MeshForwarder::GetDirectTransmission()
{
Message *curMessage, *nextMessage;
ThreadError error = kThreadError_None;
Ip6::Address ip6Dst;
for (curMessage = mSendQueue.GetHead(); curMessage; curMessage = nextMessage)
{
@@ -510,8 +485,8 @@ Message *MeshForwarder::GetDirectTransmission()
ExitNow();
case kThreadError_AddressQuery:
curMessage->Read(Ip6::Header::GetDestinationOffset(), sizeof(ip6Dst), &ip6Dst);
MoveToResolving(ip6Dst);
mSendQueue.Dequeue(*curMessage);
mResolvingQueue.Enqueue(*curMessage);
continue;
case kThreadError_Drop:
@@ -1256,8 +1231,6 @@ void MeshForwarder::HandleSentFrame(Mac::Frame &aFrame, ThreadError aError)
mSendBusy = false;
VerifyOrExit(mSendMessage != NULL, ;);
mSendMessage->SetOffset(mMessageNextOffset);
aFrame.GetDstAddr(macDest);
if ((neighbor = mMle.GetNeighbor(macDest)) != NULL)
@@ -1353,6 +1326,7 @@ void MeshForwarder::HandleSentFrame(Mac::Frame &aFrame, ThreadError aError)
mSendQueue.Dequeue(*mSendMessage);
mSendMessage->Free();
mSendMessage = NULL;
mMessageNextOffset = 0;
}
mScheduleTransmissionTask.Post();
-1
View File
@@ -221,7 +221,6 @@ private:
const Mac::Address &aMacSource, const Mac::Address &aMacDest,
const ThreadMessageInfo &aMessageInfo);
void HandleDataRequest(const Mac::Address &aMacSource, const ThreadMessageInfo &aMessageInfo);
void MoveToResolving(const Ip6::Address &aDestination);
ThreadError SendPoll(Message &aMessage, Mac::Frame &aFrame);
ThreadError SendMesh(Message &aMessage, Mac::Frame &aFrame);
ThreadError SendFragment(Message &aMessage, Mac::Frame &aFrame);