]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test case for Gateway=_dhcp4 with Table= 36183/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 26 Jan 2025 20:54:30 +0000 (05:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 26 Jan 2025 23:39:09 +0000 (08:39 +0900)
test/test-network/conf/25-dhcp-client-ipv4-only.network
test/test-network/systemd-networkd-tests.py

index 7d79ee3485e1589b6cbed9f72f6f1c49b6071a59..30a5fcc22cd517cd9efd0857ac5d1cdf5b7278b8 100644 (file)
@@ -43,5 +43,9 @@ Destination=192.168.7.0/24
 
 [Route]
 Gateway=_dhcp4
-Destination=10.0.0.0/8
-Table=211
+Destination=192.0.2.0/24
+
+[Route]
+Gateway=_dhcp4
+Destination=198.51.100.0/24
+Table=212
index a151e00a2f106ae5bb549a1d285da2e511a96484..65b8b9e3c9b648598751d8141fc2bcc2fefe3f82 100755 (executable)
@@ -7121,7 +7121,14 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         self.assertRegex(output, f'192.168.5.1 proto dhcp scope link src {address1} metric 24')
         self.assertRegex(output, f'192.168.5.6 proto dhcp scope link src {address1} metric 24')
         self.assertRegex(output, f'192.168.5.7 proto dhcp scope link src {address1} metric 24')
-        self.assertIn('10.0.0.0/8 via 192.168.5.1 proto dhcp', output)
+        self.assertRegex(output, f'192.0.2.0/24 via 192.168.5.1 proto dhcp src {address1}')
+
+        print('## ip route show table 212 dev veth99')
+        output = check_output('ip route show table 212 dev veth99')
+        print(output)
+        self.assertRegex(output, f'192.168.5.0/24 proto dhcp scope link src {address1} metric 24')
+        self.assertRegex(output, f'192.168.5.1 proto dhcp scope link src {address1} metric 24')
+        self.assertRegex(output, f'198.51.100.0/24 via 192.168.5.1 proto dhcp src {address1}')
 
         print('## link state file')
         output = read_link_state_file('veth99')
@@ -7221,7 +7228,14 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         self.assertNotIn('192.168.5.6', output)
         self.assertRegex(output, f'192.168.5.7 proto dhcp scope link src {address2} metric 24')
         self.assertRegex(output, f'192.168.5.8 proto dhcp scope link src {address2} metric 24')
-        self.assertIn('10.0.0.0/8 via 192.168.5.1 proto dhcp', output)
+        self.assertRegex(output, f'192.0.2.0/24 via 192.168.5.1 proto dhcp src {address2}')
+
+        print('## ip route show table 212 dev veth99')
+        output = check_output('ip route show table 212 dev veth99')
+        print(output)
+        self.assertRegex(output, f'192.168.5.0/24 proto dhcp scope link src {address2} metric 24')
+        self.assertRegex(output, f'192.168.5.1 proto dhcp scope link src {address2} metric 24')
+        self.assertRegex(output, f'198.51.100.0/24 via 192.168.5.1 proto dhcp src {address2}')
 
         print('## link state file')
         output = read_link_state_file('veth99')
@@ -7292,6 +7306,11 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         print(output)
         self.assertNotIn(f'{address2}', output)
 
+        print('## ip route show table 212 dev veth99')
+        output = check_output('ip route show table 212 dev veth99')
+        print(output)
+        self.assertNotIn(f'{address2}', output)
+
         self.teardown_nftset('addr4', 'network4', 'ifindex')
 
     def test_dhcp_client_ipv4_dbus_status(self):