Skip to content

Commit 34f09a3

Browse files
maxpainsmira
authored andcommitted
feat: add VLAN support to OpenStack platform
This adds support for VLAN interfaces in OpenStack network_data.json. VLANs are configured with type "vlan" and reference a parent link via "vlan_link" field. The VLAN ID is specified in "vlan_id" field. Example network_data.json entry: { "type": "vlan", "vlan_link": "tap7819ff08-20", "vlan_id": 100 } This enables Talos to automatically configure VLAN interfaces when booting on OpenStack/Ironic bare metal with VLAN-based network topology. Signed-off-by: Max Makarov <maxpain@linux.com> Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 5127ef7 commit 34f09a3

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/metadata.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ type NetworkConfig struct {
5252
BondLinks []string `json:"bond_links,omitempty"`
5353
BondMIIMon uint32 `json:"bond_miimon,string,omitempty"`
5454
BondHashPolicy string `json:"bond_xmit_hash_policy,omitempty"`
55+
VlanID uint16 `json:"vlan_id,omitempty"`
56+
VlanLink string `json:"vlan_link,omitempty"`
57+
VlanMac string `json:"vlan_mac_address,omitempty"`
5558
} `json:"links"`
5659
Networks []struct {
5760
ID string `json:"id,omitempty"`

internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/openstack.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,41 @@ func (o *OpenStack) ParseMetadata(
214214
}
215215
}
216216

217+
// VLANs
218+
for _, netLink := range unmarshalledNetworkConfig.Links {
219+
if netLink.Type != "vlan" {
220+
continue
221+
}
222+
223+
parentName, ok := ifaces[netLink.VlanLink]
224+
if !ok {
225+
parentName = netLink.VlanLink
226+
}
227+
228+
vlanName := fmt.Sprintf("%s.%d", parentName, netLink.VlanID)
229+
ifaces[netLink.ID] = vlanName
230+
231+
vlanLink := network.LinkSpecSpec{
232+
ConfigLayer: network.ConfigPlatform,
233+
Name: vlanName,
234+
Logical: true,
235+
Up: true,
236+
Kind: network.LinkKindVLAN,
237+
Type: nethelpers.LinkEther,
238+
ParentName: parentName,
239+
VLAN: network.VLANSpec{
240+
VID: netLink.VlanID,
241+
Protocol: nethelpers.VLANProtocol8021Q,
242+
},
243+
}
244+
245+
if netLink.MTU != 0 {
246+
vlanLink.MTU = uint32(netLink.MTU)
247+
}
248+
249+
networkConfig.Links = append(networkConfig.Links, vlanLink)
250+
}
251+
217252
for _, ntwrk := range unmarshalledNetworkConfig.Networks {
218253
if ntwrk.ID == "" || ifaces[ntwrk.Link] == "" {
219254
continue

internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/testdata/expected.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ links:
9494
masterName: bond0
9595
slaveIndex: 1
9696
layer: platform
97+
- name: bond0.100
98+
logical: true
99+
up: true
100+
mtu: 1400
101+
kind: vlan
102+
type: ether
103+
parentName: bond0
104+
vlan:
105+
vlanID: 100
106+
vlanProtocol: 802.1q
107+
layer: platform
97108
routes:
98109
- family: inet6
99110
dst: ""
@@ -192,6 +203,13 @@ operators:
192203
routeMetric: 2048
193204
skipHostnameRequest: true
194205
layer: platform
206+
- operator: dhcp4
207+
linkName: bond0.100
208+
requireUp: true
209+
dhcp4:
210+
routeMetric: 1024
211+
skipHostnameRequest: true
212+
layer: platform
195213
externalIPs:
196214
- 1.2.3.4
197215
metadata:

internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/testdata/network.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
"id": "83f59825-bf2d-4ea7-98be-edc772fe82de",
4444
"type": "phy",
4545
"ethernet_mac_address": "4c:d9:8f:b3:34:f7"
46+
},
47+
{
48+
"id": "vlan-interface-001",
49+
"vif_id": "acf55ef1-9a79-4c59-bec7-1ebf01a9a918",
50+
"type": "vlan",
51+
"mtu": 1400,
52+
"vlan_mac_address": null,
53+
"vlan_link": "tap7819ff08-20",
54+
"vlan_id": 100
4655
}
4756
],
4857
"networks": [
@@ -138,6 +147,12 @@
138147
"address": "8.8.4.4"
139148
}
140149
]
150+
},
151+
{
152+
"id": "vlan-network",
153+
"type": "ipv4_dhcp",
154+
"link": "vlan-interface-001",
155+
"network_id": "5ee412a7-13c5-4306-ad4d-85c06241e5f4"
141156
}
142157
],
143158
"services": [

0 commit comments

Comments
 (0)