]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add tests for fib rules with Family=both vs networkctl reload or reconf... 18109/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Dec 2020 18:32:07 +0000 (03:32 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Dec 2020 18:32:07 +0000 (03:32 +0900)
test/test-network/conf/routing-policy-rule-reconfigure1.network [moved from test/test-network/conf/routing-policy-rule-reconfigure.network with 96% similarity]
test/test-network/conf/routing-policy-rule-reconfigure2.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

similarity index 96%
rename from test/test-network/conf/routing-policy-rule-reconfigure.network
rename to test/test-network/conf/routing-policy-rule-reconfigure1.network
index ca38b78f130f1864006aca49e77ed3a1b3cb01d8..96650c2551c77deb9c400da39712027e8a362a2c 100644 (file)
@@ -21,7 +21,7 @@ OutgoingInterface=test1
 # iif
 [RoutingPolicyRule]
 Table=1011
-Family=ipv4
+Family=both
 Priority=10113
 IncomingInterface=test1
 
diff --git a/test/test-network/conf/routing-policy-rule-reconfigure2.network b/test/test-network/conf/routing-policy-rule-reconfigure2.network
new file mode 100644 (file)
index 0000000..d12fe04
--- /dev/null
@@ -0,0 +1,33 @@
+[Match]
+Name=test1
+
+[Network]
+IPv6AcceptRA=no
+
+# fwmark
+[RoutingPolicyRule]
+Table=1011
+Family=ipv4
+Priority=10111
+FirewallMark=1011
+
+# oif
+[RoutingPolicyRule]
+Table=1011
+Family=both
+Priority=10112
+OutgoingInterface=test1
+
+# iif
+[RoutingPolicyRule]
+Table=1011
+Family=ipv4
+Priority=10113
+IncomingInterface=test1
+
+# source
+[RoutingPolicyRule]
+Table=1011
+Family=ipv4
+Priority=10114
+From=192.168.8.254
index 41d3e7036ba56c1d0e68210edb0b3ae4ad0b8003..0d0923ea7b18fe73f1063ae2858ff7fd597511d3 100755 (executable)
@@ -1800,7 +1800,8 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         '26-link-local-addressing-ipv6.network',
         'routing-policy-rule-dummy98.network',
         'routing-policy-rule-test1.network',
-        'routing-policy-rule-reconfigure.network',
+        'routing-policy-rule-reconfigure1.network',
+        'routing-policy-rule-reconfigure2.network',
     ]
 
     routing_policy_rule_tables = ['7', '8', '9', '1011']
@@ -2084,37 +2085,65 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
             stop_networkd(remove_state_files=False)
 
     def test_routing_policy_rule_reconfigure(self):
-        copy_unit_to_networkd_unit_path('routing-policy-rule-reconfigure.network', '11-dummy.netdev')
+        copy_unit_to_networkd_unit_path('routing-policy-rule-reconfigure2.network', '11-dummy.netdev')
         start_networkd()
         self.wait_online(['test1:degraded'])
 
         output = check_output('ip rule list table 1011')
         print(output)
-        self.assertRegex(output, '10111:       from all fwmark 0x3f3 lookup 1011')
-        self.assertRegex(output, '10112:       from all oif test1 lookup 1011')
-        self.assertRegex(output, '10113:       from all iif test1 lookup 1011')
-        self.assertRegex(output, '10114:       from 192.168.8.254 lookup 1011')
+        self.assertIn('10111:  from all fwmark 0x3f3 lookup 1011', output)
+        self.assertIn('10112:  from all oif test1 lookup 1011', output)
+        self.assertIn('10113:  from all iif test1 lookup 1011', output)
+        self.assertIn('10114:  from 192.168.8.254 lookup 1011', output)
+
+        output = check_output('ip -6 rule list table 1011')
+        print(output)
+        self.assertIn('10112:  from all oif test1 lookup 1011', output)
+
+        copy_unit_to_networkd_unit_path('routing-policy-rule-reconfigure1.network', '11-dummy.netdev')
+        run(*networkctl_cmd, 'reload', env=env)
+        time.sleep(1)
+        self.wait_online(['test1:degraded'])
+
+        output = check_output('ip rule list table 1011')
+        print(output)
+        self.assertIn('10111:  from all fwmark 0x3f3 lookup 1011', output)
+        self.assertIn('10112:  from all oif test1 lookup 1011', output)
+        self.assertIn('10113:  from all iif test1 lookup 1011', output)
+        self.assertIn('10114:  from 192.168.8.254 lookup 1011', output)
+
+        output = check_output('ip -6 rule list table 1011')
+        print(output)
+        self.assertNotIn('10112:       from all oif test1 lookup 1011', output)
+        self.assertIn('10113:  from all iif test1 lookup 1011', output)
 
         run('ip rule delete priority 10111')
         run('ip rule delete priority 10112')
         run('ip rule delete priority 10113')
         run('ip rule delete priority 10114')
-        run('ip rule delete priority 10115')
+        run('ip -6 rule delete priority 10113')
 
         output = check_output('ip rule list table 1011')
         print(output)
         self.assertEqual(output, '')
 
-        run(*networkctl_cmd, 'reconfigure', 'test1', env=env)
+        output = check_output('ip -6 rule list table 1011')
+        print(output)
+        self.assertEqual(output, '')
 
+        run(*networkctl_cmd, 'reconfigure', 'test1', env=env)
         self.wait_online(['test1:degraded'])
 
         output = check_output('ip rule list table 1011')
         print(output)
-        self.assertRegex(output, '10111:       from all fwmark 0x3f3 lookup 1011')
-        self.assertRegex(output, '10112:       from all oif test1 lookup 1011')
-        self.assertRegex(output, '10113:       from all iif test1 lookup 1011')
-        self.assertRegex(output, '10114:       from 192.168.8.254 lookup 1011')
+        self.assertIn('10111:  from all fwmark 0x3f3 lookup 1011', output)
+        self.assertIn('10112:  from all oif test1 lookup 1011', output)
+        self.assertIn('10113:  from all iif test1 lookup 1011', output)
+        self.assertIn('10114:  from 192.168.8.254 lookup 1011', output)
+
+        output = check_output('ip -6 rule list table 1011')
+        print(output)
+        self.assertIn('10113:  from all iif test1 lookup 1011', output)
 
     @expectedFailureIfRoutingPolicyPortRangeIsNotAvailable()
     def test_routing_policy_rule_port_range(self):