Skip to content

topicindex/search: asked set stored only node IDs, leaking IP-limit slot on removal #88

Description

@srene

Problem

In the topic search table (p2p/discover/topicindex/search.go), each bucket's asked set was a map[enode.ID]struct{} — it stored only node IDs, not the nodes. The bucket's IP-limit tracker (b.ips, searchBucketIPLimit = 1 per /24) gets an entry when a node is first added to new, and setAsked moves the node new → asked without touching b.ips.

Search.removeNode (added in #71) could therefore only free the IP-limit entry for nodes still in new, because that's the only set holding the *enode.Node (and thus the IP). Removing a node that had already moved to asked would drop it from the bucket but leave its /24 reserved for the rest of the search — blocking a same-subnet replacement (limit is 1 per /24).

This was not reachable on any current path: HandleErrorResponse only ever runs on a node still in new (a queried-but-unanswered node is not setAsked until a successful response, and answered nodes are never re-queried). It was a latent footgun — any future change that removed an asked node would silently leak the IP slot.

Fix

asked now stores *enode.Node (mirroring new), and removeNode releases the IP-limit entry whether the node was in new or asked. Regression test TestSearchRemoveAskedNodeFreesIP fails on the old code (reason=iplimit) and passes after.

Fixed in #71.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions