The address two boxes answered for #1474

Merged
jaylouisw merged 1 commit from fix/arp-conflict into main 2026-11-12 04:00:43 +00:00
Owner

What was wrong

Two hosts in one VLAN, both configured 10.0.0.10:

r1> ping 10.0.0.10 4
Type escape sequence to abort.
Sending 4, 100-byte ICMP Echos to 10.0.0.10, timeout is 2 seconds:
!!!!
Success rate is 100 percent (4/4)

r1> show ip arp
Protocol  Address          Age (min)  Hardware Addr     Interface
Internet  10.0.0.10        -          02:00:00:00:03:00 Gi0/0/1

Nothing in that output is a lie. Nothing in it is the whole truth either. Two boxes hold the address; the table shows one of them, with the confidence of a row that has no competitor, and the next ping may go to the other one.

Why it happens

The ARP table is keyed by address alone, so Device.learnArp() overwrote the first answer with the second and the fact went nowhere. The binding is therefore the last reply that arrived — which is why this presents as "the lab is flaky" rather than "the lab has a duplicate address", and why it survives a save, a reload and a fresh run. No view, no log and no event mentioned it.

The router is the only place both answers exist, so that is where the fact has to be written down.

What changed

  • Device.noteArpConflict(ip, mac, port) records an address answered by a second hardware address: both MACs, the port they were heard on. It records nothing when the answer comes from the same MAC (a neighbour refreshing its entry is the ordinary case) and nothing when the second answer arrives on a different port — two subnets may legitimately reuse an address, and manufacturing a conflict out of that would be its own defect.

  • The binding itself is unchanged. The table still holds the most recent answer, because that is what the engine acts on. The note is added beside it, never instead of it.

  • show ip arp says it in a sentence, under the table it qualifies:

    10.0.0.10 is claimed by 2 hardware addresses on Gi0/0/1: 02:00:00:00:02:00, 02:00:00:00:03:00
      this row shows the one that answered last; traffic to 10.0.0.10 goes to whichever answers next
    

    The second line is the part an operator cannot infer from the first — a contested address is not a curiosity, it is traffic that moves.

  • The clash travels with the row: Device.arpRows() carries conflict, so a panel reading the same data cannot present the address as settled, and an arp-conflict event goes on the wire ({type:'arp-conflict', dev, iface, ip, macs, vlan}) for the packet view.

Deliberately not done

The two hosts themselves stay quiet. A real stack detects a duplicate address from the other box's ARP claim and logs %IP-4-DUPADDR; modelling that is a new protocol behaviour rather than a view telling the truth about data it already had, so it is left as a decision instead of being smuggled in with this fix.

Evidence

$ node test/arp-conflict.test.js              # with the fix
26 passed, 0 failed

$ git stash push engine/ && node test/arp-conflict.test.js
16 passed, 10 failed                         # the assertions test the behaviour, not themselves

Neighbours green: show-arp 28, arp-ageing 31, runtime-agreement 10, show-argument-refusal 77, show-ip-spellings 70, dhcp-bindings 51, lldp 27, vrrp 94, ping-ipv6 43. Syntax 303 files OK. Full suite: 235 suites, 8809 assertions, 0 failed (/tmp/t261.log).

One thing worth a reviewer's eye: the conflict is recorded in _learnArp() in the simulator, which is the single funnel every ARP learn passes through (request branch, reply branch, gratuitous ARP), so a clash cannot be missed by one code path updating the table privately.

