[mle] delay router role downgrade on security policy change (#9187)

This commit adds a mechanism to delay the downgrade of routers or
leader when the security policy TLV changes in the Active Operational
Dataset such that the device is no longer eligible to act as a
router.

If the decision to become a child is made due to a security policy
change, the device first delays a random period up to the "router
selection jitter" before downgrading. If the device is the leader, an
additional fixed delay of 10 seconds is added to the random period.

If the security policy changes again while the device is waiting to
downgrade such that it becomes router-eligible again, the downgrade
is cancelled and the device remains in its current role.

This commit adds a `test_router_downgrade_on_sec_policy_change` to
validate the behavior of newly added mechanism.

This commit also updates the CLI `dataset` sub-commands to allow
getting and setting the "version threshold for routing" (VR) field in
security policy.
This commit is contained in:
Abtin Keshavarzian
2023-06-30 15:09:50 -07:00
committed by GitHub
parent 60db56f0c0
commit ef8deb506f
9 changed files with 229 additions and 27 deletions
+2 -2
View File
@@ -1738,7 +1738,7 @@ class OTCI(object):
# Network Name: OpenThread-7caa
# PAN ID: 0x7caa
# PSKc: 167d89fd169e439ca0b8266de248090f
# Security Policy: 0, onrc
# Security Policy: 672 onrc 0
dataset = {}
@@ -1765,7 +1765,7 @@ class OTCI(object):
elif key == 'PSKc':
dataset['pskc'] = val
elif key == 'Security Policy':
rotation_time, flags = val.split(', ') if ', ' in val else val.split(' ')
rotation_time, flags, version_threshold = val.split(' ')
rotation_time = int(rotation_time)
dataset['security_policy'] = SecurityPolicy(rotation_time, flags)
else: