openthread icon indicating copy to clipboard operation
openthread copied to clipboard

[nat64] fetch NAT64 prefix from infrastructure interface and advertise it to netdata

Open xuyirio opened this issue 4 years ago • 5 comments

This commit fetches the NAT64 prefix on infrastructure interface and advertise it to Network Data at medium preference.

  • Use getaddrinfo_a() function to asynchronously lookup the ipv6 address of the special domain ipv4only.arpa. The infrastructure NAT64 prefix is extracted from the domain answer.
  • mInfraIfNat64PrefixStaleTimer is scheduled to monitor the presence and change of infrastructure NAT64 prefix.
  • EvaluateNat64Prefix evaluates whether to advertise the infrastructure prefix or the local ULA prefix or neither. When there is a new infrastructure prefix, it will withdraw the legacy one and add the new one. When the infrastructure prefix no longer exists, it will withdraw the legacy one and add the local ULA prefix. When the infrastructure prefix presents again, it will add the infrastructure prefix and withdraw the local ULA prefix.

New tests are added to test the scenarios when infrastructure NAT64 prefix exists. DNS64 on OTBR is turned on to enable bind9 with NAT64 prefix on infrastructure interface for these tests. bind9 is explicitly turned off when testing local ULA prefix. Since bind9 is conflict with other components like dnssd, all nat64 tests are moved under /nat64 directory and configured separately.

The case that two or more BRs have same infrastructure NAT64 prefix is not covered by this commit and will be followed up later.

xuyirio avatar Apr 21 '22 04:04 xuyirio

Size Report of OpenThread

Merging #7619 into main(034fc826f347c0d6ad4a7ce4bdb936a284fede05).

name branch text data bss total
ot-cli-ftd_1.1 main 462352 780 60772 523904
#7619 462432 780 60772 523984
+/- +80 0 0 +80
ot-cli-mtd_1.1 main 381880 780 50564 433224
#7619 381960 780 50564 433304
+/- +80 0 0 +80
ot-ncp-ftd_1.1 main 444084 780 59752 504616
#7619 444084 780 59752 504616
+/- 0 0 0 0
ot-ncp-mtd_1.1 main 366364 780 49544 416688
#7619 366364 780 49544 416688
+/- 0 0 0 0
ot-rcp_1.1 main 58136 564 19964 78664
#7619 58136 564 19964 78664
+/- 0 0 0 0
libopenthread-cli-ftd.a_1.1 main 45925 0 4244 50169
#7619 45925 0 4244 50169
+/- 0 0 0 0
libopenthread-cli-mtd.a_1.1 main 38548 0 4244 42792
#7619 38548 0 4244 42792
+/- 0 0 0 0
libopenthread-ftd.a_1.1 main 242776 20 39090 281886
#7619 242836 20 39090 281946
+/- +60 0 0 +60
libopenthread-mtd.a_1.1 main 175987 20 28882 204889
#7619 176047 20 28882 204949
+/- +60 0 0 +60
libopenthread-ncp-ftd.a_1.1 main 31597 0 5852 37449
#7619 31597 0 5852 37449
+/- 0 0 0 0
libopenthread-ncp-mtd.a_1.1 main 26441 0 5852 32293
#7619 26441 0 5852 32293
+/- 0 0 0 0
libopenthread-rcp.a_1.1 main 8894 0 4988 13882
#7619 8894 0 4988 13882
+/- 0 0 0 0
libopenthread-radio.a_1.1 main 15939 0 174 16113
#7619 15939 0 174 16113
+/- 0 0 0 0
ot-cli-ftd_1.3 main 485120 780 70468 556368
#7619 485200 780 70468 556448
+/- +80 0 0 +80
ot-cli-mtd_1.3 main 397040 780 51820 449640
#7619 397120 780 51820 449720
+/- +80 0 0 +80
ot-ncp-ftd_1.3 main 465812 780 69440 536032
#7619 465812 780 69440 536032
+/- 0 0 0 0
ot-ncp-mtd_1.3 main 380100 780 50792 431672
#7619 380100 780 50792 431672
+/- 0 0 0 0
ot-rcp_1.3 main 60464 564 20532 81560
#7619 60464 564 20532 81560
+/- 0 0 0 0
libopenthread-cli-ftd.a_1.3 main 48783 0 4244 53027
#7619 48783 0 4244 53027
+/- 0 0 0 0
libopenthread-cli-mtd.a_1.3 main 40812 0 4244 45056
#7619 40812 0 4244 45056
+/- 0 0 0 0
libopenthread-ftd.a_1.3 main 261698 20 48242 309960
#7619 261758 20 48242 310020
+/- +60 0 0 +60
libopenthread-mtd.a_1.3 main 187814 20 29594 217428
#7619 187874 20 29594 217488
+/- +60 0 0 +60
libopenthread-ncp-ftd.a_1.3 main 33427 0 5852 39279
#7619 33427 0 5852 39279
+/- 0 0 0 0
libopenthread-ncp-mtd.a_1.3 main 27807 0 5852 33659
#7619 27807 0 5852 33659
+/- 0 0 0 0
libopenthread-rcp.a_1.3 main 9060 0 4988 14048
#7619 9060 0 4988 14048
+/- 0 0 0 0
libopenthread-radio.a_1.3 main 16819 0 206 17025
#7619 16819 0 206 17025
+/- 0 0 0 0

