diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-20 03:07:10 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-20 14:02:31 +0200 |
commit | 49454d9ced87d53ada9a3a2860ce1dbd4a1da2b0 (patch) | |
tree | 229ed20b76befcbe0bf4e9686b36604bd0a98e79 /test/test-network | |
parent | test-network: do not pass '[detached]' to 'ip rule del' (diff) | |
download | systemd-49454d9ced87d53ada9a3a2860ce1dbd4a1da2b0.tar.xz systemd-49454d9ced87d53ada9a3a2860ce1dbd4a1da2b0.zip |
test-network: add tests for Type=table, goto, and nop
Diffstat (limited to 'test/test-network')
-rw-r--r-- | test/test-network/conf/25-routing-policy-rule-test1.network | 16 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 60 |
2 files changed, 44 insertions, 32 deletions
diff --git a/test/test-network/conf/25-routing-policy-rule-test1.network b/test/test-network/conf/25-routing-policy-rule-test1.network index 7d6e17cf6c..2cec4334fd 100644 --- a/test/test-network/conf/25-routing-policy-rule-test1.network +++ b/test/test-network/conf/25-routing-policy-rule-test1.network @@ -27,7 +27,23 @@ Priority=101 Family=both [RoutingPolicyRule] +Type=table IncomingInterface=test1 From=0.0.0.0/8 Table=10 Priority=102 + +[RoutingPolicyRule] +Type=goto +IncomingInterface=test1 +From=10.0.0.0/16 +Priority=103 +GoTo=111 +Table=11 + +[RoutingPolicyRule] +Type=nop +IncomingInterface=test1 +From=10.1.0.0/16 +Priority=104 +Table=12 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index c88f75b488..fbe5e758ec 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3210,41 +3210,42 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): self.assertNotRegex(output, '192.168.0.1') self.assertRegex(output, routable_map[carrier]) - def test_routing_policy_rule(self): - copy_network_unit('25-routing-policy-rule-test1.network', '11-dummy.netdev') - start_networkd() - self.wait_online('test1:degraded') - + def check_routing_policy_rule_test1(self): output = check_output('ip rule list iif test1 priority 111') print(output) - self.assertRegex(output, '111:') - self.assertRegex(output, 'from 192.168.100.18') - self.assertRegex(output, r'tos (0x08|throughput)\s') - self.assertRegex(output, 'iif test1') - self.assertRegex(output, 'oif test1') - self.assertRegex(output, 'lookup 7') + self.assertRegex(output, r'111: from 192.168.100.18 tos (0x08|throughput) iif test1 oif test1 lookup 7') - output = check_output('ip rule list iif test1 priority 101') + output = check_output('ip -6 rule list iif test1 priority 100') print(output) - self.assertRegex(output, '101:') - self.assertRegex(output, 'from all') - self.assertRegex(output, 'iif test1') - self.assertRegex(output, 'lookup 9') + self.assertIn('100: from all iif test1 lookup 8', output) - output = check_output('ip -6 rule list iif test1 priority 100') + output = check_output('ip rule list iif test1 priority 101') print(output) - self.assertRegex(output, '100:') - self.assertRegex(output, 'from all') - self.assertRegex(output, 'iif test1') - self.assertRegex(output, 'lookup 8') + self.assertIn('101: from all iif test1 lookup 9', output) output = check_output('ip rule list iif test1 priority 102') print(output) - self.assertRegex(output, '102:') - self.assertRegex(output, 'from 0.0.0.0/8') - self.assertRegex(output, 'iif test1') - self.assertRegex(output, 'lookup 10') + self.assertIn('102: from 0.0.0.0/8 iif test1 lookup 10', output) + output = check_output('ip rule list iif test1 priority 103') + print(output) + self.assertIn('103: from 10.0.0.0/16 iif test1 lookup 11 goto 111', output) + + output = check_output('ip rule list iif test1 priority 104') + print(output) + self.assertIn('104: from 10.1.0.0/16 iif test1 lookup 12 nop', output) + + def check_routing_policy_rule_dummy98(self): + output = check_output('ip rule list table 8') + 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): + copy_network_unit('25-routing-policy-rule-test1.network', '11-dummy.netdev') + start_networkd() + self.wait_online('test1:degraded') + + self.check_routing_policy_rule_test1() check_json(networkctl_json()) def test_routing_policy_rule_issue_11280(self): @@ -3255,13 +3256,8 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): restart_networkd(show_logs=(trial > 0)) self.wait_online('test1:degraded', 'dummy98:degraded') - output = check_output('ip rule list table 7') - print(output) - self.assertRegex(output, '111: from 192.168.100.18 tos (0x08|throughput) iif test1 oif test1 lookup 7') - - output = check_output('ip rule list table 8') - print(output) - self.assertRegex(output, '112: from 192.168.101.18 tos (0x08|throughput) iif dummy98 oif dummy98 lookup 8') + self.check_routing_policy_rule_test1() + self.check_routing_policy_rule_dummy98() def test_routing_policy_rule_reconfigure(self): copy_network_unit('25-routing-policy-rule-reconfigure2.network', '11-dummy.netdev') |