@@ -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