Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[netdata-publisher] optimize multiple ULA-based route prefixes #8827

Closed
wants to merge 1 commit into from

Conversation

abtink
Copy link
Member

@abtink abtink commented Mar 3, 2023

This commit adds a new mechanism in NetworkData::Publisher to optimize published route prefixes that are within ULA range fc00::/7 (can be covered by this shorter prefix). Whenever there are more than three such route prefixes (excluding NAT64 prefixes) being published, they are marked as optimized and replaced with fc00::/7 route prefix. The compact fc00::/7 route is added using highest preference level among all prefixes being optimized.

OPENTHREAD_CONFIG_NETDATA_PUBLISHER_OPTIMIZE_ULA_ROUTES enables this feature. It is enabled by default.

This commit adds a new test cases covering behavior of the new feature in detail, in particular when many route prefixes are published together or separately and we go over or below the threshold.


This is related to SPEC-1130.

@size-report
Copy link

size-report bot commented Mar 3, 2023

Size Report of OpenThread

Merging #8827 into main(0a79c30).

name branch text data bss total
ot-cli-ftd_1.1 main 471008 776 63836 535620
#8827 471552 776 63836 536164
+/- +544 0 0 +544
ot-cli-mtd_1.1 main 390336 776 53868 444980
#8827 390880 776 53868 445524
+/- +544 0 0 +544
ot-ncp-ftd_1.1 main 445252 776 59192 505220
#8827 445268 776 59192 505236
+/- +16 0 0 +16
ot-ncp-mtd_1.1 main 367996 776 49232 418004
#8827 368012 776 49232 418020
+/- +16 0 0 +16
ot-rcp_1.1 main 60156 564 19964 80684
#8827 60156 564 19964 80684
+/- 0 0 0 0
libopenthread-cli-ftd.a_1.1 main 52830 0 7868 60698
#8827 52830 0 7868 60698
+/- 0 0 0 0
libopenthread-cli-mtd.a_1.1 main 44512 0 7860 52372
#8827 44512 0 7860 52372
+/- 0 0 0 0
libopenthread-ftd.a_1.1 main 244755 20 38526 283301
#8827 245264 20 38526 283810
+/- +509 0 0 +509
libopenthread-mtd.a_1.1 main 178946 20 28566 207532
#8827 179455 20 28566 208041
+/- +509 0 0 +509
libopenthread-ncp-ftd.a_1.1 main 31663 0 5852 37515
#8827 31663 0 5852 37515
+/- 0 0 0 0
libopenthread-ncp-mtd.a_1.1 main 26505 0 5852 32357
#8827 26505 0 5852 32357
+/- 0 0 0 0
libopenthread-rcp.a_1.1 main 8992 0 4988 13980
#8827 8992 0 4988 13980
+/- 0 0 0 0
libopenthread-radio.a_1.1 main 18053 0 174 18227
#8827 18053 0 174 18227
+/- 0 0 0 0
ot-cli-ftd_1.3 main 493072 776 73316 567164
#8827 493624 776 73316 567716
+/- +552 0 0 +552
ot-cli-mtd_1.3 main 405336 776 55092 461204
#8827 405888 776 55092 461756
+/- +552 0 0 +552
ot-ncp-ftd_1.3 main 466244 776 68664 535684
#8827 466260 776 68664 535700
+/- +16 0 0 +16
ot-ncp-mtd_1.3 main 381492 776 50448 432716
#8827 381508 776 50448 432732
+/- +16 0 0 +16
ot-rcp_1.3 main 62516 564 20532 83612
#8827 62516 564 20532 83612
+/- 0 0 0 0
libopenthread-cli-ftd.a_1.3 main 55715 0 7868 63583
#8827 55715 0 7868 63583
+/- 0 0 0 0
libopenthread-cli-mtd.a_1.3 main 46814 0 7860 54674
#8827 46814 0 7860 54674
+/- 0 0 0 0
libopenthread-ftd.a_1.3 main 262888 20 47462 310370
#8827 263381 20 47462 310863
+/- +493 0 0 +493
libopenthread-mtd.a_1.3 main 190379 20 29246 219645
#8827 190888 20 29246 220154
+/- +509 0 0 +509
libopenthread-ncp-ftd.a_1.3 main 33501 0 5852 39353
#8827 33501 0 5852 39353
+/- 0 0 0 0
libopenthread-ncp-mtd.a_1.3 main 27871 0 5852 33723
#8827 27871 0 5852 33723
+/- 0 0 0 0
libopenthread-rcp.a_1.3 main 9158 0 4988 14146
#8827 9158 0 4988 14146
+/- 0 0 0 0
libopenthread-radio.a_1.3 main 18938 0 206 19144
#8827 18938 0 206 19144
+/- 0 0 0 0

