Skip to content

fix: handle default routes in brutalctl - #39

Open
morecola wants to merge 1 commit into
HyNetworks:masterfrom
morecola:fix-brutalctl-default-routes
Open

fix: handle default routes in brutalctl#39
morecola wants to merge 1 commit into
HyNetworks:masterfrom
morecola:fix-brutalctl-default-routes

Conversation

@morecola

@morecola morecola commented Sep 5, 2026

Copy link
Copy Markdown

fix: handle default routes in brutalctl

Summary

Fix brutalctl handling of 0.0.0.0/0 and ::/0 rules.

The kernel rule can be created successfully for a default prefix while the route that selects brutal fails to install, leaving brutalctl list with ROUTE=no, MEMBERS=0, and no traffic using the rule.

Root cause

For IPv4, route_lookup() strips the prefix and runs ip -4 route get 0.0.0.0. On systems where this resolves to the local route, brutalctl treats the destination as local and never installs a route-level congctl brutal setting.

For default routes, reconstructing a route from only via and dev is also insufficient. Attributes such as onlink and metric can be required, especially on VPS IPv6 configurations.

Default routes also need different delete semantics: deleting a /0 Brutal rule must not delete the system default route itself.

Changes

  • Detect IPv4 and IPv6 default prefixes explicitly.
  • Read the existing default route and update it in place while preserving the attributes printed by ip route.
  • Add or remove only the route-level congctl brutal setting for default routes.
  • Make brutalctl list detect brutal directly on the default route.
  • Keep the existing protocol-233 route behavior unchanged for non-default prefixes.
  • Make del and flush preserve the underlying default route.

Reproduction before the fix

$ brutalctl add 0.0.0.0/0 1000 gain=20
brutalctl: rule added, but no route installed: destination is a local address

$ brutalctl list
DESTINATION  RATE(Mbps)  GAIN  LOCK  ROUTE  MEMBERS  SENT(MB)
0.0.0.0/0       1000.00    20   yes     no        0       0.0

The IPv6 default rule similarly failed on a route requiring onlink.

Verification

Tested against upstream master commit 377d2a0e9324ef585ff90ea91779baf276cf6a50 on:

Debian 12 (bookworm)
Linux 6.1.0-52-cloud-amd64
KVM

Default route shapes used for the test:

IPv4: default via <gateway> dev ens3 onlink
IPv6: default via <gateway> dev ens3 metric 1024 onlink pref medium

Build check:

cc -std=c11 -O2 -Wall -Wextra -Werror tools/brutalctl.c

Regression checks passed for both IPv4 and IPv6:

  1. add 0.0.0.0/0 / add ::/0 results in ROUTE=yes.
  2. The default route retains its gateway, device, metric, onlink, and other attributes.
  3. del removes congctl brutal but leaves the default route intact.
  4. Re-adding the rule restores congctl lock brutal.
  5. IPv4 and IPv6 connectivity remain working after add/delete cycles.
  6. Live TCP sockets selected brutal, and rule membership / sent-byte counters increased during traffic.

Handle 0.0.0.0/0 and ::/0 without resolving the prefix address through
`ip route get`. Update the existing default route in place so attributes such
as gateway, device, metric and onlink are preserved, and make del/flush remove
only the Brutal congestion-control setting instead of deleting the default
route.
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