From 8cb1cf176becfbcf17b6624a54ce9bcc19ecb9a5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 29 Nov 2023 12:01:08 +0100 Subject: [PATCH] core: assert that tracked objects in NML3Cfg don't have metric_any It wouldn't work otherwise. The object state is used to track routes and compare them to what we find in platform. A "metric_any" is useful at higher layers, to track a route where the metric is decided by somebody else. But at the point when we add such an object to the object-state, a fixed metric must be chosen. Assert for that. (cherry picked from commit 8d205faa4650f3115f66699b9d2c07df865186ec) --- src/core/nm-l3cfg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 96d1a65804..402639615c 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -797,6 +797,14 @@ _nm_n_acd_data_probe_new(NML3Cfg *self, in_addr_t addr, guint32 timeout_msec, gp nm_assert(_self->priv.p->combined_l3cd_commited); \ \ if (NM_MORE_ASSERTS > 5) { \ + /* metric-any must be resolved before adding the object. Otherwise, + * their real metric is not known, and they cannot be compared to objects + * from NMPlatform cache. */ \ + nm_assert(!NM_IN_SET(NMP_OBJECT_GET_TYPE(_obj_state->obj), \ + NMP_OBJECT_TYPE_IP4_ROUTE, \ + NMP_OBJECT_TYPE_IP6_ROUTE) \ + || !NMP_OBJECT_CAST_IP_ROUTE(_obj_state->obj)->metric_any); \ + \ nm_assert(c_list_contains(&_self->priv.p->obj_state_lst_head, \ &_obj_state->os_lst)); \ nm_assert(_obj_state->os_plobj \