mirror of
https://github.com/espressif/openthread.git
synced 2026-07-26 22:09:05 +00:00
[netdata] add otNetDataReplacePublishedExternalRoute() API (#9013)
This commit adds a public OT API to replace a previously published external route entry in the Thread Network Data. It also adds a related CLI command, and updates `test_netdata_publisher` to validate the new behavior.
This commit is contained in:
@@ -2380,6 +2380,10 @@ class NodeImpl:
|
||||
self.send_command(f'netdata publish route {prefix} {flags} {prf}')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_publish_replace(self, old_prefix, prefix, flags='s', prf='med'):
|
||||
self.send_command(f'netdata publish replace {old_prefix} {prefix} {flags} {prf}')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_unpublish_prefix(self, prefix):
|
||||
self.send_command(f'netdata unpublish {prefix}')
|
||||
self._expect_done()
|
||||
|
||||
@@ -461,6 +461,19 @@ class NetDataPublisher(thread_cert.TestCase):
|
||||
routes = leader.get_routes()
|
||||
self.check_num_of_routes(routes, num - 1, 0, 1)
|
||||
|
||||
# Replace the published route on leader with '::/0'.
|
||||
leader.netdata_publish_replace(EXTERNAL_ROUTE, '::/0', EXTERNAL_FLAGS, 'med')
|
||||
self.simulator.go(0.2)
|
||||
routes = leader.get_routes()
|
||||
self.assertEqual([route.split(' ')[0] == '::/0' for route in routes].count(True), 1)
|
||||
self.check_num_of_routes(routes, num - 1, 1, 0)
|
||||
|
||||
# Replace it back to the original route.
|
||||
leader.netdata_publish_replace('::/0', EXTERNAL_ROUTE, EXTERNAL_FLAGS, 'high')
|
||||
self.simulator.go(WAIT_TIME)
|
||||
routes = leader.get_routes()
|
||||
self.check_num_of_routes(routes, num - 1, 0, 1)
|
||||
|
||||
# Publish the same prefix on leader as an on-mesh prefix. Make
|
||||
# sure it is removed from external routes and now seen in the
|
||||
# prefix list.
|
||||
|
||||
Reference in New Issue
Block a user