From db2c007ee794547e85b527bfe68838bc0e10e0ac Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Wed, 8 Apr 2026 19:05:50 +0400 Subject: [PATCH] fix: create correct blackhole routes for IPv4 For IPv4, they should be attached to no interfaces. Discovered while doing some manual testing for the documentation. Signed-off-by: Andrey Smirnov (cherry picked from commit 0bfdf7f7035fefe804ec4b568709cd6a09195293) --- internal/app/machined/pkg/controllers/network/route_config.go | 4 +++- .../app/machined/pkg/controllers/network/route_config_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/app/machined/pkg/controllers/network/route_config.go b/internal/app/machined/pkg/controllers/network/route_config.go index 1a855f7c8..00f41a8ed 100644 --- a/internal/app/machined/pkg/controllers/network/route_config.go +++ b/internal/app/machined/pkg/controllers/network/route_config.go @@ -351,9 +351,11 @@ func (ctrl *RouteConfigController) processMachineConfig(linkConfigs []cfg.Networ } family := nethelpers.FamilyInet4 + outLinkName := "" if destination.Addr().Is6() { family = nethelpers.FamilyInet6 + outLinkName = "lo" } route := network.RouteSpecSpec{ @@ -362,7 +364,7 @@ func (ctrl *RouteConfigController) processMachineConfig(linkConfigs []cfg.Networ Table: nethelpers.TableMain, Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeBlackhole, - OutLinkName: "lo", + OutLinkName: outLinkName, ConfigLayer: network.ConfigMachineConfiguration, Priority: blackholeRouteConfig.Metric().ValueOr(network.DefaultRouteMetric), } diff --git a/internal/app/machined/pkg/controllers/network/route_config_test.go b/internal/app/machined/pkg/controllers/network/route_config_test.go index c567a40f1..3f201f0cc 100644 --- a/internal/app/machined/pkg/controllers/network/route_config_test.go +++ b/internal/app/machined/pkg/controllers/network/route_config_test.go @@ -274,7 +274,7 @@ func (suite *RouteConfigSuite) TestMachineConfiguration() { asrt.Equal(nethelpers.FamilyInet4, r.TypedSpec().Family) asrt.EqualValues(network.DefaultRouteMetric, r.TypedSpec().Priority) case "configuration/inet4//10.1.3.4/32/300": - asrt.Equal("lo", r.TypedSpec().OutLinkName) + asrt.Empty(r.TypedSpec().OutLinkName) asrt.Equal(nethelpers.FamilyInet4, r.TypedSpec().Family) asrt.EqualValues(300, r.TypedSpec().Priority) asrt.Equal(nethelpers.TypeBlackhole, r.TypedSpec().Type)