Skip to content

infra: override default route when running in a netns#627

Open
rjarry wants to merge 1 commit into
DPDK:mainfrom
rjarry:default-route
Open

infra: override default route when running in a netns#627
rjarry wants to merge 1 commit into
DPDK:mainfrom
rjarry:default-route

Conversation

@rjarry
Copy link
Copy Markdown
Collaborator

@rjarry rjarry commented Jun 1, 2026

When grout runs inside a k8s pod, the default route installed by k8s has priority over grout's own default route (which uses metric UINT32_MAX). This causes TCP connections to fail over grout.

When the environment variable GROUT_OVERRIDE_DEFAULT_ROUTE is set to a truthy value (1, true, on, yes), install the default route with metric 0 and NLM_F_REPLACE to take over the existing one. Set the variable in the default systemd environment file (which runs with PrivateNetwork=true), in the container quadlet and in the Containerfile.

Link: #625

Overview

Adds an explicit override mechanism for the default route driven by a new configuration flag (gr_config.override_default_route) and the GROUT_OVERRIDE_DEFAULT_ROUTE environment variable. When enabled, grout will install default routes into the main routing table using NLM_F_REPLACE and without the high-priority metric so the installed default takes precedence over existing defaults (useful for container/netns deployments).

Changes

  • main/config.h

    • Adds bool override_default_route to struct gr_config.
  • main/main.c

    • Adds parse_bool_env() helper to parse truthy environment values ("1", "true", "on", "yes", case-insensitive).
    • Reads GROUT_OVERRIDE_DEFAULT_ROUTE into gr_config.override_default_route at startup.
    • Emits a NOTICE log when GROUT_OVERRIDE_DEFAULT_ROUTE is set.
  • modules/infra/control/netlink.c

    • When adding routes for RT_TABLE_MAIN, set netlink message flags to include NLM_F_REPLACE (nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE) if gr_config.override_default_route is true; otherwise preserve previous behavior using NLM_F_EXCL.
    • Only set RTA_PRIORITY = UINT32_MAX when override_default_route is false (omit the high-priority metric when override is enabled), allowing a route with metric 0 to win.
  • Documentation and defaults

    • docs/grout.8.scdoc: Documents GROUT_OVERRIDE_DEFAULT_ROUTE in ENVIRONMENT with accepted truthy values and the effect (override existing default route with metric 0).
    • Containerfile: Sets ENV GROUT_OVERRIDE_DEFAULT_ROUTE=true in the final image.
    • main/grout.default and smoke/_init.sh: Set GROUT_OVERRIDE_DEFAULT_ROUTE=true in defaults/test harness so runtime behavior overrides existing default routes in those environments.

@coderabbitai

This comment was marked as resolved.

When grout runs inside a k8s pod, the default route installed by k8s
has priority over grout's own default route (which uses metric
UINT32_MAX). This causes TCP connections to fail over grout.

When the environment variable GROUT_OVERRIDE_DEFAULT_ROUTE is set to
a truthy value (1, true, on, yes), install the default route with
metric 0 and NLM_F_REPLACE to take over the existing one. Set the
variable in the default systemd environment file (which runs with
PrivateNetwork=true), in the container quadlet and in the Containerfile.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
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