diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-11-29 08:49:24 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-11-30 20:00:16 +0100 |
commit | 6387cac3f34b2d2da02bc7ccacfea1d3dfbf3bb9 (patch) | |
tree | d95a43920eb888ebe79936d55a222bba9a698223 /test | |
parent | network: wireguard: automatically configure routes to addresses specified in ... (diff) | |
download | systemd-6387cac3f34b2d2da02bc7ccacfea1d3dfbf3bb9.tar.xz systemd-6387cac3f34b2d2da02bc7ccacfea1d3dfbf3bb9.zip |
test-network: add tests for creating routes to wireguard's AllowedIPs=
Diffstat (limited to 'test')
-rw-r--r-- | test/test-network/conf/25-wireguard-23-peers.netdev | 2 | ||||
-rw-r--r-- | test/test-network/conf/25-wireguard-23-peers.network | 92 | ||||
-rw-r--r-- | test/test-network/conf/25-wireguard.netdev | 5 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 57 |
4 files changed, 64 insertions, 92 deletions
diff --git a/test/test-network/conf/25-wireguard-23-peers.netdev b/test/test-network/conf/25-wireguard-23-peers.netdev index 90ea1b9450..86f1440158 100644 --- a/test/test-network/conf/25-wireguard-23-peers.netdev +++ b/test/test-network/conf/25-wireguard-23-peers.netdev @@ -11,6 +11,8 @@ ListenPort=4500 # The key below should be overridden by PrivateKeyFile= PrivateKey=EEGlnEPYJV//kbvvIqxKkQwOiS+UENyPncC4bF46ong= PrivateKeyFile=/run/systemd/network/25-wireguard-private-key.txt +RouteTable=1234 +RouteMetric=123 # peer 1 [WireGuardPeer] diff --git a/test/test-network/conf/25-wireguard-23-peers.network b/test/test-network/conf/25-wireguard-23-peers.network index 33c794c267..6f4c2d030c 100644 --- a/test/test-network/conf/25-wireguard-23-peers.network +++ b/test/test-network/conf/25-wireguard-23-peers.network @@ -6,95 +6,3 @@ Name=wg98 Address=192.168.123.123/24 Address=fd8d:4d6d:3ccb:0500::1/64 IPv6AcceptRA=no - -# nat64 via 1 -[Route] -Destination = fd8d:4d6d:3ccb:0c79:2339:edce::/96 - -# nat64 via 2 -[Route] -Destination = fd8d:4d6d:3ccb:a072:80da:de4f::/96 - -# nat64 via 3 -[Route] -Destination = fd8d:4d6d:3ccb:f349:c4f0:10c1::/96 - -# nat64 via 4 -[Route] -Destination = fd8d:4d6d:3ccb:b684:4f81:2e3e::/96 - -# nat64 via 5 -[Route] -Destination = fd8d:4d6d:3ccb:c624:6bf7:4c09::/96 - -# nat64 via 6 -[Route] -Destination = fd8d:4d6d:3ccb:9c11:d820:2e96::/96 - -# nat64 via 7 -[Route] -Destination = fd8d:4d6d:3ccb:bad5:495d:8e9c::/96 - -# nat64 via 8 -[Route] -Destination = fd8d:4d6d:3ccb:1e54:1415:35d0::/96 - -# nat64 via 9 -[Route] -Destination = fd8d:4d6d:3ccb:1dbf:ca8a:32d3::/96 - -# nat64 via 10 -[Route] -Destination = fd8d:4d6d:3ccb:dcdd:d33b:90c9::/96 - -# nat64 via 11 -[Route] -Destination = fd8d:4d6d:3ccb:6f2e:6888:c6fd::/96 - -# nat64 via 12 -[Route] -Destination = fd8d:4d6d:3ccb:d4f9:05dc:9296::/96 - -# nat64 via 13 -[Route] -Destination = fd8d:4d6d:3ccb:b39c:9cdc:755a::/96 - -# nat64 via 14 -[Route] -Destination = fd8d:4d6d:3ccb:bfe5:c3c3:5d77::/96 - -# nat64 via 15 -[Route] -Destination = fd8d:4d6d:3ccb:900c:d437:ec27::/96 - -# nat64 via 16 -[Route] -Destination = fd8d:4d6d:3ccb:270d:b5dd:4a3f::/96 - -# nat64 via 17 -[Route] -Destination = fd8d:4d6d:3ccb:e2e1:ae15:103f::/96 - -# nat64 via 18 -[Route] -Destination = fd8d:4d6d:3ccb:5660:679d:3532::/96 - -# nat64 via 19 -[Route] -Destination = fd8d:4d6d:3ccb:6825:573f:30f3::/96 - -# nat64 via 20 -[Route] -Destination = fd8d:4d6d:3ccb:a94b:cd6a:a32d::/96 - -# nat64 via 21 -[Route] -Destination = fd8d:4d6d:3ccb:8d4d:0bab:7280::/96 - -# nat64 via 22 -[Route] -Destination = fd8d:4d6d:3ccb:a3f3:df38:19b0::/96 - -# nat64 via 23 -[Route] -Destination = fd8d:4d6d:3ccb:9742:9931:5217::/96 diff --git a/test/test-network/conf/25-wireguard.netdev b/test/test-network/conf/25-wireguard.netdev index 075f2bd6a8..16f63d00bd 100644 --- a/test/test-network/conf/25-wireguard.netdev +++ b/test/test-network/conf/25-wireguard.netdev @@ -6,6 +6,9 @@ Kind=wireguard [WireGuard] ListenPort=51820 FwMark=1234 +# settings below are ignored. +RouteTable=off +RouteMetric=456 [WireGuardPeer] PublicKey=RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA= @@ -14,3 +17,5 @@ AllowedIPs=fd31:bf08:57cb::/48,192.168.26.0/24 Endpoint=192.168.27.3:51820 PresharedKey=IIWIV17wutHv7t4cR6pOT91z6NSz/T8Arh0yaywhw3M= PersistentKeepalive=20 +RouteTable=1234 +RouteMetric=123 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 4d4f792707..2c70a05719 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -1383,6 +1383,63 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities): print(output) self.assertIn('inet6 fd8d:4d6d:3ccb:500::1/64 scope global', output) + output = check_output('ip -4 route show dev wg99 table 1234') + print(output) + self.assertIn('192.168.26.0/24 proto static metric 123', output) + + output = check_output('ip -6 route show dev wg99 table 1234') + print(output) + self.assertIn('fd31:bf08:57cb::/48 proto static metric 123 pref medium', output) + + output = check_output('ip -6 route show dev wg98 table 1234') + print(output) + self.assertIn('fd8d:4d6d:3ccb:500:c79:2339:edce:ece1 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:1dbf:ca8a:32d3:dd81 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:1e54:1415:35d0:a47c proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:270d:b5dd:4a3f:8909 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:5660:679d:3532:94d8 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:6825:573f:30f3:9472 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:6f2e:6888:c6fd:dfb9 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:8d4d:bab:7280:a09a proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:900c:d437:ec27:8822 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:9742:9931:5217:18d5 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:9c11:d820:2e96:9be0 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:a072:80da:de4f:add1 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:a3f3:df38:19b0:721 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:a94b:cd6a:a32d:90e6 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:b39c:9cdc:755a:ead3 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:b684:4f81:2e3e:132e proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:bad5:495d:8e9c:3427 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:bfe5:c3c3:5d77:fcb proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:c624:6bf7:4c09:3b59 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:d4f9:5dc:9296:a1a proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:dcdd:d33b:90c9:6088 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:e2e1:ae15:103f:f376 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:500:f349:c4f0:10c1:6b4 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:c79:2339:edce::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:1dbf:ca8a:32d3::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:1e54:1415:35d0::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:270d:b5dd:4a3f::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:5660:679d:3532::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:6825:573f:30f3::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:6f2e:6888:c6fd::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:8d4d:bab:7280::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:900c:d437:ec27::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:9742:9931:5217::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:9c11:d820:2e96::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:a072:80da:de4f::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:a3f3:df38:19b0::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:a94b:cd6a:a32d::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:b39c:9cdc:755a::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:b684:4f81:2e3e::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:bad5:495d:8e9c::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:bfe5:c3c3:5d77::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:c624:6bf7:4c09::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:d4f9:5dc:9296::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:dcdd:d33b:90c9::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:e2e1:ae15:103f::/96 proto static metric 123 pref medium', output) + self.assertIn('fd8d:4d6d:3ccb:f349:c4f0:10c1::/96 proto static metric 123 pref medium', output) + if shutil.which('wg'): call('wg') |