Skip to content

Commit 47c301d

Browse files
authored
Merge pull request #611 from stackhpc/upstream/2025.1-2026-08-24
Synchronise 2025.1 with upstream
2 parents a2e3296 + 4e33454 commit 47c301d

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

kayobe/plugins/filter/nmstate.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ def get_iface(name):
519519
# <network>_port_type_<portname>.
520520
for port in br_ports or []:
521521
port_iface = get_iface(port)
522+
if mtu:
523+
port_iface.setdefault("mtu", mtu)
522524
if "type" not in port_iface:
523525
# Check for explicit type configuration
524526
port_type = networks.net_attr(
@@ -586,6 +588,22 @@ def get_iface(name):
586588
parent = re.sub(
587589
r'\.{}$'.format(vlan_id), '', iface_name)
588590

591+
# NOTE(bbezak): Do not pass MTU for VLAN interfaces on bridges when
592+
# it is identical to the parent bridge, to work around a
593+
# NetworkManager bug.
594+
bridge_mtus = {}
595+
for bridge in networks.net_select_bridges(
596+
context, names, inventory_hostname):
597+
bridge_interface = networks.net_interface(
598+
context, bridge, inventory_hostname)
599+
bridge_mtus[bridge_interface] = networks.net_mtu(
600+
context, bridge, inventory_hostname)
601+
602+
if parent in bridge_mtus:
603+
parent_mtu = bridge_mtus[parent]
604+
if mtu and mtu == parent_mtu:
605+
del iface["mtu"]
606+
589607
iface["vlan"] = {
590608
"base-iface": parent,
591609
"id": int(vlan_id)

kayobe/tests/unit/plugins/filter/test_nmstate.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class TestNMStateFilter(unittest.TestCase):
4444
"net3_interface": "br0",
4545
"net3_bridge_ports": ['eth1'],
4646
"net3_bridge_stp": True,
47+
"net3_mtu": 9000,
4748
# net4: bond on bond0 with slaves eth2 and eth3.
4849
"net4_interface": "bond0",
4950
"net4_bond_slaves": ['eth2', 'eth3'],
@@ -123,13 +124,15 @@ def test_nmstate_config_bridge(self):
123124
result = nmstate.nmstate_config(self.context, ["net3"])
124125
br_iface = next(i for i in result["interfaces"] if i["name"] == "br0")
125126
self.assertEqual(br_iface["type"], "linux-bridge")
127+
self.assertEqual(br_iface["mtu"], 9000)
126128
self.assertEqual(br_iface["bridge"]["port"], [{"name": "eth1"}])
127129
self.assertTrue(br_iface["bridge"]["options"]["stp"]["enabled"])
128130

129131
# eth1 should be present as ethernet
130132
eth1_iface = next(i for i in result["interfaces"]
131133
if i["name"] == "eth1")
132134
self.assertEqual(eth1_iface["type"], "ethernet")
135+
self.assertEqual(eth1_iface["mtu"], 9000)
133136

134137
def test_nmstate_config_bond(self):
135138
result = nmstate.nmstate_config(self.context, ["net4"])
@@ -434,6 +437,44 @@ def test_vlan_interface_explicit_vlan_and_parent(self):
434437
self.assertEqual(vlan_iface["vlan"]["base-iface"], "eth0")
435438
self.assertEqual(vlan_iface["vlan"]["id"], 100)
436439

440+
def test_vlan_on_bridge_inherits_matching_mtu(self):
441+
variables = {
442+
"inventory_hostname": "test-host",
443+
"ansible_facts": {"os_family": "RedHat"},
444+
"vlan_interface": "br0.6",
445+
"vlan_vlan": 6,
446+
"vlan_mtu": 9150,
447+
"bridge_interface": "br0",
448+
"bridge_bridge_ports": ["eth0"],
449+
"bridge_mtu": 9150,
450+
}
451+
context = self._make_context(variables)
452+
result = nmstate.nmstate_config(context, ["vlan", "bridge"])
453+
454+
vlan_iface = next(
455+
i for i in result["interfaces"]
456+
if i["name"] == "br0.6")
457+
self.assertNotIn("mtu", vlan_iface)
458+
459+
def test_vlan_on_bridge_keeps_different_mtu(self):
460+
variables = {
461+
"inventory_hostname": "test-host",
462+
"ansible_facts": {"os_family": "RedHat"},
463+
"vlan_interface": "br0.6",
464+
"vlan_vlan": 6,
465+
"vlan_mtu": 9000,
466+
"bridge_interface": "br0",
467+
"bridge_bridge_ports": ["eth0"],
468+
"bridge_mtu": 9150,
469+
}
470+
context = self._make_context(variables)
471+
result = nmstate.nmstate_config(context, ["vlan", "bridge"])
472+
473+
vlan_iface = next(
474+
i for i in result["interfaces"]
475+
if i["name"] == "br0.6")
476+
self.assertEqual(vlan_iface["mtu"], 9000)
477+
437478
def test_vlan_interface_invalid_name(self):
438479
"""Test VLAN with invalid interface name is skipped gracefully."""
439480
variables = {

0 commit comments

Comments
 (0)