net_processing: set fDisconnect instead of calling DisconnectNode

bitcoin/bitcoin: PR #36894

1 suggestion

Optional improvements

Link

[suggestion] · peer_discouragement misses ordinary same-IP sibling coverage

The existing assertions would not detect restoring the old address-wide disconnect with its private-broadcast exclusion, leaving the PR's main behavior change unguarded.

Location: src/net_processing.cpp:5404 (head).

Details and suggested fix

In peer_discouragement, the ordinary inbound peers use different IPs. The only same-address sibling is nodes[3], a PRIVATE_BROADCAST connection that the base subnet helper already skipped. Its assertion catches a call to the head's unrestricted subnet helper, but not restoration of the old behavior. Add two ordinary INBOUND peers sharing a non-local IPv4 address, without NoBan permission, and register both with connman->AddTestNode before either misbehaves. Call UnitTestMisbehaving and then SendMessages on one. Assert that the offender has fDisconnect set, the sibling does not, and banman->IsDiscouraged is true for their shared address. This would distinguish base from head while checking that address discouragement remains intact. Avoid local addresses because the IsLocal() branch already disconnects only the offender on base.


Coverage details