mirror of
https://github.com/espressif/openthread.git
synced 2026-09-01 14:59:54 +00:00
[nat64] check OMR prefix when selecting favored NAT64 prefix (#8995)
This commit adds a check on OMR prefix before selecting AIL prefix as the favored NAT64 prefix for publishing.
This commit is contained in:
@@ -49,6 +49,8 @@ ROUTER = 2
|
||||
BR2 = 3
|
||||
HOST = 4
|
||||
|
||||
OMR_PREFIX = "2000:0:1111:4444::/64"
|
||||
|
||||
NAT64_PREFIX_REFRESH_DELAY = 305
|
||||
|
||||
NAT64_STATE_DISABLED = 'disabled'
|
||||
@@ -118,9 +120,15 @@ class Nat64MultiBorderRouter(thread_cert.TestCase):
|
||||
self.simulator.go(config.BORDER_ROUTER_STARTUP_DELAY)
|
||||
self.assertEqual('router', br2.get_state())
|
||||
|
||||
br2.add_prefix(OMR_PREFIX)
|
||||
br2.register_netdata()
|
||||
self.simulator.go(10)
|
||||
|
||||
self.simulator.go(10)
|
||||
self.assertNotEqual(br1.get_br_favored_nat64_prefix(), br2.get_br_favored_nat64_prefix())
|
||||
br1_local_nat64_prefix = br1.get_br_nat64_prefix()
|
||||
br2_local_nat64_prefix = br2.get_br_nat64_prefix()
|
||||
self.assertNotEqual(br2_local_nat64_prefix, br2.get_br_favored_nat64_prefix())
|
||||
br2_infra_nat64_prefix = br2.get_br_favored_nat64_prefix()
|
||||
|
||||
self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
|
||||
@@ -164,8 +172,7 @@ class Nat64MultiBorderRouter(thread_cert.TestCase):
|
||||
br2.nat64_set_enabled(True)
|
||||
|
||||
self.simulator.go(10)
|
||||
self.assertNotEqual(br2_infra_nat64_prefix, br2.get_br_favored_nat64_prefix())
|
||||
br2_local_nat64_prefix = br2.get_br_nat64_prefix()
|
||||
self.assertEqual(br2_local_nat64_prefix, br2.get_br_favored_nat64_prefix())
|
||||
|
||||
self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
|
||||
nat64_prefix = br1.get_netdata_nat64_prefix()[0]
|
||||
|
||||
@@ -47,6 +47,7 @@ import thread_cert
|
||||
BR = 1
|
||||
ROUTER = 2
|
||||
|
||||
OMR_PREFIX = "2000:0:1111:4444::/64"
|
||||
# The prefix is set smaller than the default infrastructure NAT64 prefix.
|
||||
SMALL_NAT64_PREFIX = "2000:0:0:1:0:0::/96"
|
||||
|
||||
@@ -90,8 +91,26 @@ class Nat64SingleBorderRouter(thread_cert.TestCase):
|
||||
self.simulator.go(config.ROUTER_STARTUP_DELAY)
|
||||
self.assertEqual('router', router.get_state())
|
||||
|
||||
# Case 1 BR advertise the infrastructure prefix
|
||||
infra_nat64_prefix = br.get_br_favored_nat64_prefix()
|
||||
# Case 1 No infra-derived OMR prefix. BR publishes its local prefix.
|
||||
local_nat64_prefix = br.get_br_nat64_prefix()
|
||||
|
||||
self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
|
||||
nat64_prefix = br.get_netdata_nat64_prefix()[0]
|
||||
self.assertEqual(nat64_prefix, local_nat64_prefix)
|
||||
|
||||
self.assertDictIncludes(br.nat64_state, {
|
||||
'PrefixManager': NAT64_STATE_ACTIVE,
|
||||
'Translator': NAT64_STATE_ACTIVE
|
||||
})
|
||||
|
||||
# Case 2 Add OMR prefix. BR publishes the infrastructure nat64 prefix
|
||||
br.add_prefix(OMR_PREFIX)
|
||||
br.register_netdata()
|
||||
self.simulator.go(10)
|
||||
|
||||
favored_nat64_prefix = br.get_br_favored_nat64_prefix()
|
||||
self.assertNotEqual(favored_nat64_prefix, local_nat64_prefix)
|
||||
infra_nat64_prefix = favored_nat64_prefix
|
||||
|
||||
self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
|
||||
nat64_prefix = br.get_netdata_nat64_prefix()[0]
|
||||
@@ -101,7 +120,7 @@ class Nat64SingleBorderRouter(thread_cert.TestCase):
|
||||
'Translator': NAT64_STATE_NOT_RUNNING
|
||||
})
|
||||
|
||||
# Case 2 Withdraw infrastructure prefix when a smaller prefix in medium
|
||||
# Case 3 Unpublish infrastructure prefix when a smaller prefix in medium
|
||||
# preference is present
|
||||
br.add_route(SMALL_NAT64_PREFIX, stable=False, nat64=True, prf='med')
|
||||
br.register_netdata()
|
||||
@@ -121,7 +140,7 @@ class Nat64SingleBorderRouter(thread_cert.TestCase):
|
||||
self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
|
||||
self.assertEqual(nat64_prefix, infra_nat64_prefix)
|
||||
|
||||
# Case 3 No change when a smaller prefix in low preference is present
|
||||
# Case 4 No change when a smaller prefix in low preference is present
|
||||
br.add_route(SMALL_NAT64_PREFIX, stable=False, nat64=True, prf='low')
|
||||
br.register_netdata()
|
||||
self.simulator.go(5)
|
||||
@@ -137,7 +156,7 @@ class Nat64SingleBorderRouter(thread_cert.TestCase):
|
||||
br.register_netdata()
|
||||
self.simulator.go(5)
|
||||
|
||||
# Case 4 Infrastructure nat64 prefix no longer presents
|
||||
# Case 5 Infrastructure nat64 prefix no longer presents
|
||||
br.bash("service bind9 stop")
|
||||
self.simulator.go(NAT64_PREFIX_REFRESH_DELAY)
|
||||
|
||||
@@ -150,7 +169,7 @@ class Nat64SingleBorderRouter(thread_cert.TestCase):
|
||||
'Translator': NAT64_STATE_ACTIVE
|
||||
})
|
||||
|
||||
# Case 5 Infrastructure nat64 prefix is recovered
|
||||
# Case 6 Infrastructure nat64 prefix is recovered
|
||||
br.bash("service bind9 start")
|
||||
self.simulator.go(NAT64_PREFIX_REFRESH_DELAY)
|
||||
|
||||
@@ -162,7 +181,7 @@ class Nat64SingleBorderRouter(thread_cert.TestCase):
|
||||
'Translator': NAT64_STATE_NOT_RUNNING
|
||||
})
|
||||
|
||||
# Case 6 Change infrastructure nat64 prefix
|
||||
# Case 7 Change infrastructure nat64 prefix
|
||||
br.bash("sed -i 's/dns64 /\/\/dns64 /' /etc/bind/named.conf.options")
|
||||
br.bash("sed -i '/\/\/dns64 /a dns64 " + SMALL_NAT64_PREFIX + " {};' /etc/bind/named.conf.options")
|
||||
br.bash("service bind9 restart")
|
||||
|
||||
Reference in New Issue
Block a user