Merge "Ubuntu: Fix networkd config for multiple VLANs without MTU"

This commit is contained in:
Zuul 2023-02-16 17:33:52 +00:00 committed by Gerrit Code Review
commit be0a819623
3 changed files with 46 additions and 1 deletions

View File

@ -641,7 +641,8 @@ def networkd_networks(context, names, inventory_hostname=None):
set(bond_member_to_bond)) set(bond_member_to_bond))
for device in implied_vlan_parents: for device in implied_vlan_parents:
vlan_interfaces = interface_to_vlans[device] vlan_interfaces = interface_to_vlans[device]
mtu = max([vlan["mtu"] for vlan in vlan_interfaces]) vlan_mtus = [vlan["mtu"] for vlan in vlan_interfaces if vlan["mtu"]]
mtu = max(vlan_mtus) if vlan_mtus else None
net = _vlan_parent_network(device, mtu, net = _vlan_parent_network(device, mtu,
[vlan["device"] [vlan["device"]
for vlan in vlan_interfaces]) for vlan in vlan_interfaces])

View File

@ -491,6 +491,44 @@ class TestNetworkdNetworks(BaseNetworkdTest):
} }
self.assertEqual(expected, nets) self.assertEqual(expected, nets)
def test_vlan_multiple(self):
# Test the case with multiple VLANs on an implied parent without MTUs.
# https://storyboard.openstack.org/#!/story/2009013
self._update_context({
"net5_interface": "eth0.3",
"net5_vlan": 3})
nets = networkd.networkd_networks(self.context, ["net2", "net5"])
expected = {
"50-kayobe-eth0": [
{
"Match": [
{"Name": "eth0"}
],
},
{
"Network": [
{"VLAN": "eth0.2"},
{"VLAN": "eth0.3"},
]
},
],
"50-kayobe-eth0.2": [
{
"Match": [
{"Name": "eth0.2"}
]
},
],
"50-kayobe-eth0.3": [
{
"Match": [
{"Name": "eth0.3"}
]
},
]
}
self.assertEqual(expected, nets)
def test_vlan_with_parent(self): def test_vlan_with_parent(self):
nets = networkd.networkd_networks(self.context, nets = networkd.networkd_networks(self.context,
["net1", "net2", "net5", "net6"]) ["net1", "net2", "net5", "net6"])

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes an issue with systemd-networkd configuration on Ubuntu with multiple
VLAN interfaces. See `story 2009013
<https://storyboard.openstack.org/#!/story/2009013>`__ for details.