addrman, rpc: classify linked-IPv4 addresses consistently #36746

pull brunoerg wants to merge 4 commits into bitcoin:master from brunoerg:2026-10-fuzz-addrman-getaddr-network changing 6 files +70 −4
  1. brunoerg commented at 4:44 PM on November 3, 2026: contributor

    Some addresses can be an IPv6 ones with an embedded IPv4 address belongs to. AddrMan::Size(), and so the per-network counts in getaddrmaninfo, use GetNetwork(), which returns ipv6 for these addresses. However, the network filter in GetAddr_() and the network / source_network labels in getnodeaddresses and getrawaddrman use GetNetClass(), which returns ipv4 for them.

    So on master, for example, for a node whose addrman holds a 6to4 or Teredo address:

    • getaddrmaninfo counts it under ipv6.
    • getnodeaddresses 0 "ipv6" doesn't return it.
    • getnodeaddresses 0 "ipv4" does return it, labelled ipv4.

    This PR changes all of this places to use GetNetwork(). This way the filter, labels and the counts agree. We should leave GetNetClass() usage for netgroup and bucketing decisions, where treating linked-IPv4 addresses as IPv4 is intended. If you pick the change in the fuzz target and run it without the other changes, it's expected to crash to reproduce the issue.

  2. addrman: use GetNetwork() when filtering in GetAddr_ 19fb5c16b2
  3. fuzz: check GetAddr network filtering in addrman target
    Network-filtered GetAddr() results must agree with the network
    classification used by Size().
    faa7ba3103
  4. rpc: use GetNetwork() for addrman entry network labels
    getnodeaddresses and getrawaddrman labelled entries with GetNetClass(),
    which reports linked-IPv4 addresses (6to4, Teredo, NAT64) as ipv4, while
    the getnodeaddresses network filter and the getaddrmaninfo counts use
    GetNetwork() and treat them as ipv6. Use GetNetwork() so filtered results
    match their labels.
    18abfefa5b
  5. DrahtBot commented at 4:45 PM on November 3, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    ACK willcl-ark, jpk68
    Concept ACK w0xlt

    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-->

  6. brunoerg force-pushed on Nov 3, 2026
  7. DrahtBot added the label CI failed on Nov 3, 2026
  8. brunoerg force-pushed on Nov 3, 2026
  9. doc: add release note for 36746 b7eeb2dbe3
  10. brunoerg force-pushed on Nov 3, 2026
  11. DrahtBot removed the label CI failed on Nov 3, 2026
  12. atsushi196323 commented at 5:36 AM on November 4, 2026: none

    On master, I reproduced that getaddrmaninfo counts a 6to4 address as ipv6, while getnodeaddresses treats it as ipv4. On b7eeb2d, I confirmed that both now report it as ipv6.

    I checked the callers of GetAddressesUnsafe. getaddr passes nullopt, so it is unaffected, and since ASMapHealthCheck() combines the IPv4 and IPv6 results, my reading is that its totals should not change.

    According to the code and the release note, linked-IPv4 addresses are still shown as ipv4 in getpeerinfo after this PR. Since the RPCs that deal with addrman are now consistent with each other, I think this difference is acceptable.

    I have not run the fuzz tests, and I have not checked getpeerinfo with real connections or tested with NAT64 / RFC6145 addresses.

  13. willcl-ark approved
  14. willcl-ark commented at 12:31 PM on November 4, 2026: member

    ACK b7eeb2dbe3a2fdfe70075c06133ebc382075d0db

    LGTM.

    I think this also afffects ASMapHealthCheck(), but as this combines all results there is no production difference as ipv4 and 6 are concatenated and linked to their ASes.

  15. jpk68 commented at 6:43 PM on November 4, 2026: contributor

    ACK b7eeb2dbe3a2fdfe70075c06133ebc382075d0db

  16. w0xlt commented at 12:02 AM on November 6, 2026: contributor

    Concept ACK


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-11-21 10:51 UTC

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