Review report

bitcoin/bitcoin: PR #36014

1 minor finding · 1 suggestion

Findings

Link

[minor] · Numeric equivalence merges link-local addnodes on different interfaces

When configured link-local peers differ only by IPv6 scope, startup now discards the second destination, and removal or lookup using that scope can affect the first entry.

Location: src/net.cpp:3915 (head).

Details and suggested fix

LookupNumeric preserves the scope ID, and socket construction uses it to select the interface. However, CService equality compares only the address and port, so this branch treats [fe80::1%2]:8333 and [fe80::1%3]:8333 as duplicates before checking their different host text. Startup previously retained both. With networking active and manual-connection capacity available, a failed first attempt leaves no connected CNode, allowing the second destination to be tried. Now only the retained scope is retried; restarting with the same configuration does not restore the omitted entry. The new shared lookup also makes remove and filtered getaddednodeinfo for %3 act on a stored %2 entry. Runtime addnode add already had this limitation. Require matching scopes in the numeric comparison, for example by additionally comparing canonical ToStringAddr() values, and test that same-scope aliases deduplicate while different scopes remain distinct. No configuration using the same link-local address on multiple interfaces was identified, so production impact remains unconfirmed.


Optional improvements

Link

[suggestion] · DNS case variants remain separate added nodes

DNS hostname case variants with the same effective port remain separate entries and can still cause redundant lookups and connection attempts while disconnected.

Location: src/net.cpp:3920 (head).

Details and suggested fix

SplitHostPort preserves case, so -addnode=Example.org and -addnode=example.org both survive this byte-for-byte comparison and appear in getaddednodeinfo. With name lookup enabled, networking active, and connection capacity available, each can reach Lookup and a separate attempt when the earlier attempt fails. This is existing behavior, not a regression, and the helper explicitly promises only the same host text. Compare ordinary DNS hostname text using ASCII case folding while retaining the effective-port check and original stored spelling, and add a mixed-case test. Onion and I2P case variants already match through the numeric branch. If literal case-sensitive matching is intentional, clarify that limitation in the release note's “same host and port” description.


Coverage details