dhcp: a MAC is the same 48 bits in every notation the console prints #1863

Merged
jaylouisw merged 1 commit from fix/1117-1506 into main 2026-11-17 15:27:58 +00:00
Owner

Fixes #1861

What was wrong. The DHCP console decided what a hardware address is with three private shapes of its own - a colon-only regex in host, a /:/.test(...) in no host, and a third copy in the show ip dhcp binding filter - while everything else on the box uses one rule: net.formatMac() prints dotted (0200.0000.0001) and dhcp.normalizePool() canonicalises any spelling. So the address the console prints was refused as "neither" an address nor a MAC, and a lease held by exactly that MAC was answered no lease holds that address.

What changed.

  • macSpelling(token) next to the other small helpers: asks net.macToInt (the engine's rule) and returns the canonical colon form, or null. An IPv4 address is never a MAC, even where its digits read as twelve hex characters (100.100.100.100).
  • host <address> <mac> uses it, so colon, hyphen and dotted spellings all work in either order, and the reservation is stored once under the canonical form.
  • no host uses it, so a reservation added dotted is removable dotted; a miss now names the token that was typed instead of saying only "in pool lan".
  • show ip dhcp binding <mac> uses it, so a dotted MAC finds its lease instead of being answered as an address lookup.
  • The "not a reservation" refusal lists the three notations rather than only the colon one - all three are typeable on the line it appears on.
  • docs/CLI.md §DHCP server says the same.

Tests. test/dhcp-bindings.test.js, new sections "A hardware address is accepted in every notation this console prints it in" and "A lease is found by the MAC the console prints elsewhere": 7 new assertions (66 -> 67 in that file), red before the fix.

Gates: node scripts/syntax-check.js (389 files OK); full npm test 317 suites, 11,053 assertions, 0 failed.

Not done, deliberately: show ip dhcp binding still prints MACs colon-separated while the rest of the console prints dotted. That is a display question of its own and is called out in the issue.

Fixes #1861 **What was wrong.** The DHCP console decided what a hardware address is with three private shapes of its own - a colon-only regex in `host`, a `/:/.test(...)` in `no host`, and a third copy in the `show ip dhcp binding` filter - while everything else on the box uses one rule: `net.formatMac()` prints dotted (`0200.0000.0001`) and `dhcp.normalizePool()` canonicalises any spelling. So the address the console prints was refused as "neither" an address nor a MAC, and a lease held by exactly that MAC was answered `no lease holds that address`. **What changed.** - `macSpelling(token)` next to the other small helpers: asks `net.macToInt` (the engine's rule) and returns the canonical colon form, or null. An IPv4 address is never a MAC, even where its digits read as twelve hex characters (`100.100.100.100`). - `host <address> <mac>` uses it, so colon, hyphen and dotted spellings all work in either order, and the reservation is stored once under the canonical form. - `no host` uses it, so a reservation added dotted is removable dotted; a miss now names the token that was typed instead of saying only "in pool lan". - `show ip dhcp binding <mac>` uses it, so a dotted MAC finds its lease instead of being answered as an address lookup. - The "not a reservation" refusal lists the three notations rather than only the colon one - all three are typeable on the line it appears on. - `docs/CLI.md` §DHCP server says the same. **Tests.** `test/dhcp-bindings.test.js`, new sections "A hardware address is accepted in every notation this console prints it in" and "A lease is found by the MAC the console prints elsewhere": 7 new assertions (66 -> 67 in that file), red before the fix. Gates: `node scripts/syntax-check.js` (389 files OK); full `npm test` 317 suites, 11,053 assertions, 0 failed. **Not done, deliberately:** `show ip dhcp binding` still prints MACs colon-separated while the rest of the console prints dotted. That is a display question of its own and is called out in the issue.
dhcp: a MAC is the same 48 bits in every notation the console prints (#1861)
All checks were successful
CI / Classify the change (pull_request) Successful in 10s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 16s
CI / Server smoke test (pull_request) Successful in 8s
CI / Docker build (pull_request) Successful in 22s
CI / Test (Node 20) (pull_request) Successful in 47s
CI / Test (Node 22) (pull_request) Successful in 52s
CI / Test (Node 18) (pull_request) Successful in 55s
CI / Arm auto-merge (pull_request) Successful in 8s
3bf2c846a5
The DHCP console answered "is this token a hardware address?" three times
with a private shape each time: a colon-only regex in `host`, a /:/.test in
`no host`, and a third copy in the `show ip dhcp binding` filter. Everything
else on the box disagrees with them - net.formatMac() prints dotted
(0200.0000.0001) and dhcp.normalizePool() canonicalises any spelling - so

  host 192.168.10.105 0200.0000.0001
  % Not a reservation: ... (host ... is neither)

refused the address the box prints, calling it neither an address nor a MAC,
and

  show ip dhcp binding 0200.0000.000a
  % No binding for 0200.0000.000a (no lease holds that address)

answered a MAC lookup as an address lookup while the lease was held by
exactly that MAC. `no host` carried the third copy, so a reservation would
be addable in one spelling and unfindable in another.

One helper, macSpelling(), asks the engine's own rule (net.macToInt) and
returns the canonical colon form; all three sites use it, the reservation is
stored once under that form, and a miss echoes the token that was typed.
The refusal now lists the three notations instead of only the colon one, and
docs/CLI.md says the same.

test/dhcp-bindings.test.js: 7 new assertions, red before the fix.
jaylouisw force-pushed fix/1117-1506 from 3bf2c846a5
All checks were successful
CI / Classify the change (pull_request) Successful in 10s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 16s
CI / Server smoke test (pull_request) Successful in 8s
CI / Docker build (pull_request) Successful in 22s
CI / Test (Node 20) (pull_request) Successful in 47s
CI / Test (Node 22) (pull_request) Successful in 52s
CI / Test (Node 18) (pull_request) Successful in 55s
CI / Arm auto-merge (pull_request) Successful in 8s
to 4ba2f84293
All checks were successful
CI / Classify the change (pull_request) Successful in 11s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 7s
CI / Server smoke test (pull_request) Successful in 7s
CI / Docker build (pull_request) Successful in 22s
CI / Test (Node 20) (pull_request) Successful in 48s
CI / Test (Node 18) (pull_request) Successful in 54s
CI / Test (Node 22) (pull_request) Successful in 51s
CI / Arm auto-merge (pull_request) Successful in 20s
2026-11-17 15:26:02 +00:00
Compare
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!1863
No description provided.