A netmask is validated nowhere, and four modules disagree about what 255.0.255.0 means #1249

Closed
opened 2026-11-09 18:39:32 +00:00 by jaylouisw · 0 comments
Owner

What happens

ip address accepts a mask that is not a netmask, and the components that read that mask disagree about
what it means:

R1(config-if)#ip address 10.9.9.9 255.0.255.0
IP address set on Gi0: 10.9.9.9/8              <- accepted, read as /8 by the engine

255.0.255.0 is a valid IPv4 address and not a netmask: it has no prefix length. Measured, on four
implementations of the same question:

mask engine/net.js prefixOf() engine/dhcp.js maskContiguous() engine/ospf.js maskPrefix() web/app.js maskBits()
255.0.255.0 8 false null 16
255.255.255.253 30 false null 31
255.255.0.255 16 false null 24

So the console accepted it, the router routes on the raw mask, and the inspector you open to find out why
the link behaves oddly summarises it as /16 — a number that describes nothing.

The quieter half

R1(config-if)#ip address 10.0.0.1 24

That stored the string "24". Anything that parses a dotted mask — including the front panel — reads it as
0.0.0.24 and prints /2.

Third, smaller: the refusal printed the wrong argument.

R1(config-if)#ip address 10.9.9.9 garbage
% Error: Invalid IPv4 address: garbage          <- it is the mask, not the address

Expected

  • one predicate for "is this a netmask" in engine/net.js, used by the console, the DHCP pool validator and
    OSPF, instead of three private implementations;
  • ip address refuses a non-contiguous mask and says so, naming the mask, and leaves the previous address
    untouched;
  • the mask is stored in one spelling (dotted), so nothing downstream has to guess;
  • the front panel applies the same rule and shows ? for a mask that has no prefix length, rather than a
    confident number;
  • an agreement test over all 33 prefix lengths in both spellings, plus the refusal path, plus a lab that
    still carries a bad mask.

Scope

Validation of an existing command, and de-duplication of an existing rule. No new commands, no change to
what a valid mask means.

## What happens `ip address` accepts a mask that is not a netmask, and the components that read that mask disagree about what it means: ``` R1(config-if)#ip address 10.9.9.9 255.0.255.0 IP address set on Gi0: 10.9.9.9/8 <- accepted, read as /8 by the engine ``` `255.0.255.0` is a valid IPv4 *address* and not a netmask: it has no prefix length. Measured, on four implementations of the same question: | mask | `engine/net.js prefixOf()` | `engine/dhcp.js maskContiguous()` | `engine/ospf.js maskPrefix()` | `web/app.js maskBits()` | |---|---|---|---|---| | `255.0.255.0` | 8 | false | null | **16** | | `255.255.255.253` | 30 | false | null | **31** | | `255.255.0.255` | 16 | false | null | **24** | So the console accepted it, the router routes on the raw mask, and the inspector you open to find out why the link behaves oddly summarises it as `/16` — a number that describes nothing. ## The quieter half ``` R1(config-if)#ip address 10.0.0.1 24 ``` That stored the string `"24"`. Anything that parses a dotted mask — including the front panel — reads it as `0.0.0.24` and prints `/2`. Third, smaller: the refusal printed the wrong argument. ``` R1(config-if)#ip address 10.9.9.9 garbage % Error: Invalid IPv4 address: garbage <- it is the mask, not the address ``` ## Expected * one predicate for "is this a netmask" in `engine/net.js`, used by the console, the DHCP pool validator and OSPF, instead of three private implementations; * `ip address` refuses a non-contiguous mask and says so, naming the mask, and leaves the previous address untouched; * the mask is stored in **one** spelling (dotted), so nothing downstream has to guess; * the front panel applies the same rule and shows `?` for a mask that has no prefix length, rather than a confident number; * an agreement test over all 33 prefix lengths in both spellings, plus the refusal path, plus a lab that still carries a bad mask. ## Scope Validation of an existing command, and de-duplication of an existing rule. No new commands, no change to what a valid mask means.
Sign in to join this conversation.
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#1249
No description provided.