fix ipv6 external route miss

This commit is contained in:
chxssg 2022-03-09 14:54:48 +08:00
parent 4bde73854e
commit e8aaa793bd
2 changed files with 102 additions and 1 deletions

View File

@ -50,7 +50,7 @@
Name: NetworkManager
Version: 1.32.12
Epoch: 1
Release: 3
Release: 4
Summary: Network Link Manager and User Applications
License: GPLv2+
URL: https://www.gnome.org/projects/NetworkManager/
@ -59,6 +59,7 @@ Source1: NetworkManager.conf
Source2: 00-server.conf
Patch1: fix-wants-and-add-requires.patch
Patch2: bugfix-use-PartOf-replace-Requires-in-service.patch
Patch3: bugfix-ipv6-external-route-miss.patch
BuildRequires: gcc libtool pkgconfig automake autoconf intltool gettext-devel ppp-devel gnutls-devel
BuildRequires: dbus-devel dbus-glib-devel glib2-devel gobject-introspection-devel jansson-devel
@ -476,6 +477,12 @@ fi
%{_datadir}/gtk-doc/html/NetworkManager/*
%changelog
* Wen Mar 9 2022 chxssg <chxssg@qq.com> - 1.32.12-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix ipv6 external route miss
* Mon Mar 7 2022 seuzw <930zhaowei@163.com> - 1.32.12-3
- Type:bugfix
- ID:NA

View File

@ -0,0 +1,94 @@
From 386467d16455cc027d1ff9a6ef65d01c172a9f8f Mon Sep 17 00:00:00 2001
From: gaoxingwang <gaoxingwang@huawei.com>
Date: Mon, 7 Mar 2022 11:04:17 +0800
Subject: [PATCH] revert external flag
---
src/libnm-platform/nm-platform.c | 44 ++++++++------------------------
1 file changed, 10 insertions(+), 34 deletions(-)
diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c
index b7a65df..9b9c194 100644
--- a/src/libnm-platform/nm-platform.c
+++ b/src/libnm-platform/nm-platform.c
@@ -4528,20 +4528,6 @@ nm_platform_ip_route_sync(NMPlatform *self,
conf_o = routes->pdata[i];
- if (NMP_OBJECT_CAST_IP_ROUTE(conf_o)->is_external) {
- /* This route is added externally. We don't have our own agenda to
- * add it, so skip. */
- continue;
- }
-
- /* User space cannot add IPv6 routes with metric 0. However, kernel can, and we might track such
- * routes in @route as they are present external. As we already skipped external routes above,
- * we don't expect a user's choice to add such a route (it won't work anyway). */
- nm_assert(
- IS_IPv4
- || nm_platform_ip6_route_get_effective_metric(NMP_OBJECT_CAST_IP6_ROUTE(conf_o))
- != 0);
-
#define VTABLE_IS_DEVICE_ROUTE(vt, o) \
(vt->is_ip4 ? (NMP_OBJECT_CAST_IP4_ROUTE(o)->gateway == 0) \
: IN6_IS_ADDR_UNSPECIFIED(&NMP_OBJECT_CAST_IP6_ROUTE(o)->gateway))
@@ -4558,7 +4544,7 @@ nm_platform_ip_route_sync(NMPlatform *self,
routes_idx = g_hash_table_new((GHashFunc) nmp_object_id_hash,
(GEqualFunc) nmp_object_id_equal);
}
- if (!g_hash_table_add(routes_idx, (gpointer) conf_o)) {
+ if (!g_hash_table_insert(routes_idx, (gpointer) conf_o, (gpointer) conf_o)) {
_LOG3D("route-sync: skip adding duplicate route %s",
nmp_object_to_string(conf_o,
NMP_OBJECT_TO_STRING_PUBLIC,
@@ -4567,6 +4553,14 @@ nm_platform_ip_route_sync(NMPlatform *self,
continue;
}
+ if (!IS_IPv4
+ && nm_platform_ip6_route_get_effective_metric(NMP_OBJECT_CAST_IP6_ROUTE(conf_o))
+ == 0) {
+ /* User space cannot add routes with metric 0. However, kernel can, and we might track such
+ * routes in @route as they are present external. Skip them silently. */
+ continue;
+ }
+
plat_entry = nm_platform_lookup_entry(self, NMP_CACHE_ID_TYPE_OBJECT_TYPE, conf_o);
if (plat_entry) {
const NMPObject *plat_o;
@@ -4729,24 +4723,6 @@ sync_route_add:
}
if (routes_prune) {
- if (routes) {
- for (i = 0; i < routes->len; i++) {
- conf_o = routes->pdata[i];
-
- if (NMP_OBJECT_CAST_IP_ROUTE(conf_o)->is_external) {
- /* this is only to catch the case where an external route is
- * both in @routes and @routes_prune list. In that case,
- * @routes should win and we should not remove the address. */
- if (!routes_idx) {
- routes_idx = g_hash_table_new((GHashFunc) nmp_object_id_hash,
- (GEqualFunc) nmp_object_id_equal);
- }
- g_hash_table_add(routes_idx, (gpointer) conf_o);
- continue;
- }
- }
- }
-
for (i = 0; i < routes_prune->len; i++) {
const NMPObject *prune_o;
@@ -4757,7 +4733,7 @@ sync_route_add:
|| (!NM_IS_IPv4(addr_family)
&& NMP_OBJECT_GET_TYPE(prune_o) == NMP_OBJECT_TYPE_IP6_ROUTE));
- if (nm_g_hash_table_lookup(routes_idx, prune_o))
+ if (routes_idx && g_hash_table_lookup(routes_idx, prune_o))
continue;
if (!nm_platform_lookup_entry(self, NMP_CACHE_ID_TYPE_OBJECT_TYPE, prune_o))
--
2.33.0