A netmask is a run of ones, and one rule says so (#1249) #1250
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!1250
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/mask-rule"
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?
A netmask is a run of ones, and one rule says so
Fixes #1249.
255.0.255.0is a valid IPv4 address and not a netmask — it has no prefix length. Four places answeredthe question "what prefix is this mask" four different ways:
net.prefixOf()dhcp.maskContiguous()ospf.maskPrefix()app.maskBits()255.0.255.0255.255.255.253255.255.0.255So the router accepted it, routed on the raw mask, and the inspector summarised it as a number that
describes nothing — in the one panel you open to find out why a link behaves oddly.
Second half, quieter:
ip address 10.0.0.1 24stored the string"24". Anything parsing a dotted mask— the front panel included — reads that as
0.0.0.24and prints/2.Third:
ip address 10.9.9.9 garbageprinted% Error: Invalid IPv4 address: garbage— the wrongargument, because mask parsing was left to throw through the address path.
Now
engine/net.jsowns the rule:isContiguousMask(),maskFromPrefix(),prefixOfInt().maskToInt()keeps its contract — a bare number is still a prefix length — so no caller changes meaning.
untouched; a bad address is still reported as an address.
guess.
own copies; their contracts (a validation error, a
nullprefix) are unchanged.?for a mask with no prefix length, and a bare number read as aprefix length.
Evidence
test/mask-rule.test.js— 31 checks:prefixOf,prefixOfInt, the panel, and the short spelling;?for eachrather than a plausible number;
address still reported as an address, an out-of-range prefix length as a mask error;
/24stored dotted, printed dotted byshow running-config, and replayed to the same address and mask;Reverting
engine/cli.jsfails 11 of the 31.docs/CLI.mddocuments the rule and the stored form under "Interface-mode commands".Suite: 138 suites, 5,964 assertions, 0 failed.