1 Star 0 Fork 98

Mingtai/systemd

forked from src-openEuler/systemd 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
backport-network-also-check-addresses-when-determine-a-gatewa.patch 2.66 KB
Copy Edit Raw Blame History
From 2f599380f1ab1ee5fe3f7b02926ae2dd642bed9b Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Mon, 12 Jul 2021 15:46:44 +0900
Subject: [PATCH] network: also check addresses when determine a gateway
address is reachable or not
Fixes #20201.
(cherry picked from commit 11046cea1414c70b5d7aab37ea88d5a839cbd209)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/2f599380f1ab1ee5fe3f7b02926ae2dd642bed9b
---
src/network/networkd-route.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 77a93beca9..068915616e 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -746,6 +746,26 @@ static bool route_address_is_reachable(const Route *route, int family, const uni
FAMILY_ADDRESS_SIZE(family) * 8) > 0;
}
+static bool prefix_route_address_is_reachable(const Address *a, int family, const union in_addr_union *address) {
+ assert(a);
+ assert(IN_SET(family, AF_INET, AF_INET6));
+ assert(address);
+
+ if (a->family != family)
+ return false;
+ if (FLAGS_SET(a->flags, IFA_F_NOPREFIXROUTE))
+ return false;
+ if (in_addr_is_set(a->family, &a->in_addr_peer))
+ return false;
+
+ return in_addr_prefix_intersect(
+ family,
+ &a->in_addr,
+ a->prefixlen,
+ address,
+ FAMILY_ADDRESS_SIZE(family) * 8) > 0;
+}
+
bool manager_address_is_reachable(Manager *manager, int family, const union in_addr_union *address) {
Link *link;
@@ -764,6 +784,20 @@ bool manager_address_is_reachable(Manager *manager, int family, const union in_a
return true;
}
+ /* If we do not manage foreign routes, then there may exist a prefix route we do not know,
+ * which was created on configuring an address. Hence, also check the addresses. */
+ if (!manager->manage_foreign_routes)
+ HASHMAP_FOREACH(link, manager->links_by_index) {
+ Address *a;
+
+ SET_FOREACH(a, link->addresses)
+ if (prefix_route_address_is_reachable(a, family, address))
+ return true;
+ SET_FOREACH(a, link->addresses_foreign)
+ if (prefix_route_address_is_reachable(a, family, address))
+ return true;
+ }
+
return false;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangmingtaip/systemd.git
git@gitee.com:yangmingtaip/systemd.git
yangmingtaip
systemd
systemd
master

Search