]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add tests for dropping unnecessary nexthops 18589/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Feb 2021 09:45:48 +0000 (18:45 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Feb 2021 13:48:12 +0000 (22:48 +0900)
test/test-network/conf/25-nexthop-nothing.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/25-nexthop-nothing.network b/test/test-network/conf/25-nexthop-nothing.network
new file mode 100644 (file)
index 0000000..fdaf32d
--- /dev/null
@@ -0,0 +1,8 @@
+[Match]
+Name=veth99
+
+[Network]
+IPv6AcceptRA=no
+Address=2001:1234:5:8f63::1/120
+Address=192.168.5.10/24
+Gateway=192.168.5.1
index 6c17b204a1136476ace63a6c17ce4c5c40e783c9..70285d2a89533c800de9424069f66ddf1780f37c 100755 (executable)
@@ -1801,6 +1801,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         '25-neighbor-ipv6.network',
         '25-neighbor-ip-dummy.network',
         '25-neighbor-ip.network',
+        '25-nexthop-nothing.network',
         '25-nexthop.network',
         '25-qdisc-cake.network',
         '25-qdisc-clsact-and-htb.network',
@@ -2868,6 +2869,33 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         print(output)
         self.assertEqual('blackhole 2001:1234:5:8f62::2 nhid 7 dev lo proto static metric 1024 pref medium', output)
 
+        remove_unit_from_networkd_path(['25-nexthop.network'])
+        copy_unit_to_networkd_unit_path('25-nexthop-nothing.network')
+        rc = call(*networkctl_cmd, 'reload', env=env)
+        self.assertEqual(rc, 0)
+        time.sleep(1)
+
+        output = check_output('ip nexthop list dev veth99')
+        print(output)
+        self.assertEqual(output, '')
+        output = check_output('ip nexthop list dev lo')
+        print(output)
+        self.assertEqual(output, '')
+
+        remove_unit_from_networkd_path(['25-nexthop-nothing.network'])
+        copy_unit_to_networkd_unit_path('25-nexthop.network')
+        rc = call(*networkctl_cmd, 'reload', env=env)
+        self.assertEqual(rc, 0)
+        time.sleep(1)
+
+        rc = call('ip link del veth99')
+        self.assertEqual(rc, 0)
+        time.sleep(2)
+
+        output = check_output('ip nexthop list dev lo')
+        print(output)
+        self.assertEqual(output, '')
+
     def test_qdisc(self):
         copy_unit_to_networkd_unit_path('25-qdisc-clsact-and-htb.network', '12-dummy.netdev',
                                         '25-qdisc-ingress-netem-compat.network', '11-dummy.netdev')