[spinel] fix passing an unexpected transmit error to mac layer (#9745)

For the Spinel layer, when the state is transmitting, if the received
Spinel frame fails parsing, the current implementation passes the
`OT_ERROR_PARSE` error code to the sub_mac layer via the tx done
handler. This causes an assert because the error code `OT_ERROR_PARSE`
is not a valid one for `SubMac::HandleTransmitDone`. Additionally, I
believe that when the received Spinel frame fails parsing, we should
not trigger a transmit done to the sub_mac layer, as the `TxFrame` and
the `AckFrame` may not be valid for further processing.

In this corner case, I suggest considering ignoring the parsing-failed
received packets, waiting for the tx timeout, and then raising a tx
timeout failure to recover the RCP. This might be a reasonable
approach.
This commit is contained in:
Zhangwx
2024-01-24 15:05:36 -08:00
committed by GitHub
parent 7a2983b01c
commit ab28127a2a
+12 -2
View File
@@ -1763,8 +1763,18 @@ void RadioSpinel::HandleTransmitDone(uint32_t aCommand,
}
exit:
mState = kStateTransmitDone;
mTxError = error;
// A parse error indicates an RCP misbehavior, so recover the RCP immediately.
mState = kStateTransmitDone;
if (error != OT_ERROR_PARSE)
{
mTxError = error;
}
else
{
mTxError = kErrorAbort;
HandleRcpTimeout();
RecoverFromRcpFailure();
}
UpdateParseErrorCount(error);
LogIfFail("Handle transmit done failed", error);
}