net: treat RFC 9637 new IPv6 documentation range as invalid #36199

pull fjahr wants to merge 2 commits into bitcoin:master from fjahr:2026-09-doc-rfc changing 4 files +19 −4
  1. fjahr commented at 8:22 AM on September 9, 2026: contributor

    RFC 9637 was newly introduced in 2024 but we don't handle this yet. This pull handles it in the same way as RFC 3849 of which 9637 is an extension.

    This came up in #36196 because the new GetMappedAS() benchmark from #35285 asserts on these addresses being unmapped. New maps using --fill couldn't be embedded because the filling assigns these addresses. Making this range invalid in the code fixes the benchmarks.

  2. DrahtBot added the label P2P on Sep 9, 2026
  3. DrahtBot commented at 8:22 AM on September 9, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36199.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK willcl-ark, hodlinator, sedited, 0xB10C

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. fanquake added this to the milestone 32.0 on Sep 9, 2026
  5. in src/netaddress.cpp:443 in 30e6eb3b2d outdated
     439 | @@ -434,7 +440,7 @@ bool CNetAddr::IsValid() const
     440 |      }
     441 |  
     442 |      // documentation IPv6 address
     443 | -    if (IsRFC3849())
     444 | +    if (IsRFC3849() || IsRFC9637())
    


    willcl-ark commented at 9:25 AM on September 9, 2026:

    In 30e6eb3b2d77a21a9163f20d3e9d7e20f5bfaac7

    If we remove this addition, no tests fail as we don't do any kind of BOOST_CHECK(!ResolveIP("3FFF::").IsValid()) in netbase_tests.cpp.


    fjahr commented at 10:31 AM on September 9, 2026:

    Added, thanks!


    hodlinator commented at 10:49 AM on September 9, 2026:

    Rather than checking both

    BOOST_CHECK(!ResolveIP("3FFF::").IsRoutable());
    

    and

    BOOST_CHECK(!ResolveIP("3FFF::").IsValid());
    

    I think it would be better to only test IsValid() as initially suggested and also add a test for the general relationship between IsValid() and IsRoutable() in the fuzz test:

    --- a/src/test/fuzz/netaddress.cpp
    +++ b/src/test/fuzz/netaddress.cpp
    @@ -72,7 +72,8 @@ FUZZ_TARGET(netaddress)
         (void)net_addr.IsRFC6598();
         (void)net_addr.IsRFC7343();
         (void)net_addr.IsRFC9637();
    -    if (!net_addr.IsRoutable()) {
    +    const bool routable{net_addr.IsRoutable()};
    +    if (!routable) {
             assert(net_addr.GetNetwork() == Network::NET_UNROUTABLE || net_addr.GetNetwork() == Network::NET_INTERNAL);
         }
         if (net_addr.IsTor()) {
    @@ -84,7 +85,9 @@ FUZZ_TARGET(netaddress)
         if (net_addr.IsCJDNS()) {
             assert(net_addr.GetNetwork() == Network::NET_CJDNS);
         }
    -    (void)net_addr.IsValid();
    +    if (!net_addr.IsValid()) {
    +        assert(!routable);
    +    }
         (void)net_addr.ToStringAddr();
     
         const CSubNet sub_net{net_addr, fuzzed_data_provider.ConsumeIntegral<uint8_t>()};
    

    fjahr commented at 11:14 AM on September 9, 2026:

    Good suggestion, I dropped the IsRoutable check and added the fuzz coverage in a separate commit.

  6. willcl-ark commented at 9:26 AM on September 9, 2026: member

    Concept ACK

  7. hodlinator approved
  8. hodlinator commented at 9:29 AM on September 9, 2026: contributor

    ACK 30e6eb3b2d77a21a9163f20d3e9d7e20f5bfaac7

    Adds calls in the same places as IsRFC3849() (and similarly to IsRFC5737() which is IPv4).

    Makes the ASMapGetMappedASUnmappedv6() which verifies RFC 9637 address 3fff::1 confirm that it is unmapped, regardless of whether the ASMap binary blob contains it. Call chain verified in debugger: ASMapGetMappedASUnmappedv6() -> BenchGetMappedAS() -> NetGroupManager::GetMappedAS() -> CNetAddr::GetNetClass() -> CNetAddr::IsRoutable() -> CNetAddr::IsValid() -> CNetAddr::IsRFC9637()

    One could possibly prevent the ASMap filling optimization from assigning specific ranges to begin with. But the current PR approach should be implemented regardless.

  9. DrahtBot requested review from willcl-ark on Sep 9, 2026
  10. fjahr force-pushed on Sep 9, 2026
  11. fjahr commented at 10:47 AM on September 9, 2026: contributor

    Added test coverage as suggested by @willcl-ark , thanks!

    One could possibly prevent the ASMap filling optimization from assigning specific ranges to begin with. But the current PR approach should be implemented regardless.

    Seems doable but we should still not make assumptions about the user-supplied asmap file being clean, so we need to handle it on the core side either way, I think.

  12. net: treat RFC 9637 new IPv6 documentation range as invalid e6c775c6d6
  13. fuzz: assert invalid addresses are not routable
    Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
    b48a27691d
  14. fjahr force-pushed on Sep 9, 2026
  15. DrahtBot added the label CI failed on Sep 9, 2026
  16. willcl-ark approved
  17. willcl-ark commented at 11:29 AM on September 9, 2026: member

    ACK b48a27691ded8c9014be59b190726159b0bff038

    Having the IsValid() test covering the changed behavior and the fuzz assertion checking that invalid addresses are never routable is neat!

  18. DrahtBot requested review from hodlinator on Sep 9, 2026
  19. hodlinator approved
  20. hodlinator commented at 11:44 AM on September 9, 2026: contributor

    re-ACK b48a27691ded8c9014be59b190726159b0bff038

    Thanks for incorporating my fuzz test suggestion.

  21. DrahtBot removed the label CI failed on Sep 9, 2026
  22. sedited approved
  23. sedited commented at 2:14 PM on September 9, 2026: contributor

    ACK b48a27691ded8c9014be59b190726159b0bff038

  24. 0xB10C commented at 2:19 PM on September 9, 2026: contributor

    ACK b48a27691ded8c9014be59b190726159b0bff038

    Thanks!

  25. sedited merged this on Sep 9, 2026
  26. sedited closed this on Sep 9, 2026

  27. fanquake referenced this in commit 5a5b1ed747 on Sep 10, 2026
  28. fanquake commented at 10:10 AM on September 10, 2026: member

    Backported to 31.x in #35969.

  29. fanquake referenced this in commit a0ae200d99 on Sep 10, 2026
  30. fanquake referenced this in commit 83456f92d0 on Sep 10, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-09-10 13:50 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me