]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test case for requesting routing policy rules by multiple interfaces 36257/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 4 Feb 2025 00:45:45 +0000 (09:45 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 4 Feb 2025 03:28:59 +0000 (12:28 +0900)
For issue #36244.

test/test-network/conf/25-routing-policy-rule-manual.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/25-routing-policy-rule-manual.network b/test/test-network/conf/25-routing-policy-rule-manual.network
new file mode 100644 (file)
index 0000000..fa13281
--- /dev/null
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Match]
+Name=test1
+Name=test2
+
+[Link]
+ActivationPolicy=manual
+
+[Network]
+IPv6AcceptRA=no
+
+[RoutingPolicyRule]
+Family=both
+Priority=10
+SuppressPrefixLength=0
+Table=51819
+
+[RoutingPolicyRule]
+Family=both
+FirewallMark=911
+InvertRule=true
+Priority=11
+Table=51820
index c865fbdbe307fdedc18ac2a33136b193ad3f3bab..9da626484aeb621be3e8bad8ef3e4ab4a59e62ba 100755 (executable)
@@ -3983,6 +3983,45 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         print(output)
         self.assertIn('10113:  from all iif test1 lookup 1011', output)
 
+    def test_routing_policy_rule_manual(self):
+        # For issue #36244.
+        copy_network_unit(
+            '11-dummy.netdev',
+            '25-routing-policy-rule-manual.network')
+        start_networkd()
+        self.wait_operstate('test1', operstate='off', setup_state='configuring', setup_timeout=20)
+
+        check_output('ip link add test2 type dummy')
+        self.wait_operstate('test2', operstate='off', setup_state='configuring', setup_timeout=20)
+
+        networkctl('up', 'test2')
+        self.wait_online('test2:degraded')
+
+        # The request for the routing policy rules are bound to test1. Hence, we need to wait for the rules
+        # being configured explicitly.
+        for _ in range(20):
+            time.sleep(0.5)
+
+            output = check_output('ip -4 rule list table 51819')
+            if output != '10:  from all lookup 51819 suppress_prefixlength 0 proto static':
+                continue
+
+            output = check_output('ip -6 rule list table 51819')
+            if output != '10:  from all lookup 51819 suppress_prefixlength 0 proto static':
+                continue
+
+            output = check_output('ip -4 rule list table 51820')
+            if output != '11:  not from all fwmark 0x38f lookup 51820 proto static':
+                continue
+
+            output = check_output('ip -6 rule list table 51820')
+            if output != '11:  not from all fwmark 0x38f lookup 51820 proto static':
+                continue
+
+            break
+        else:
+            self.assertFalse(True)
+
     @expectedFailureIfRoutingPolicyPortRangeIsNotAvailable()
     def test_routing_policy_rule_port_range(self):
         copy_network_unit('25-fibrule-port-range.network', '11-dummy.netdev')