summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-02-03 23:53:30 +0100
committerThomas Haller <thaller@redhat.com>2022-02-09 19:13:05 +0100
commit6255e0dcac06111a121541f982d11eefbae20cb1 (patch)
tree5299e2c7b69dd1ff63cb28a0d4b38ba50f0282da
parente32bc6d248fa09d1652465577af4fd03eb39e0f1 (diff)
downloadNetworkManager-6255e0dcac06111a121541f982d11eefbae20cb1.tar.gz
core: handle blackhole/unreachable/prohibit route types in core
Specifically, in nm_utils_ip_route_attribute_to_platform() and in _l3_config_data_add_obj() handle such new route type. For the moment, they cannot be stored in a valid NMSettingIPConfig, but later this will be necessary.
-rw-r--r--src/core/NetworkManagerUtils.c3
-rw-r--r--src/core/nm-l3-config-data.c16
2 files changed, 17 insertions, 2 deletions
diff --git a/src/core/NetworkManagerUtils.c b/src/core/NetworkManagerUtils.c
index 14f9b453c8..c50dbadad2 100644
--- a/src/core/NetworkManagerUtils.c
+++ b/src/core/NetworkManagerUtils.c
@@ -1347,7 +1347,8 @@ nm_utils_ip_route_attribute_to_platform(int addr_family,
int type;
type = nm_net_aux_rtnl_rtntype_a2n(g_variant_get_string(variant, NULL));
- nm_assert(NM_IN_SET(type, RTN_UNICAST, RTN_LOCAL));
+ nm_assert(
+ NM_IN_SET(type, RTN_UNICAST, RTN_LOCAL, RTN_BLACKHOLE, RTN_UNREACHABLE, RTN_PROHIBIT));
r->type_coerced = nm_platform_route_type_coerce(type);
} else
diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c
index 4b099884f8..03593ea28c 100644
--- a/src/core/nm-l3-config-data.c
+++ b/src/core/nm-l3-config-data.c
@@ -1094,8 +1094,22 @@ _l3_config_data_add_obj(NMDedupMultiIndex *multi_idx,
NMP_OBJECT_TYPE_IP4_ROUTE,
NMP_OBJECT_TYPE_IP6_ADDRESS,
NMP_OBJECT_TYPE_IP6_ROUTE));
+ nm_assert((!!obj_new) != (!!pl_new));
+
+ if (NM_IN_SET(idx_type->obj_type, NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE)) {
+ const NMPlatformIPRoute *r;
+
+ r = obj_new ? NMP_OBJECT_CAST_IP_ROUTE(obj_new) : (NMPlatformIPRoute *) pl_new;
+
+ if (nm_platform_route_type_is_nodev(nm_platform_route_type_uncoerce(r->type_coerced))) {
+ /* such routes don't have a device/next-hop. We track them without ifindex. */
+ ifindex = 0;
+ }
+ }
+
/* we go through extra lengths to accept a full obj_new object. That one,
- * can be reused by increasing the ref-count. */
+ * can be reused by increasing the ref-count. We thus accept any ifindex, and
+ * set it here. */
if (!obj_new) {
nm_assert(pl_new);
obj_new = nmp_object_stackinit(&obj_new_stackinit, idx_type->obj_type, pl_new);