From e2d9bc5cfd7fb1affd665c3f6aa57e408a6ab082 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 14 Feb 2021 15:19:06 +0900 Subject: [PATCH] test-network: add a test for OnLink= in [NextHop] section --- test/test-network/conf/25-nexthop.network | 9 +++++++++ test/test-network/systemd-networkd-tests.py | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/test/test-network/conf/25-nexthop.network b/test/test-network/conf/25-nexthop.network index d4c7aa606c4..a0b220f9184 100644 --- a/test/test-network/conf/25-nexthop.network +++ b/test/test-network/conf/25-nexthop.network @@ -23,6 +23,11 @@ Family=ipv6 Id=4 Family=ipv4 +[NextHop] +Id=5 +Gateway=192.168.10.1 +OnLink=yes + [NextHop] Gateway=192.168.5.2 @@ -37,3 +42,7 @@ Destination=10.10.10.11 [Route] NextHop=2 Destination=2001:1234:5:8f62::1 + +[Route] +NextHop=5 +Destination=10.10.10.12 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index a5942ec4ea7..38480e1ce58 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2812,6 +2812,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): self.assertIn('id 2 via 2001:1234:5:8f63::2 dev veth99', output) self.assertIn('id 3 dev veth99', output) self.assertIn('id 4 dev veth99', output) + self.assertRegex(output, 'id 5 via 192.168.10.1 dev veth99 .*onlink') self.assertRegex(output, r'id [0-9]* via 192.168.5.2 dev veth99') output = check_output('ip route show dev veth99 10.10.10.10') @@ -2822,6 +2823,10 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertEqual('10.10.10.11 nhid 2 via inet6 2001:1234:5:8f63::2 proto static', output) + output = check_output('ip route show dev veth99 10.10.10.12') + print(output) + self.assertEqual('10.10.10.12 nhid 5 via 192.168.10.1 proto static onlink', output) + output = check_output('ip -6 route show dev veth99 2001:1234:5:8f62::1') print(output) self.assertEqual('2001:1234:5:8f62::1 nhid 2 via 2001:1234:5:8f63::2 proto static metric 1024 pref medium', output)