]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/route: fix reachability check when peer address is specified
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 10 Dec 2023 04:56:46 +0000 (13:56 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 10 Dec 2023 05:01:33 +0000 (14:01 +0900)
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

index a204fb9631950a9f74624f34798f68b09353ff3c..d49a0b95124a2cac1295f809c372eea12085b09f 100644 (file)
@@ -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;
         }