Skip to content

fix: give each route_section ltype its correct grammar (#476)#486

Closed
SJrX wants to merge 1 commit into
issue-345-16from
issue-345-17
Closed

fix: give each route_section ltype its correct grammar (#476)#486
SJrX wants to merge 1 commit into
issue-345-16from
issue-345-17

Conversation

@SJrX

@SJrX SJrX commented Jun 23, 2026

Copy link
Copy Markdown
Owner

What

Fixes the mis-registration in #476. config_parse_route_section was registered for eight ltypes all pointing at ConfigParseRouteSectionOptionValue — the route-Type enum grammar (unicast/blackhole/…). So valid values on those [Route] options (a numeric Metric=100, QuickAck=true, IPv6Preference=high, …) were wrongly flagged as invalid. Each ltype now gets its correct grammar.

Stacked on #485 (issue-345-16).

Grammars (verified against the systemd source, not guessed)

ltype [Route] key grammar
ROUTE_PRIORITY Metric uint32 (safe_atou32)
ROUTE_NEXTHOP NextHop uint32
ROUTE_PROTOCOL Protocol kernel/boot/static or 0–255 (route_protocol_from_string, string table + numeric fallback to UINT8_MAX)
ROUTE_PREFERENCE IPv6Preference low/medium/high (config_parse_route_preference)
ROUTE_METRIC_HOPLIMIT HopLimit 1–255 (parser rejects 0 / >255)
ROUTE_METRIC_INITRWND InitialAdvertisedReceiveWindow 1–1023 (config_parse_tcp_window)
ROUTE_METRIC_QUICKACK QuickAck boolean
ROUTE_METRIC_FASTOPEN_NO_COOKIE FastOpenNoCookie boolean

ROUTE_TYPE keeps the enum grammar (it was the only correct one). Six small SimpleGrammarOptionValues classes (uint32 and boolean each shared by their two ltypes). These work under the default engine — no flag needed.

Test

A [Route] file of valid options (Type/Metric/Protocol/IPv6Preference/NextHop/HopLimit/InitialAdvertisedReceiveWindow/QuickAck/FastOpenNoCookie) now produces no warnings; bad values (non-number metric, bad preference, Protocol=999, HopLimit=0, QuickAck=perhaps) each flag.

Still open in #476

The unregistered route_section ltypes (Scope, Table, Destination/Source, PreferredSource, GatewayOnLink, MultiPathRoute, MTUBytes, TCPAdvertisedMaximumSegmentSize, InitialCongestionWindow, TCPRetransmissionTimeoutSec, TCPCongestionControlAlgorithm) still get no validation — latent coverage gaps, but not false errors. Can be a follow-up.

Refs #476 #467

🤖 Generated with Claude Code

config_parse_route_section was registered for eight ltypes all pointing at the route-
Type enum grammar (unicast/blackhole/...), so valid integers/booleans/enums on those
[Route] options were wrongly flagged. Re-point each to a correct grammar (verified
against the systemd source):

- ROUTE_PRIORITY (Metric), ROUTE_NEXTHOP (NextHop)        -> uint32
- ROUTE_PROTOCOL (Protocol)        -> kernel|boot|static or 0-255
- ROUTE_PREFERENCE (IPv6Preference) -> low|medium|high
- ROUTE_METRIC_HOPLIMIT (HopLimit)  -> 1..255
- ROUTE_METRIC_INITRWND (InitialAdvertisedReceiveWindow) -> 1..1023 (tcp window)
- ROUTE_METRIC_QUICKACK, ROUTE_METRIC_FASTOPEN_NO_COOKIE -> boolean

ROUTE_TYPE keeps the enum grammar. Adds six small SimpleGrammarOptionValues classes
(uint32/boolean shared across their two ltypes). Works under the default engine.

Test: a [Route] file of valid options now produces no warnings; bad values (non-number
metric, bad preference, out-of-range protocol/hoplimit, non-boolean quickack) each flag.

Still open in #476: the unregistered route_section ltypes (Scope, Table, Destination,
PreferredSource, GatewayOnLink, MultiPathRoute, MTUBytes, ADVMSS, INITCWND, RTO_MIN,
CC_ALGO) get no validation yet — latent gaps, not false errors.

Refs #476 #467

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test Results

1 159 tests  +2   1 159 ✅ +2   50s ⏱️ -1s
  308 suites +1       0 💤 ±0 
  308 files   +1       0 ❌ ±0 

Results for commit 55453f1. ± Comparison against base commit cab658e.

SJrX added a commit that referenced this pull request Jun 25, 2026
…ute_section) (#493)

Every config_parse_route_section ltype mapped to the generic
ConfigParseRouteSectionOptionValue, so most [Route] directives in .network files
got no real validation. Point each ltype at a validator matching its systemd
semantics, and add the two gateway ltypes that had no entry:

  ROUTE_GATEWAY          -> IPv4/IPv6 address, or _dhcp4 / _ipv6ra
  ROUTE_GATEWAY_NETWORK  -> gateway-or-network form
  ROUTE_METRIC_*COOKIE / *QUICKACK -> boolean
  ROUTE_METRIC_HOPLIMIT  -> hop limit
  ROUTE_METRIC_INITRWND  -> initial window
  ROUTE_NEXTHOP/PRIORITY -> uint32
  ROUTE_PREFERENCE       -> low|medium|high
  ROUTE_PROTOCOL         -> protocol enum
  (ROUTE_TYPE stays on the generic validator)

Bundles the route_section work from the stacked PRs #475 (Gateway=) and #486
(the remaining ltypes); both edit the same registry block, so they ship as one
cohesive MR re-cut against current 242.x. Default-path fix (both engines).

Co-authored-by: Steve Ramage <gitcommits@sjrx.net>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@SJrX

SJrX commented Jun 26, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #493 (merged into 242.x as 360c662), which bundled the route_section grammars (#475 + #486) into one cohesive MR re-cut against current 242.x. Closing.

@SJrX SJrX closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant