diff --git a/test/test-network/conf/routing-policy-rule-reconfigure.network b/test/test-network/conf/routing-policy-rule-reconfigure1.network 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 ca38b78f13..96650c2551 100644 --- a/test/test-network/conf/routing-policy-rule-reconfigure.network +++ b/test/test-network/conf/routing-policy-rule-reconfigure1.network @@ -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 index 0000000000..d12fe04020 --- /dev/null +++ b/test/test-network/conf/routing-policy-rule-reconfigure2.network @@ -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 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 41d3e7036b..0d0923ea7b 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -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):