A port keeps the address and the neighbour its document states (#1521) #1553
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1553
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/1115-2206"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1521
Two facts a port carries were dropped on save, and they are the two an importer needs.
The address.
serialize()never wroteinterfaces[].mac, andfromJSON()renumbered every port from thelocally-administered base, so a document that stated
00:1b:21:aa:bb:cccame back as an invented02:00:00:00:00:00.The neighbour. The per-port
lldprecord was the reverse fault: written by every save since LLDP existed andread by nobody, so a reopened board's neighbour table came back empty while the file still listed the neighbours.
What changed
Device.serialize()writesmacfor physical ports. A subinterface states none: it has no address of its own, itborrows its parent's.
Device.hydrate()restores a stated address, and only a unicast, non-zero one -Device.statedMac()is the singlepredicate, so the writer, the reader and the load report cannot disagree about what a port can have.
Topology._assignMacs()keeps a stated address instead of overwriting it, and holds uniqueness by skippingaddresses a port on the board already holds, so a device added after a load cannot collide with one the document
stated. Two ports given one address: the first keeps it, the second gets a free one, reported as
E_IFACE_DUPLICATE_MAC. An address no port can have is not adopted and is reported asE_IFACE_BAD_MAC.Device.hydrate()restores a per-portlldprecord, so a reopened board knows the neighbours its document stateswithout announcing again - and a record that names nobody is not restored.
Tests
test/port-roundtrip.test.js: 13 new assertions - the document states the address a port has, a stated address iswhat the port comes back with, re-saving is byte-identical, a duplicate is resolved and reported, broadcast and
nonsense addresses are refused and reported, a device added after the load cannot collide, and a subinterface
states no address and borrows its parent's.
test/neighbours-on-load.test.js: the restore assertions, plus a fix to a check that looked for neighbour rows onthe device (
d.lldp) where nothing is ever written, instead of on its ports - which is how a field no loaderread survived this long.
npm test: 254 suites, 9284 assertions, 0 failures.node scripts/syntax-check.js: 324 files, all OK.node examples/build-examples.js): 113 added lines across the four labs, all onemacperphysical port.
Documented in
docs/ARCHITECTURE.mdunder "A saved board is the lab that was saved".22f309517506c693fa2106c693fa21929b1fcedd