@codecov
Copy link

codecov bot commented Mar 3, 2023

Codecov Report

Merging #8827 (8b39231) into main (0a79c30) will increase coverage by 2.56%.
The diff coverage is 93.75%.

❗ Current head 8b39231 differs from pull request most recent head 56d4164. Consider uploading reports for the commit 56d4164 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8827      +/-   ##
==========================================
+ Coverage   79.89%   82.46%   +2.56%     
==========================================
  Files         518      535      +17     
  Lines       70747    72830    +2083     
==========================================
+ Hits        56523    60056    +3533     
+ Misses      14224    12774    -1450     
Impacted Files Coverage Δ
tests/unit/test_routing_manager.cpp 100.00% <ø> (ø)
src/core/thread/network_data_publisher.cpp 90.25% <93.47%> (+1.38%) ⬆️
src/core/border_router/routing_manager.cpp 87.17% <100.00%> (+84.16%) ⬆️
src/core/thread/network_data_publisher.hpp 82.05% <100.00%> (+0.47%) ⬆️
src/core/mac/mac_types.cpp 75.22% <0.00%> (-15.40%) ⬇️
src/core/mac/data_poll_handler.hpp 88.23% <0.00%> (-11.77%) ⬇️
src/core/net/ip4_types.hpp 83.87% <0.00%> (-8.99%) ⬇️
src/core/net/srp_client.hpp 85.24% <0.00%> (-8.20%) ⬇️
src/core/coap/coap_secure.hpp 89.28% <0.00%> (-6.87%) ⬇️
src/core/api/coap_secure_api.cpp 66.10% <0.00%> (-4.81%) ⬇️
... and 114 more

@abtink abtink force-pushed the nd/optimize-ula-routes branch 2 times, most recently from d1cb79e to 8b39231 Compare March 4, 2023 00:07
Copy link
Contributor

@EskoDijk EskoDijk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments inline!

