Skip to content

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

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

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.

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