Skip to content

Commit eb636dc

Browse files
6ixfallsshanduur
authored andcommitted
feat: add multicast to linkconfig
Adds a multicast option to CommonLinkConfig that can be set to override the multicast flag of the link. Signed-off-by: Bryan Lee <me@bryanl.ee> (cherry picked from commit 0c59b3e)
1 parent e34e458 commit eb636dc

File tree

16 files changed

+190
-1
lines changed

16 files changed

+190
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ func (ctrl *LinkConfigController) processDevicesConfiguration(
408408
}
409409
}
410410

411-
//nolint:gocyclo
411+
//nolint:gocyclo,cyclop
412412
func (ctrl *LinkConfigController) processLinkConfigs(logger *zap.Logger, linkMap map[string]*network.LinkSpecSpec, cfg *config.MachineConfig, linkNameResolver *network.LinkResolver) {
413413
if cfg == nil {
414414
return
@@ -439,6 +439,11 @@ func (ctrl *LinkConfigController) processLinkConfigs(logger *zap.Logger, linkMap
439439
linkMap[linkName].HardwareAddress = nil
440440
}
441441

442+
if multicast, ok := linkConfig.Multicast().Get(); ok {
443+
linkMap[linkName].Multicast = new(bool)
444+
*linkMap[linkName].Multicast = multicast
445+
}
446+
442447
switch specificLinkConfig := linkConfig.(type) {
443448
case talosconfig.NetworkPhysicalLinkConfig:
444449
// nothing specific for physical links

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ func (suite *LinkConfigSuite) TestMachineConfiguration() {
256256
} else {
257257
asrt.EqualValues(9001, r.TypedSpec().MTU)
258258
}
259+
260+
asrt.Nil(r.TypedSpec().Multicast)
259261
case "eth0.24", "eth0.48":
260262
asrt.True(r.TypedSpec().Up)
261263
asrt.True(r.TypedSpec().Logical)
@@ -779,6 +781,37 @@ func (suite *LinkConfigSuite) TestNoDefaultUp() {
779781
)
780782
}
781783

784+
func (suite *LinkConfigSuite) TestMulticast() {
785+
suite.Require().NoError(suite.Runtime().RegisterController(&netctrl.LinkConfigController{}))
786+
787+
lc1 := networkcfg.NewLinkConfigV1Alpha1("enp1s1")
788+
lc1.LinkMulticast = pointer.To(false)
789+
lc2 := networkcfg.NewLinkConfigV1Alpha1("enp1s2")
790+
lc2.LinkMulticast = pointer.To(true)
791+
792+
ctr, err := container.New(lc1, lc2)
793+
suite.Require().NoError(err)
794+
795+
cfg := config.NewMachineConfig(ctr)
796+
suite.Create(cfg)
797+
798+
suite.assertLinks(
799+
[]string{
800+
"configuration/enp1s1",
801+
"configuration/enp1s2",
802+
}, func(r *network.LinkSpec, asrt *assert.Assertions) {
803+
asrt.Equal(network.ConfigMachineConfiguration, r.TypedSpec().ConfigLayer)
804+
805+
switch r.TypedSpec().Name {
806+
case "enp1s1":
807+
asrt.False(*r.TypedSpec().Multicast)
808+
case "enp1s2":
809+
asrt.True(*r.TypedSpec().Multicast)
810+
}
811+
},
812+
)
813+
}
814+
782815
func TestLinkConfigSuite(t *testing.T) {
783816
t.Parallel()
784817

pkg/machinery/config/config/network.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ type NetworkCommonLinkConfig interface {
152152
MTU() optional.Optional[uint32]
153153
Addresses() []NetworkAddressConfig
154154
Routes() []NetworkRouteConfig
155+
Multicast() optional.Optional[bool]
155156
}
156157

157158
// NetworkAddressConfig defines a network address configuration.

pkg/machinery/config/schemas/config.schema.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,13 @@
12881288
"description": "Configure routes to be statically created via the link.\n",
12891289
"markdownDescription": "Configure routes to be statically created via the link.",
12901290
"x-intellij-html-description": "\u003cp\u003eConfigure routes to be statically created via the link.\u003c/p\u003e\n"
1291+
},
1292+
"multicast": {
1293+
"type": "boolean",
1294+
"title": "multicast",
1295+
"description": "Set the multicast capability of the link.\n",
1296+
"markdownDescription": "Set the multicast capability of the link.",
1297+
"x-intellij-html-description": "\u003cp\u003eSet the multicast capability of the link.\u003c/p\u003e\n"
12911298
}
12921299
},
12931300
"additionalProperties": false,
@@ -1393,6 +1400,13 @@
13931400
"description": "Configure routes to be statically created via the link.\n",
13941401
"markdownDescription": "Configure routes to be statically created via the link.",
13951402
"x-intellij-html-description": "\u003cp\u003eConfigure routes to be statically created via the link.\u003c/p\u003e\n"
1403+
},
1404+
"multicast": {
1405+
"type": "boolean",
1406+
"title": "multicast",
1407+
"description": "Set the multicast capability of the link.\n",
1408+
"markdownDescription": "Set the multicast capability of the link.",
1409+
"x-intellij-html-description": "\u003cp\u003eSet the multicast capability of the link.\u003c/p\u003e\n"
13961410
}
13971411
},
13981412
"additionalProperties": false,
@@ -1468,6 +1482,13 @@
14681482
"description": "Configure routes to be statically created via the link.\n",
14691483
"markdownDescription": "Configure routes to be statically created via the link.",
14701484
"x-intellij-html-description": "\u003cp\u003eConfigure routes to be statically created via the link.\u003c/p\u003e\n"
1485+
},
1486+
"multicast": {
1487+
"type": "boolean",
1488+
"title": "multicast",
1489+
"description": "Set the multicast capability of the link.\n",
1490+
"markdownDescription": "Set the multicast capability of the link.",
1491+
"x-intellij-html-description": "\u003cp\u003eSet the multicast capability of the link.\u003c/p\u003e\n"
14711492
}
14721493
},
14731494
"additionalProperties": false,
@@ -1721,6 +1742,13 @@
17211742
"description": "Configure routes to be statically created via the link.\n",
17221743
"markdownDescription": "Configure routes to be statically created via the link.",
17231744
"x-intellij-html-description": "\u003cp\u003eConfigure routes to be statically created via the link.\u003c/p\u003e\n"
1745+
},
1746+
"multicast": {
1747+
"type": "boolean",
1748+
"title": "multicast",
1749+
"description": "Set the multicast capability of the link.\n",
1750+
"markdownDescription": "Set the multicast capability of the link.",
1751+
"x-intellij-html-description": "\u003cp\u003eSet the multicast capability of the link.\u003c/p\u003e\n"
17241752
}
17251753
},
17261754
"additionalProperties": false,
@@ -2224,6 +2252,13 @@
22242252
"description": "Configure routes to be statically created via the link.\n",
22252253
"markdownDescription": "Configure routes to be statically created via the link.",
22262254
"x-intellij-html-description": "\u003cp\u003eConfigure routes to be statically created via the link.\u003c/p\u003e\n"
2255+
},
2256+
"multicast": {
2257+
"type": "boolean",
2258+
"title": "multicast",
2259+
"description": "Set the multicast capability of the link.\n",
2260+
"markdownDescription": "Set the multicast capability of the link.",
2261+
"x-intellij-html-description": "\u003cp\u003eSet the multicast capability of the link.\u003c/p\u003e\n"
22272262
}
22282263
},
22292264
"additionalProperties": false,
@@ -2699,6 +2734,13 @@
26992734
"description": "Configure routes to be statically created via the link.\n",
27002735
"markdownDescription": "Configure routes to be statically created via the link.",
27012736
"x-intellij-html-description": "\u003cp\u003eConfigure routes to be statically created via the link.\u003c/p\u003e\n"
2737+
},
2738+
"multicast": {
2739+
"type": "boolean",
2740+
"title": "multicast",
2741+
"description": "Set the multicast capability of the link.\n",
2742+
"markdownDescription": "Set the multicast capability of the link.",
2743+
"x-intellij-html-description": "\u003cp\u003eSet the multicast capability of the link.\u003c/p\u003e\n"
27022744
}
27032745
},
27042746
"additionalProperties": false,
@@ -2803,6 +2845,13 @@
28032845
"description": "Configure routes to be statically created via the link.\n",
28042846
"markdownDescription": "Configure routes to be statically created via the link.",
28052847
"x-intellij-html-description": "\u003cp\u003eConfigure routes to be statically created via the link.\u003c/p\u003e\n"
2848+
},
2849+
"multicast": {
2850+
"type": "boolean",
2851+
"title": "multicast",
2852+
"description": "Set the multicast capability of the link.\n",
2853+
"markdownDescription": "Set the multicast capability of the link.",
2854+
"x-intellij-html-description": "\u003cp\u003eSet the multicast capability of the link.\u003c/p\u003e\n"
28062855
}
28072856
},
28082857
"additionalProperties": false,

