diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-20 03:33:42 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-20 14:02:31 +0200 |
commit | 085818569b89e72e4d7b6dfed3b3f3230be0fe9e (patch) | |
tree | d8e7237f5958c76d2687c53b3e93533f3c736ebd /test/test-network | |
parent | test-network: add tests for Type=table, goto, and nop (diff) | |
download | systemd-085818569b89e72e4d7b6dfed3b3f3230be0fe9e.tar.xz systemd-085818569b89e72e4d7b6dfed3b3f3230be0fe9e.zip |
test-network: add test for ManageForeignRoutingPolicyRules=
Diffstat (limited to 'test/test-network')
-rw-r--r-- | test/test-network/conf/networkd-manage-foreign-rules-no.conf | 3 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 38 |
2 files changed, 40 insertions, 1 deletions
diff --git a/test/test-network/conf/networkd-manage-foreign-rules-no.conf b/test/test-network/conf/networkd-manage-foreign-rules-no.conf new file mode 100644 index 0000000000..b376889fc8 --- /dev/null +++ b/test/test-network/conf/networkd-manage-foreign-rules-no.conf @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Network] +ManageForeignRoutingPolicyRules=no diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index fbe5e758ec..b2aadde36c 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3240,14 +3240,50 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertRegex(output, r'112: from 192.168.101.18 tos (0x08|throughput) iif dummy98 oif dummy98 lookup 8') - def test_routing_policy_rule(self): + def _test_routing_policy_rule(self, manage_foreign_routes): + if not manage_foreign_routes: + copy_networkd_conf_dropin('networkd-manage-foreign-rules-no.conf') copy_network_unit('25-routing-policy-rule-test1.network', '11-dummy.netdev') + + stop_networkd() + + check_output('ip -4 rule add priority 20001 table 9999 from 10.10.0.0/16') + check_output('ip -6 rule add priority 20001 table 9999 from 2001:db8:0:1::/64') + start_networkd() self.wait_online('test1:degraded') self.check_routing_policy_rule_test1() check_json(networkctl_json()) + output = check_output('ip -4 rule list priority 20001 table 9999 from 10.10.0.0/16') + print(output) + if manage_foreign_routes: + self.assertEqual(output, '') + else: + self.assertIn(output, '20001: from 10.10.0.0/16 lookup 9999') + check_output('ip -4 rule del priority 20001 table 9999 from 10.10.0.0/16') + + output = check_output('ip -6 rule list priority 20001 table 9999 from 2001:db8:0:1::/64') + print(output) + if manage_foreign_routes: + self.assertEqual(output, '') + else: + self.assertIn(output, '20001: from 2001:db8:0:1::/64 lookup 9999') + check_output('ip -6 rule del priority 20001 table 9999 from 2001:db8:0:1::/64') + + def test_routing_policy_rule(self): + first = True + for manage_foreign_routes in [True, False]: + if first: + first = False + else: + self.tearDown() + + print(f'### test_routing_policy_rule(manage_foreign_routes={manage_foreign_routes})') + with self.subTest(manage_foreign_routes=manage_foreign_routes): + self._test_routing_policy_rule(manage_foreign_routes) + def test_routing_policy_rule_issue_11280(self): copy_network_unit('25-routing-policy-rule-test1.network', '11-dummy.netdev', '25-routing-policy-rule-dummy98.network', '12-dummy.netdev') |