From 09c7c911d702fbe906c5c97435551416d27a2bf9 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Tue, 21 Jul 2020 13:51:17 +0200
Subject: [PATCH 1/2] core: only expose "type unicast" routes on D-Bus
Currently, we would not mark non-unicast routes with their type, so they
would wrongly appear as unicast routes in the D-Bus API.
That is wrong. For now, just hide them.
Fixes: 5d0d13f57010 ('platform: add support for local routes')
(cherry picked from commit 5035687a7be4c67e32b4e08319f2e66c76b42212)
(cherry picked from commit cf3cff4f12e78615c18fd829b1f32eac4f607c0b)
---
src/nm-ip4-config.c | 3 +++
src/nm-ip6-config.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index f017a3e809f4..9ad811642317 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -3227,6 +3227,9 @@ out_addresses_cached:
nm_assert (_route_valid (route));
+ if (route->type_coerced != nm_platform_route_type_coerce (RTN_UNICAST))
+ continue;
+
g_variant_builder_init (&route_builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&route_builder, "{sv}",
"dest",
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
index 1589cad004af..deb30e77d757 100644
--- a/src/nm-ip6-config.c
+++ b/src/nm-ip6-config.c
@@ -2682,6 +2682,9 @@ out_addresses_cached:
nm_assert (_route_valid (route));
+ if (route->type_coerced != nm_platform_route_type_coerce (RTN_UNICAST))
+ continue;
+
g_variant_builder_init (&route_builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&route_builder, "{sv}",
"dest",
--
2.26.2
From 52fe9dec97eb7d57594141732694453ce2db08d5 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Tue, 21 Jul 2020 18:06:21 +0200
Subject: [PATCH 2/2] core: fix selecting of best-default-route to consider
only unicast routes
Fixes: 5d0d13f57010 ('platform: add support for local routes')
(cherry picked from commit 2a1bac6b8a7d107f33bbdb9d91eaf924fa67b64a)
(cherry picked from commit 99b362c9443591b2b643aa09980f1a5dd42b1f6b)
---
src/nm-ip4-config.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h
index dc8222fd5a7b..ea0617497607 100644
--- a/src/nm-ip4-config.h
+++ b/src/nm-ip4-config.h
@@ -83,7 +83,8 @@ nm_ip_config_best_default_route_is (const NMPObject *obj)
* Note that this only considers the main routing table. */
return r
&& NM_PLATFORM_IP_ROUTE_IS_DEFAULT (r)
- && nm_platform_route_table_is_main (r->table_coerced);
+ && nm_platform_route_table_is_main (r->table_coerced)
+ && r->type_coerced == nm_platform_route_type_coerce (1 /*RTN_UNICAST*/);
}
const NMPObject *_nm_ip_config_best_default_route_find_better (const NMPObject *obj_cur, const NMPObject *obj_cmp);
--
2.26.2