## What was wrong Two hosts in one VLAN, both configured `10.0.0.10`: ``` r1> ping 10.0.0.10 4 Type escape sequence to abort. Sending 4, 100-byte ICMP Echos to 10.0.0.10, timeout is 2 seconds: !!!! Success rate is 100 percent (4/4) r1> show ip arp Protocol Address Age (min) Hardware Addr Interface Internet 10.0.0.10 - 02:00:00:00:03:00 Gi0/0/1 ``` Nothing in that output is a lie. Nothing in it is the whole truth either. Two boxes hold the address; the table shows one of them, with the confidence of a row that has no competitor, and the next ping may go to the other one. ## Why it happens The ARP table is keyed by address alone, so `Device.learnArp()` overwrote the first answer with the second and the fact went nowhere. The binding is therefore *the last reply that arrived* — which is why this presents as "the lab is flaky" rather than "the lab has a duplicate address", and why it survives a save, a reload and a fresh run. No view, no log and no event mentioned it. The router is the only place both answers exist, so that is where the fact has to be written down. ## What changed - **`Device.noteArpConflict(ip, mac, port)`** records an address answered by a second hardware address: both MACs, the port they were heard on. It records nothing when the answer comes from the **same** MAC (a neighbour refreshing its entry is the ordinary case) and nothing when the second answer arrives on a **different port** — two subnets may legitimately reuse an address, and manufacturing a conflict out of that would be its own defect. - **The binding itself is unchanged.** The table still holds the most recent answer, because that is what the engine acts on. The note is added beside it, never instead of it. - **`show ip arp` says it in a sentence**, under the table it qualifies: ``` 10.0.0.10 is claimed by 2 hardware addresses on Gi0/0/1: 02:00:00:00:02:00, 02:00:00:00:03:00 this row shows the one that answered last; traffic to 10.0.0.10 goes to whichever answers next ``` The second line is the part an operator cannot infer from the first — a contested address is not a curiosity, it is traffic that moves. - **The clash travels with the row**: `Device.arpRows()` carries `conflict`, so a panel reading the same data cannot present the address as settled, and an `arp-conflict` event goes on the wire (`{type:'arp-conflict', dev, iface, ip, macs, vlan}`) for the packet view. ## Deliberately not done The two hosts themselves stay quiet. A real stack detects a duplicate address from the other box's ARP claim and logs `%IP-4-DUPADDR`; modelling that is a new protocol behaviour rather than a view telling the truth about data it already had, so it is left as a decision instead of being smuggled in with this fix. ## Evidence ``` $ node test/arp-conflict.test.js # with the fix 26 passed, 0 failed $ git stash push engine/ && node test/arp-conflict.test.js 16 passed, 10 failed # the assertions test the behaviour, not themselves ``` Neighbours green: `show-arp` 28, `arp-ageing` 31, `runtime-agreement` 10, `show-argument-refusal` 77, `show-ip-spellings` 70, `dhcp-bindings` 51, `lldp` 27, `vrrp` 94, `ping-ipv6` 43. Syntax 303 files OK. Full suite: 235 suites, 8809 assertions, 0 failed (/tmp/t261.log). One thing worth a reviewer's eye: the conflict is recorded in `_learnArp()` in the simulator, which is the single funnel every ARP learn passes through (request branch, reply branch, gratuitous ARP), so a clash cannot be missed by one code path updating the table privately.
The address two boxes answered for (#1473)
All checks were successful
CI / Classify the change (pull_request) Successful in 12s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 12s
CI / Test (Node 20) (pull_request) Successful in 3m11s
CI / Test (Node 18) (pull_request) Successful in 3m23s
CI / Server smoke test (pull_request) Successful in 28s
CI / Docker build (pull_request) Successful in 45s
CI / Test (Node 22) (pull_request) Successful in 2m56s
5aca4f5a7f
two hosts in one VLAN, both configured 10.0.0.10

  r1> ping 10.0.0.10 4        r1> show ip arp
  !!!!                        Internet  10.0.0.10  -  02:00:00:00:03:00  Gi0/0/1
  Success rate is 100 percent

Nothing in that is a lie and nothing in it is the whole truth. The ARP table is
keyed by address alone, so learnArp() overwrote the first answer with the second
and the fact went nowhere: the binding is whatever reply arrived last, which is
why this presents as "the lab is flaky" rather than "there are two claimants",
and why it survives a save, a reload and a fresh run. No view, log or event
mentioned it.

  * device.js: noteArpConflict() records an address answered by a second
    hardware address, keeping both MACs and the port they were heard on. Silent
    when the same MAC re-answers (a neighbour refreshing its entry is the
    ordinary case) and silent when the second answer arrives on a different port,
    because two subnets may legitimately reuse an address - inventing a conflict
    out of that would be its own defect. arpRows() carries it, so any panel
    reading the same data cannot present the address as settled;
  * simulator.js: _learnArp() is the single funnel every ARP learn passes
    through (request, reply, gratuitous), and it notes the clash there and emits
    an arp-conflict event for the packet view;
  * cli.js: `show ip arp` says it in a sentence under the table it qualifies -
    both MACs, the port, and the consequence, which is the part an operator
    cannot infer: "traffic to 10.0.0.10 goes to whichever answers next". The
    binding itself is unchanged; the note is added beside it, not instead of it.

Deliberately not done: the two hosts stay quiet. A real stack detects a
duplicate address from the other box's ARP claim and logs %IP-4-DUPADDR, and
modelling that is a new protocol behaviour rather than a view telling the truth
about data it already had - a decision, not a side effect of this fix.

Evidence: test/arp-conflict.test.js 26 checks, reverting engine/ gives 16 passed
and 10 failed. Neighbours green: show-arp 28, arp-ageing 31, runtime-agreement
10, show-argument-refusal 77, show-ip-spellings 70, dhcp-bindings 51, lldp 27,
vrrp 94, ping-ipv6 43. Syntax 303 files OK. Suite 235 suites, 8809 assertions,
0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-12 04:00:40 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1474
No description provided.