mirror of
https://github.com/espressif/openthread.git
synced 2026-09-01 06:49:54 +00:00
[srp-client] exclude non-preferred addresses in AutoAddress mode (#9642)
This commit updates the `AutoAddress` mode in `Srp::Client` to exclude any deprecated (non-preferred) address when registering host addresses. It also updates `test_srp_auto_host_address` to validate the new behavior.
This commit is contained in:
@@ -1880,8 +1880,8 @@ class NodeImpl:
|
||||
self.send_command(cmd)
|
||||
self._expect_done()
|
||||
|
||||
def get_addrs(self):
|
||||
self.send_command('ipaddr')
|
||||
def get_addrs(self, verbose=False):
|
||||
self.send_command('ipaddr' + (' -v' if verbose else ''))
|
||||
|
||||
return self._expect_results(r'\S+(:\S*)+')
|
||||
|
||||
|
||||
@@ -155,6 +155,19 @@ class SrpAutoHostAddress(thread_cert.TestCase):
|
||||
self.assertEqual(len(slaac_addr), 1)
|
||||
self.check_registered_addresses(client, server)
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Add a non-preferred SLAAC on-mesh prefix and check that the
|
||||
# set of registered addresses remains unchanged and that the
|
||||
# non-preferred address is not registered by SRP client.
|
||||
|
||||
client.add_prefix('fd00:a:b:c::/64', 'aos')
|
||||
client.register_netdata()
|
||||
self.simulator.go(5)
|
||||
|
||||
slaac_addr = [addr.strip() for addr in client.get_addrs() if addr.strip().startswith('fd00:a:b:c:')]
|
||||
self.assertEqual(len(slaac_addr), 1)
|
||||
self.check_registered_addresses(client, server)
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Remove the on-mesh prefix (which will trigger an address to be
|
||||
# removed) and check that the SRP client re-registered and updated
|
||||
@@ -219,19 +232,21 @@ class SrpAutoHostAddress(thread_cert.TestCase):
|
||||
# Check the host addresses on server to match client.
|
||||
|
||||
host_addresses = [addr.strip() for addr in server_host['addresses']]
|
||||
client_addresses = [addr.strip() for addr in client.get_addrs()]
|
||||
|
||||
client_mleid = client.get_mleid()
|
||||
client_addresses = [addr.split(' ')[0] for addr in client.get_addrs(verbose=True) if 'preferred:1' in addr]
|
||||
client_addresses += [client_mleid]
|
||||
|
||||
# All registered addresses must be in client list of addresses.
|
||||
|
||||
for addr in host_addresses:
|
||||
self.assertIn(addr, client_addresses)
|
||||
|
||||
# All addresses on client excluding link-local and mesh-local
|
||||
# addresses must be seen on server side. But if there was
|
||||
# no address, then mesh-local address should be the only
|
||||
# All preferred addresses on client excluding link-local and
|
||||
# mesh-local addresses must be seen on server side. But if there
|
||||
# was no address, then mesh-local address should be the only
|
||||
# one registered.
|
||||
|
||||
client_mleid = client.get_mleid()
|
||||
checked_address = False
|
||||
|
||||
for addr in client_addresses:
|
||||
|
||||
Reference in New Issue
Block a user