size-report[bot] avatar Apr 21 '22 04:04 size-report[bot]

DNS64 on OTBR is turned on to enable bind9 with NAT64 prefix on infrastructure interface for these tests. bind9 is explicitly turned off when testing local ULA prefix. Since bind9 is conflict with other components like dnssd, all nat64 tests are moved under /nat64 directory and configured separately.

Does it mean that the current NAT64 solution on OTBR does not work with other 1.3 features? I think eventually we want them to co-work. How do we resolve the gaps?

simonlingoogle avatar Apr 24 '22 02:04 simonlingoogle

DNS64 on OTBR is turned on to enable bind9 with NAT64 prefix on infrastructure interface for these tests. bind9 is explicitly turned off when testing local ULA prefix. Since bind9 is conflict with other components like dnssd, all nat64 tests are moved under /nat64 directory and configured separately.

Does it mean that the current NAT64 solution on OTBR does not work with other 1.3 features? I think eventually we want them to co-work. How do we resolve the gaps?

The bind9 is enabled here for testing only that a DNS server w/ NAT64 prefix is needed on infrastructure interface. The DNS servers in /etc/resolv.conf is expected to be managed by upstream network service (e.g. generated by dhcpcd) rather than we configure a local server. I expect that other OTBR components work w/ the upstream configured DNS servers?

xuyirio avatar Apr 24 '22 06:04 xuyirio

Codecov Report

Merging #7619 (189b71f) into main (034fc82) will decrease coverage by 0.05%. The diff coverage is 91.94%.

:exclamation: Current head 189b71f differs from pull request most recent head 861f180. Consider uploading reports for the commit 861f180 to get more accurate results

@@            Coverage Diff             @@
##             main    #7619      +/-   ##
==========================================
- Coverage   85.43%   85.38%   -0.06%     
==========================================
  Files         505      510       +5     
  Lines       70125    70830     +705     
==========================================
+ Hits        59911    60477     +566     
- Misses      10214    10353     +139     
Impacted Files Coverage Δ
examples/platforms/simulation/infra_if.c 0.00% <0.00%> (ø)
src/core/border_router/infra_if.hpp 100.00% <ø> (ø)
src/core/border_router/routing_manager.hpp 62.79% <ø> (-1.66%) :arrow_down:
src/posix/platform/infra_if.hpp 50.00% <ø> (ø)
tests/unit/test_platform.cpp 46.73% <ø> (ø)
src/posix/platform/infra_if.cpp 89.76% <85.71%> (-1.11%) :arrow_down:
src/core/border_router/routing_manager.cpp 88.17% <98.03%> (+3.45%) :arrow_up:
src/cli/cli.cpp 79.56% <100.00%> (-1.60%) :arrow_down:
src/core/api/border_routing_api.cpp 48.38% <100.00%> (+17.61%) :arrow_up:
src/core/api/ip6_api.cpp 80.37% <100.00%> (-2.32%) :arrow_down:
... and 66 more

codecov[bot] avatar Apr 25 '22 03:04 codecov[bot]

@wgtdkp @abtink Could you help review this PR? Thanks!

xuyirio avatar Jul 28 '22 01:07 xuyirio