From e091ed405353624f2da28e2f3210e205f7eab370 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 10 Dec 2023 13:56:46 +0900 Subject: [PATCH 1/2] network/route: fix reachability check when peer address is specified When an address with peer address is specified, the kernel by default adds the prefix route for the peer address. When ManageForeignRoute=no is set, then we also needs to check the prefix for the peer address. Fixes #30403. --- src/network/networkd-route-util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/networkd-route-util.c b/src/network/networkd-route-util.c index a204fb9631..d49a0b9512 100644 --- a/src/network/networkd-route-util.c +++ b/src/network/networkd-route-util.c @@ -162,9 +162,9 @@ bool gateway_is_ready(Link *link, bool onlink, int family, const union in_addr_u continue; if (FLAGS_SET(a->flags, IFA_F_NOPREFIXROUTE)) continue; - if (in_addr_is_set(a->family, &a->in_addr_peer)) - continue; - if (in_addr_prefix_covers(family, &a->in_addr, a->prefixlen, gw) > 0) + if (in_addr_prefix_covers(a->family, + in_addr_is_set(a->family, &a->in_addr_peer) ? &a->in_addr_peer : &a->in_addr, + a->prefixlen, gw) > 0) return true; } From 5e46ca9890bb463644f91426678570edc2891163 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 10 Dec 2023 14:04:28 +0900 Subject: [PATCH 2/2] test-network: add test case for issue #30403 --- test/test-network/conf/25-route-static.network | 7 +++++++ test/test-network/systemd-networkd-tests.py | 1 + 2 files changed, 8 insertions(+) diff --git a/test/test-network/conf/25-route-static.network b/test/test-network/conf/25-route-static.network index 3574f021b0..7ef211d410 100644 --- a/test/test-network/conf/25-route-static.network +++ b/test/test-network/conf/25-route-static.network @@ -108,3 +108,10 @@ MultiPathRoute=2001:1234:5:6fff:ff:ff:ff:ff@test1 20 MultiPathRoute=2001:1234:5:7fff:ff:ff:ff:ff@test1 30 MultiPathRoute=2001:1234:5:8fff:ff:ff:ff:ff@dummy98 10 MultiPathRoute=2001:1234:5:9fff:ff:ff:ff:ff@dummy98 5 + +[Address] +Address=1.1.8.105/31 +Peer=1.1.8.104/31 + +[Route] +Gateway=1.1.8.104 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 8ffcda37ed..9df204fd1d 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3095,6 +3095,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): self.assertIn('default via 149.10.125.65 proto static onlink', output) self.assertIn('default via 149.10.124.64 proto static', output) self.assertIn('default proto static', output) + self.assertIn('default via 1.1.8.104 proto static', output) print('### ip -4 route show table local dev dummy98') output = check_output('ip -4 route show table local dev dummy98')