Just to check: based on the size report, I see +400 for CLI-MTD and CLI-FTD builds. So that is because the CLI builds contain a complete netdata-publisher, including any features that would normally be only used by a BR, right? The proposed test also uses this feature on FTDs/Routers. Also makes it useful for simulations to emulate a BR behavior.

}
else
{
IgnoreError(Get<Local>().RemoveHasRoutePrefix(AsCoreType(&kCompactPrefix)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to remove a previously-added kCompactPrefix. But what about these situations

  1. A kCompactPrefix was never added before (but there is a real route to fc00::/7 to be advertised) -> does this mean the 'real' route gets removed unintendedly?
  2. A kCompactPrefix was added before, but there's also a real route to fc00::/7 -> could it mean the real route is removed instead of the intended kCompactPrefix entry?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @EskoDijk . Yes. The two cases you mention should be covered.

  • On second case (fc00::/7 is itself being published):

    • We remove prefix first, but then it will be re-added from AddIfOptimized() call below (the order here is important).
    • We cover it in the test (i.e. we publish fc00::/7 and then we add/remove other prefixes to go above/below the N=3 threshold (last steps in test-019).
  • On first case:

    • It should work with current code (would rely on the fact that publisher would not immediately add prefix).
    • But to be safer I changed the code to track if/when we add compact prefix (use a new boolean in new push).
    • Also added this situation in the test test-019.


def check_netdata_step11():
routes = r2.get_netdata_routes()
verify(len(routes) == 3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did the routes fd01:3:0:0::/64 and fd01:4:0:0::/64 go to? Does this mean that more-specific routes are automatically suppressed, in case of ULA routes? Why do this for ULAs but not for non-ULA prefixes then? Seems like we should discuss this in SPEC-1130.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it counts N=3 ULA prefixes now, based on the newly added fc00::/7 ? And then all prefixes are optimized into fc00::/7.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we get here we have the following prefixes being published on r1:

  • fc00::/7 s med (this is explicitly published - covering the case from above)
  • fd01:3:0:0::/64 s med
  • fd01:4:0:0::/64 s low
  • fd01:5:0:0:0:0::/96 sn med (NAT64 flag so not counted).

The first 3 are "optimizable" (have fc00::/7 as sub-prefix) and can be covered by fc00::/7, so we are above N=3 threshold and they are all replaced with compact prefix (which happens to be one the published prefixes).

This commit adds a new mechanism in `NetworkData::Publisher` to
optimize published route prefixes that are within ULA range
`fc00::/7` (can be covered by this shorter prefix). Whenever there
are more than three such route prefixes (excluding NAT64 prefixes)
being published, they are marked as optimized and replaced with
`fc00::/7` route prefix. The compact `fc00::/7` route is added using
highest preference level among all prefixes being optimized.

`OPENTHREAD_CONFIG_NETDATA_PUBLISHER_OPTIMIZE_ULA_ROUTES` enables this
feature. It is enabled by default.

This commit adds a new test cases covering behavior of the new feature
in detail, in particular when many route prefixes are published
together or separately and we go over or below the threshold.
@abtink
Copy link
Member Author

abtink commented Mar 6, 2023

Just to check: based on the size report, I see +400 for CLI-MTD and CLI-FTD builds. So that is because the CLI builds contain a complete netdata-publisher, including any features that would normally be only used by a BR, right? The proposed test also uses this feature on FTDs/Routers. Also makes it useful for simulations to emulate a BR behavior.

Yes. Correct. The code-size check build script seems to include OT_BORDER_ROUTER and OT_NETDATA_PUBLISHER flags (it does not include OT_BORDER_ROUTING though which is the larger RoutingManager module listening for RA and emits RA and discover prefixes). At some point there were discussions/ideas to add a new "code size check" flavor for "BR" type devcies (which is good idea but I guess increases the reprted table length :)).

size_nrf52840_version()
{
local options=(
"-DOT_ANYCAST_LOCATOR=ON"
"-DOT_BORDER_AGENT=ON"
"-DOT_BORDER_ROUTER=ON"
"-DOT_CHANNEL_MANAGER=ON"
"-DOT_CHANNEL_MONITOR=ON"
"-DOT_COAP=ON"
"-DOT_COAPS=ON"
"-DOT_COMMISSIONER=ON"
"-DOT_DATASET_UPDATER=ON"
"-DOT_DHCP6_CLIENT=ON"
"-DOT_DHCP6_SERVER=ON"
"-DOT_DIAGNOSTIC=ON"
"-DOT_DNSSD_SERVER=ON"
"-DOT_DNS_CLIENT=ON"
"-DOT_ECDSA=ON"
"-DOT_FULL_LOGS=ON"
"-DOT_JAM_DETECTION=ON"
"-DOT_JOINER=ON"
"-DOT_LINK_RAW=ON"
"-DOT_MAC_FILTER=ON"
"-DOT_MESSAGE_USE_HEAP=ON"
"-DOT_MTD_NETDIAG=ON"
"-DOT_NETDATA_PUBLISHER=ON"
"-DOT_PING_SENDER=ON"
"-DOT_SERVICE=ON"
"-DOT_SLAAC=ON"
"-DOT_SNTP_CLIENT=ON"
"-DOT_SRP_CLIENT=ON"
"-DOT_SRP_SERVER=ON"
"-DOT_TIME_SYNC=ON"
"-DOT_UDP_FORWARD=ON"
"-DOT_UPTIME=ON"
)

@abtink
Copy link
Member Author

abtink commented Apr 8, 2023

Closing this PR since discussion the SPEC-1130 moved towards a different approach.

@abtink abtink closed this Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants