]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add tests for MTUBytes= for bridge master and ports
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Aug 2022 16:59:56 +0000 (01:59 +0900)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 16 Aug 2022 21:46:40 +0000 (21:46 +0000)
Prompted by #24311.

test/test-network/conf/25-bridge99.network
test/test-network/conf/26-bridge-slave-interface-1.network
test/test-network/conf/26-bridge-slave-interface-2.network
test/test-network/systemd-networkd-tests.py

index 07ef254ddabed4e6ef239b76e152f2d58067113d..dbeb04ea0452866e58a98dbe0683a5dfc885598a 100644 (file)
@@ -2,6 +2,9 @@
 [Match]
 Name=bridge99
 
+[Link]
+MTUBytes=9000
+
 [Network]
 Address=192.168.0.15/24
 Gateway=192.168.0.1
index 8858cbf0008f176f744bc509f6a67426a2edca82..cdb3daa2b1bed74d96a27838fcde6249eba4be0b 100644 (file)
@@ -2,6 +2,9 @@
 [Match]
 Name=dummy98
 
+[Link]
+MTUBytes=9000
+
 [Network]
 Bridge=bridge99
 
index 26ab7d8af6abba835ed9a4842fe8d3e400ea6e58..42b197eeef12060557e5ac04fb4dafab1229d576 100644 (file)
@@ -2,6 +2,9 @@
 [Match]
 Name=test1
 
+[Link]
+MTUBytes=9000
+
 [Network]
 Bridge=bridge99
 
index f3ec22aeee460dd75a24c2986f0bfe67e8f84211..3ee734eaf0ebb77b4c29d7c969c6cf29ebb5eedc 100755 (executable)
@@ -3796,19 +3796,25 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
         start_networkd()
         self.wait_online(['dummy98:enslaved', 'test1:enslaved', 'bridge99:routable'])
 
+        output = check_output('ip -d link show bridge99')
+        print(output)
+        self.assertIn('mtu 9000 ', output)
+
         output = check_output('ip -d link show test1')
         print(output)
-        self.assertRegex(output, 'master')
-        self.assertRegex(output, 'bridge')
+        self.assertIn('master bridge99 ', output)
+        self.assertIn('bridge_slave', output)
+        self.assertIn('mtu 9000 ', output)
 
         output = check_output('ip -d link show dummy98')
         print(output)
-        self.assertRegex(output, 'master')
-        self.assertRegex(output, 'bridge')
+        self.assertIn('master bridge99 ', output)
+        self.assertIn('bridge_slave', output)
+        self.assertIn('mtu 9000 ', output)
 
         output = check_output('ip addr show bridge99')
         print(output)
-        self.assertRegex(output, '192.168.0.15/24')
+        self.assertIn('192.168.0.15/24', output)
 
         output = check_output('bridge -d link show dummy98')
         print(output)
@@ -3833,7 +3839,7 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
         check_output('ip address add 192.168.0.16/24 dev bridge99')
         output = check_output('ip addr show bridge99')
         print(output)
-        self.assertRegex(output, '192.168.0.16/24')
+        self.assertIn('192.168.0.16/24', output)
 
         # for issue #6088
         print('### ip -6 route list table all dev bridge99')
@@ -3842,24 +3848,49 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
         self.assertRegex(output, 'ff00::/8 table local (proto kernel )?metric 256 (linkdown )?pref medium')
 
         remove_link('test1')
-
         self.wait_operstate('bridge99', 'degraded-carrier')
 
-        remove_link('dummy98')
+        output = check_output('ip -d link show bridge99')
+        print(output)
+        self.assertIn('mtu 9000 ', output)
+
+        output = check_output('ip -d link show dummy98')
+        print(output)
+        self.assertIn('master bridge99 ', output)
+        self.assertIn('bridge_slave', output)
+        self.assertIn('mtu 9000 ', output)
 
+        remove_link('dummy98')
         self.wait_operstate('bridge99', 'no-carrier')
 
+        output = check_output('ip -d link show bridge99')
+        print(output)
+        # When no carrier, the kernel may reset the MTU
+        self.assertIn('NO-CARRIER', output)
+
         output = check_output('ip address show bridge99')
         print(output)
-        self.assertRegex(output, 'NO-CARRIER')
-        self.assertNotRegex(output, '192.168.0.15/24')
-        self.assertRegex(output, '192.168.0.16/24') # foreign address is kept
+        self.assertNotIn('192.168.0.15/24', output)
+        self.assertIn('192.168.0.16/24', output) # foreign address is kept
 
         print('### ip -6 route list table all dev bridge99')
         output = check_output('ip -6 route list table all dev bridge99')
         print(output)
         self.assertRegex(output, 'ff00::/8 table local (proto kernel )?metric 256 (linkdown )?pref medium')
 
+        check_output('ip link add dummy98 type dummy')
+        self.wait_online(['dummy98:enslaved', 'bridge99:routable'])
+
+        output = check_output('ip -d link show bridge99')
+        print(output)
+        self.assertIn('mtu 9000 ', output)
+
+        output = check_output('ip -d link show dummy98')
+        print(output)
+        self.assertIn('master bridge99 ', output)
+        self.assertIn('bridge_slave', output)
+        self.assertIn('mtu 9000 ', output)
+
     def test_bridge_configure_without_carrier(self):
         copy_network_unit('26-bridge.netdev', '26-bridge-configure-without-carrier.network',
                           '11-dummy.netdev')