mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 03:20:11 +01:00
l3cfg: get routes to prune from the list of routes configured by NM
We always sync routes in the main table, but routes in tables other than main are only pruned if were added by NM, by default. Get the list of routes to prune from other tables using obj_state->os_nm_configured, as this tracks what routes were effectively added by NM. The list should be the same that the one obtained from l3cfg_old. It could be different if we commited the l3cfg with an NMIPRouteTableSyncMode of NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN, thus not deleting some routes at commit time. However, since the previous commit, we never do it. What all this shows is that starting to use different NMIPRouteTableSyncModes is probably a bad idea: it will be a source of bugs of routes not being always synced as users expect, and the use case for them is still to be known. (cherry picked from commitc06d130c38) (cherry picked from commitf59a26b1b1) (cherry picked from commit75e1d49edf)
This commit is contained in:
parent
3157504062
commit
a9b7a8d88e
1 changed files with 10 additions and 8 deletions
|
|
@ -5038,15 +5038,17 @@ _l3_commit_one(NML3Cfg *self,
|
|||
nm_g_array_len(ipv6_temp_addrs_keep));
|
||||
|
||||
if (route_table_sync == NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN_AND_NM_ROUTES) {
|
||||
NMDedupMultiIter iter;
|
||||
const NMPObject *rt_obj;
|
||||
GHashTableIter h_iter;
|
||||
ObjStateData *obj_state;
|
||||
|
||||
routes_old = g_ptr_array_new();
|
||||
nm_l3_config_data_iter_obj_for_each (&iter,
|
||||
l3cd_old,
|
||||
&rt_obj,
|
||||
NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4))
|
||||
g_ptr_array_add(routes_old, (gpointer) rt_obj);
|
||||
/* Get list of all the routes that were configured by us */
|
||||
routes_old = g_ptr_array_new_with_free_func((GDestroyNotify) nmp_object_unref);
|
||||
g_hash_table_iter_init(&h_iter, self->priv.p->obj_state_hash);
|
||||
while (g_hash_table_iter_next(&h_iter, (gpointer *) &obj_state, NULL)) {
|
||||
if (NMP_OBJECT_GET_TYPE(obj_state->obj) == NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)
|
||||
&& obj_state->os_nm_configured)
|
||||
g_ptr_array_add(routes_old, (gpointer) nmp_object_ref(obj_state->obj));
|
||||
}
|
||||
|
||||
nm_platform_route_objs_sort(routes_old, NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue