An address is an address (#1411) #1412
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!1412
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/one-address-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?
An address is an address. Fixes #1411.
Found by asking one question of every door that takes an address: what happens if I type one that cannot exist?
Eight doors took it, because
net.isIp()asked the wrong question: four dotted groups of one to three digits, so300.1.1.1and10.0.0.999were addresses as far as every caller was concerned.ipToInt()has always checkedthe octets — that is why
ip address,vrrp 1 ipandpingrefused the same value — andpinghad alreadyworked around this by writing a private strict helper beside the weak predicate instead of fixing it (#1379).
What changed
net.isIp()asks the parser (ipToInt), so every caller that already used it — the DHCP pool validator, the OSPFinterface checks, the console doors — gets the right answer at once, and the six hand-written copies of the shape
regex in
engine/cli.jsplus two inengine/bgp.jsare gone. Each door quotes the value it refused, and the NATand BGP doors name the offending address rather than falling back to a usage line.
ip route"validated" its mask by callingmaskToInt()and throwing the result away, andmaskToInt()turns a non-contiguous mask into an integer rather than refusing it — soip route 192.0.2.0 255.0.255.0 10.1.1.9answeredRoute added: 192.0.2.0/8and installed a prefix nobody askedfor. It now applies the contiguity rule and the sentence
ip addresshas always used, and a NAT pool netmask isasked the same question.
ip route <dest> <mask>with neither a next hop nor aninterface was accepted as
on-link, and the table then described it with "no next hop: ARP for the destination onthat segment" — naming a segment the command never mentioned. It is now an incomplete command. The
interface-only form is still legal and still carries its caveat.
access-list 10 permit 300.1.1.0 0.0.0.255answered% [object Object]: the refusal printed the error objectinstead of its message.
Evidence
test/address-rule.test.js— 26 checks. The predicate refuses300.1.1.1,10.0.0.999,9999.1.1.1,1.2.3,1.2.3.4.5,'', a word and a missing value, and still accepts the whole legal range; eight doors refuse with thevalue quoted and never reach a config; the BGP neighbour names the address; the ACL refusal is a sentence; a
non-contiguous mask is refused in both directions while
/24as a prefix length and a real/25still work; a routewith no next hop is refused and never appears in the table or the config while the interface-only form still works
and still warns; a 50-case matrix (five impossible addresses × ten doors) leaves nothing in a
show running-configor a
show ip route; the seven legal forms are all still accepted (no over-refusal); and a sweep over every modelthat can route (700+) stores none of them.
Reverting
engine/net.jsfails 6 of the 26,engine/cli.js11.test/nat-cli.test.js: its "bad address gets the usage line" assertion pinned the old ambiguous answer; it nowasserts the address is named, and that a missing operand still gets the usage line.
docs/CLI.md: "An address is an address", with the mask and no-next-hop rules beside it.Suite: 207 suites, 7,965 assertions, 0 failed. Syntax: 275 files, OK.
Found by asking one question of every door that takes an address: what happens if I type one that cannot exist? r1(config)#ip name-server 300.1.1.1 → Name server 300.1.1.1 r1(config)#ip default-gateway 300.1.1.1 → Default gateway: 300.1.1.1 r1(config)#ip route 300.1.1.0 255.255.255.0 10.1.1.9 → Route added: 300.1.1.0/24 via 10.1.1.9 r1(config)#ip route 192.0.2.0 255.255.255.0 300.1.1.9 → Route added: 192.0.2.0/24 via 300.1.1.9 r1(config)#ip nat pool NP 300.1.1.1 300.1.1.9 netmask 255.255.255.0 → NAT pool "NP" 300.1.1.1 - 300.1.1.9 netmask 255.255.255.0 r1(config-router)#neighbor 300.1.1.1 remote-as 65002 → BGP neighbor 300.1.1.1 remote-as 65002 Eight doors took it, because `net.isIp()` asked the wrong question: four dotted groups of one to three digits, so `300.1.1.1` and `10.0.0.999` were addresses. `ipToInt()` has always checked the octets - that is why `ip address`, `vrrp 1 ip` and `ping` refused the same value - and `ping` had already worked around this by writing a private strict helper beside the weak predicate instead of fixing it (#1379). Fixed: `net.isIp()` asks the parser (`ipToInt`), so every caller that already used it - the DHCP pool validator, the OSPF interface checks, the console doors - gets the right answer at once, and the six hand-written copies of the shape regex in `engine/cli.js` plus two in `engine/bgp.js` are gone. Each door quotes the value it refused, and the NAT and BGP doors name the offending address instead of falling back to a usage line. Two neighbours of the same mistake, found in the same sweep: * **A mask is a mask.** `ip route` "validated" its mask by calling `maskToInt()` and throwing the result away, and `maskToInt()` turns a non-contiguous mask into an integer rather than refusing it - so `ip route 192.0.2.0 255.0.255.0 10.1.1.9` answered `Route added: 192.0.2.0/8` and installed a prefix nobody asked for. It now applies the contiguity rule and the sentence `ip address` has always used, and a NAT pool netmask is asked the same question. * **A route with nowhere to go is not installed.** `ip route <dest> <mask>` with neither a next hop nor an interface was accepted as `on-link`, and the table then described it with "no next hop: ARP for the destination on that segment" - naming a segment the command never mentioned. It is now an incomplete command. The interface-only form is still legal and still carries its caveat. * `access-list 10 permit 300.1.1.0 0.0.0.255` answered `% [object Object]`: the refusal printed the error object instead of its message. Evidence: `test/address-rule.test.js`, 26 checks. The predicate refuses `300.1.1.1`, `10.0.0.999`, `9999.1.1.1`, `1.2.3`, `1.2.3.4.5`, `''`, a word and a missing value, and still accepts the whole legal range; eight doors refuse with the value quoted and never reach a config; the BGP neighbour names the address; the ACL refusal is a sentence; a non-contiguous mask is refused in both directions while `/24` as a prefix length and a real `/25` still work; a route with no next hop is refused and never appears in the table or the config while the interface-only form still works and still warns; a 50-case matrix (five impossible addresses × ten doors) leaves nothing in a `show running-config` or a `show ip route`; the seven legal forms are all still accepted (no over-refusal); and a sweep over every model that can route (700+) stores none of them. Reverting `engine/net.js` fails 6 of the 26, `engine/cli.js` 11. `test/nat-cli.test.js`: its "bad address gets the usage line" assertion pinned the old ambiguous answer; it now asserts the address is named, and that a missing operand still gets the usage line. docs/CLI.md: "An address is an address", with the mask and no-next-hop rules beside it. Suite: 207 suites, 7,965 assertions, 0 failed. Syntax: 275 files, OK.