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 <andrey.smirnov@siderolabs.com>
(cherry picked from commit 0bfdf7f7035fefe804ec4b568709cd6a09195293)
This commit is contained in:
Andrey Smirnov 2026-04-08 19:05:50 +04:00
parent 6f84628494
commit db2c007ee7
No known key found for this signature in database
GPG Key ID: 322C6F63F594CE7C
2 changed files with 4 additions and 2 deletions

View File

@ -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),
}

View File

@ -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)