pkg/machinery/config/types/network/deep_copy.generated.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/machinery/config/types/network/link.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ type CommonLinkConfig struct {
9999
// description: |
100100
// Configure routes to be statically created via the link.
101101
LinkRoutes []RouteConfig `yaml:"routes,omitempty"`
102+
// description: |
103+
// Set the multicast capability of the link.
104+
LinkMulticast *bool `yaml:"multicast,omitempty"`
102105
}
103106

104107
// AddressConfig represents a network address configuration.
@@ -307,6 +310,15 @@ func (s *CommonLinkConfig) Routes() []config.NetworkRouteConfig {
307310
})
308311
}
309312

313+
// Multicast implements NetworkCommonLinkConfig interface.
314+
func (s *CommonLinkConfig) Multicast() optional.Optional[bool] {
315+
if s.LinkMulticast == nil {
316+
return optional.None[bool]()
317+
}
318+
319+
return optional.Some(*s.LinkMulticast)
320+
}
321+
310322
// Address implements NetworkAddressConfig interface.
311323
func (a AddressConfig) Address() netip.Prefix {
312324
return a.AddressAddress

pkg/machinery/config/types/network/link_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestLinkConfigMarshalStability(t *testing.T) {
4646
RouteGateway: network.Addr{netip.MustParseAddr("fe80::1")},
4747
},
4848
}
49+
cfg.LinkMulticast = pointer.To(true)
4950

