Skip to content

Commit d4d018b

Browse files
committed
fix: propagate route table down to the resource
Fixes #13153 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit 3399ff4)
1 parent ffa0bcf commit d4d018b

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

internal/app/machined/pkg/controllers/network/route_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ func (ctrl *RouteConfigController) processMachineConfig(linkConfigs []cfg.Networ
328328
route.Family = nethelpers.FamilyInet4
329329
}
330330

331-
route.Table = nethelpers.TableMain
331+
route.Table = spec.Table().ValueOr(nethelpers.TableMain)
332332
route.Protocol = nethelpers.ProtocolStatic
333333
route.OutLinkName = linkConfig.Name()
334334
route.ConfigLayer = network.ConfigMachineConfiguration

internal/app/machined/pkg/controllers/network/route_config_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func (suite *RouteConfigSuite) TestMachineConfiguration() {
245245
{
246246
RouteGateway: networkcfg.Addr{Addr: netip.MustParseAddr("2001:470:6d:30e:8ed2:b60c:9d2f:803b")},
247247
RouteMetric: 200,
248+
RouteTable: nethelpers.Table101,
248249
},
249250
}
250251

@@ -259,25 +260,28 @@ func (suite *RouteConfigSuite) TestMachineConfiguration() {
259260
ctest.AssertResources(
260261
suite,
261262
[]string{
262-
"configuration/enp0s3/inet6/2001:470:6d:30e:8ed2:b60c:9d2f:803b//200",
263+
"configuration/101/enp0s3/inet6/2001:470:6d:30e:8ed2:b60c:9d2f:803b//200",
263264
"configuration/inet4/10.12.3.1/10.12.3.0/24/1024",
264265
"configuration/inet4//10.1.3.4/32/300",
265266
},
266267
func(r *network.RouteSpec, asrt *assert.Assertions) {
267268
switch r.Metadata().ID() {
268-
case "configuration/enp0s3/inet6/2001:470:6d:30e:8ed2:b60c:9d2f:803b//200":
269+
case "configuration/101/enp0s3/inet6/2001:470:6d:30e:8ed2:b60c:9d2f:803b//200":
269270
asrt.Equal("enp0s3", r.TypedSpec().OutLinkName)
270271
asrt.Equal(nethelpers.FamilyInet6, r.TypedSpec().Family)
271272
asrt.EqualValues(200, r.TypedSpec().Priority)
273+
asrt.EqualValues(nethelpers.Table101, r.TypedSpec().Table)
272274
case "configuration/inet4/10.12.3.1/10.12.3.0/24/1024":
273275
asrt.Equal("enp0s2", r.TypedSpec().OutLinkName)
274276
asrt.Equal(nethelpers.FamilyInet4, r.TypedSpec().Family)
275277
asrt.EqualValues(network.DefaultRouteMetric, r.TypedSpec().Priority)
278+
asrt.EqualValues(nethelpers.TableMain, r.TypedSpec().Table)
276279
case "configuration/inet4//10.1.3.4/32/300":
277280
asrt.Empty(r.TypedSpec().OutLinkName)
278281
asrt.Equal(nethelpers.FamilyInet4, r.TypedSpec().Family)
279282
asrt.EqualValues(300, r.TypedSpec().Priority)
280283
asrt.Equal(nethelpers.TypeBlackhole, r.TypedSpec().Type)
284+
asrt.EqualValues(nethelpers.TableMain, r.TypedSpec().Table)
281285
}
282286

283287
asrt.Equal(network.ConfigMachineConfiguration, r.TypedSpec().ConfigLayer)

internal/integration/api/network-config.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ func (suite *NetworkConfigSuite) TestDummyLinkConfig() {
147147
{
148148
RouteDestination: network.Prefix{Prefix: netip.MustParsePrefix("fd13:1235::/64")},
149149
RouteGateway: network.Addr{Addr: netip.MustParseAddr("fd13:1234::ffff")},
150+
RouteTable: nethelpers.Table101,
150151
},
151152
}
152153

153154
addressID := dummyName + "/fd13:1234::1/64"
154-
routeID := dummyName + "/inet6/fd13:1234::ffff/fd13:1235::/64/1024"
155+
routeID := "101/" + dummyName + "/inet6/fd13:1234::ffff/fd13:1235::/64/1024"
155156
addressRouteID := dummyName + "/inet6//fd13:1234::/64/100"
156157

157158
suite.PatchMachineConfig(nodeCtx, dummy)
@@ -174,6 +175,12 @@ func (suite *NetworkConfigSuite) TestDummyLinkConfig() {
174175
[]resource.ID{routeID, addressRouteID},
175176
func(route *networkres.RouteStatus, asrt *assert.Assertions) {
176177
asrt.Equal(dummyName, route.TypedSpec().OutLinkName)
178+
179+
if route.Metadata().ID() == routeID {
180+
asrt.Equal(nethelpers.Table101, route.TypedSpec().Table)
181+
} else {
182+
asrt.Equal(nethelpers.TableMain, route.TypedSpec().Table)
183+
}
177184
},
178185
)
179186

0 commit comments

Comments
 (0)