[network-data] add check for invalid router IDs (#4544)

It is posisble for a leader to receive SVR_DATA.ntf messages
attempting to register with a router ID that is not valid on the
leader.

This commit does not allow registering network data with invalid
router IDs to avoid having stale network data that persists.
This commit is contained in:
Jonathan Hui
2020-02-11 07:32:43 -08:00
committed by GitHub
parent b81813fa4e
commit 2c66141c17
@@ -727,6 +727,8 @@ otError Leader::RegisterNetworkData(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aT
uint8_t oldTlvs[NetworkData::kMaxSize];
uint8_t oldTlvsLength = NetworkData::kMaxSize;
VerifyOrExit(Get<RouterTable>().IsAllocated(Mle::Mle::RouterIdFromRloc16(aRloc16)), error = OT_ERROR_NO_ROUTE);
// Verify that `aTlvs` only contains entries matching `aRloc16`.
SuccessOrExit(error = RlocLookup(aRloc16, rlocIn, rlocStable, aTlvs, aTlvsLength, kMatchModeRloc16,
/* aAllowOtherEntries */ false));