5051
marshaled, err := encoder.NewEncoder(cfg, encoder.WithComments(encoder.CommentsDisabled)).Encode()
5152
require.NoError(t, err)
@@ -91,6 +92,7 @@ func TestLinkConfigUnmarshal(t *testing.T) {
9192
RouteGateway: network.Addr{netip.MustParseAddr("fe80::1")},
9293
},
9394
},
95+
LinkMulticast: pointer.To(true),
9496
},
9597
}, docs[0])
9698
}

pkg/machinery/config/types/network/network_doc.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/machinery/config/types/network/testdata/linkconfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ routes:
1111
- destination: 10.3.5.0/24
1212
gateway: 10.3.5.1
1313
- gateway: fe80::1
14+
multicast: true

website/content/v1.12/reference/configuration/network/bondconfig.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ allSlavesActive: 0
159159
|`mtu` |uint32 |Configure LinkMTU (Maximum Transmission Unit) for the link.<br><br>If not specified, the system default LinkMTU will be used (usually 1500). | |
160160
|`addresses` |<a href="#BondConfig.addresses.">[]AddressConfig</a> |Configure addresses to be statically assigned to the link. | |
161161
|`routes` |<a href="#BondConfig.routes.">[]RouteConfig</a> |Configure routes to be statically created via the link. | |
162+
|`multicast` |bool |Set the multicast capability of the link. | |
162163

163164

164165

0 commit comments

Comments
 (0)