Skip to content

feat: validate Gateway= in .network files (route_section gateway ltypes)#475

Open
SJrX wants to merge 1 commit into
issue-345-6from
issue-345-7
Open

feat: validate Gateway= in .network files (route_section gateway ltypes)#475
SJrX wants to merge 1 commit into
issue-345-6from
issue-345-7

Conversation

@SJrX

@SJrX SJrX commented Jun 21, 2026

Copy link
Copy Markdown
Owner

What

Adds value validation for [Network] Gateway= and [Route] Gateway= in systemd .network files. These map to config_parse_route_section with ltypes ROUTE_GATEWAY_NETWORK / ROUTE_GATEWAY, but neither ltype was registered, so Gateway values previously got no validation (resolved to NullOptionValue). This is the gap the new key-marker (#474) surfaced when Gateway stayed un-tinted.

Stacked on #474 (issue-345-6).

Grammars (reusing the existing IPV4_ADDR / IPV6_ADDR combinators)

Per systemd.network(5):

  • ConfigParseRouteSectionGatewayNetworkOptionValue[Network] Gateway=: an IPv4/IPv6 address only. The man page: "the gateway address … This is a short-hand for a [Route] section only containing a Gateway= key." — no special tokens here.
  • ConfigParseRouteSectionGatewayOptionValue[Route] Gateway=: an IPv4/IPv6 address or _dhcp4 / _ipv6ra. The man page: "Takes the gateway address or the special values "_dhcp4" and "_ipv6ra"."

Registered for ROUTE_GATEWAY_NETWORK and ROUTE_GATEWAY in AiGenerated.

Tests

ConfigParseRouteSectionGatewayOptionValueTest: valid addresses (v4/v6) in both sections + the specials in [Route] → 0 highlights; and the specials rejected in [Network], a bad address, and _dhcp6 in [Route] → one highlight each. Runs under the default engine; full suite green.

Aside (separate, pre-existing)

While here I noticed config_parse_route_section is also registered (in AiGenerated) for ROUTE_PRIORITY, ROUTE_NEXTHOP, etc., all pointing at ConfigParseRouteSectionOptionValue — which is actually the route-type enum grammar. So e.g. a numeric [Route] Priority= would likely be mis-flagged. That's pre-existing and out of scope here; happy to file an issue if you'd like.

Refs #467

🤖 Generated with Claude Code

… gateway ltypes)

[Network] Gateway= and [Route] Gateway= mapped to config_parse_route_section with
ltypes ROUTE_GATEWAY_NETWORK / ROUTE_GATEWAY, but neither ltype was registered, so
Gateway values got no validation at all (resolved to NullOptionValue). This also
showed up as the key staying unmarked under the new GrammarEngineKeyAnnotator.

Add two grammar validators (reusing the existing IPV4_ADDR / IPV6_ADDR combinators):
- ConfigParseRouteSectionGatewayNetworkOptionValue ([Network] Gateway=): IPv4/IPv6
  address only — per systemd.network(5) the [Network] short-hand does not take the
  special tokens.
- ConfigParseRouteSectionGatewayOptionValue ([Route] Gateway=): IPv4/IPv6 address or
  the special values "_dhcp4" / "_ipv6ra".

Registered for ROUTE_GATEWAY_NETWORK and ROUTE_GATEWAY in AiGenerated. Works under the
default engine and lights up under the experimental key marker (it's a
GrammarOptionValue), confirming the pipeline end-to-end.

Refs #467

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

Copy link
Copy Markdown

Test Results

1 125 tests  +2   1 125 ✅ +2   47s ⏱️ -8s
  298 suites +1       0 💤 ±0 
  298 files   +1       0 ❌ ±0 

Results for commit b41dfdd. ± Comparison against base commit 4a3707d.

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