core: set force-commit flag for generated routes

The force-commit flag is used to force the commit of an address or a
route from DHCP/RA even when it was removed from platform externally
(for example because it expired). Routes generated from the l3cd
should also have the flag set.

Without this, NM properly re-adds the DHCP address after the lease is
lost and obtained again, but fails to add the prefix-route.

Fixes: 2838b1c5e8 ('core: track force-commit flag for l3cd and platform objects')

https://bugzilla.redhat.com/show_bug.cgi?id=2033991
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1049
This commit is contained in:
Beniamino Galvani 2021-12-15 17:23:23 +01:00
parent 3e12c6ff81
commit ae28d2251a
5 changed files with 22 additions and 14 deletions

View file

@ -2428,6 +2428,7 @@ nm_l3_config_data_add_dependent_device_routes(NML3ConfigData *self,
int addr_family,
guint32 route_table,
guint32 route_metric,
gboolean force_commit,
const NML3ConfigData *source)
{
const int IS_IPv4 = NM_IS_IPv4(addr_family);
@ -2472,6 +2473,7 @@ nm_l3_config_data_add_dependent_device_routes(NML3ConfigData *self,
self->ifindex,
route_table,
route_metric,
force_commit,
&r_stack.r4);
if (r)
nm_l3_config_data_add_route(self, addr_family, NULL, r);
@ -2510,12 +2512,13 @@ nm_l3_config_data_add_dependent_device_routes(NML3ConfigData *self,
}
rx.r6 = (NMPlatformIP6Route){
.ifindex = self->ifindex,
.rt_source = NM_IP_CONFIG_SOURCE_KERNEL,
.table_coerced = nm_platform_route_table_coerce(route_table),
.metric = route_metric,
.network = *a6,
.plen = plen,
.ifindex = self->ifindex,
.rt_source = NM_IP_CONFIG_SOURCE_KERNEL,
.table_coerced = nm_platform_route_table_coerce(route_table),
.metric = route_metric,
.network = *a6,
.plen = plen,
.r_force_commit = force_commit,
};
nm_platform_ip_route_normalize(addr_family, &rx.rx);

View file

@ -165,6 +165,7 @@ void nm_l3_config_data_add_dependent_device_routes(NML3ConfigData *self,
int addr_family,
guint32 route_table,
guint32 route_metric,
gboolean force_commit,
const NML3ConfigData *source);
/*****************************************************************************/

View file

@ -3533,6 +3533,7 @@ _l3cfg_update_combined_config(NML3Cfg *self,
IS_IPv4 ? AF_INET : AF_INET6,
l3cd_data->default_route_table_x[IS_IPv4],
l3cd_data->default_route_metric_x[IS_IPv4],
l3cd_data->force_commit_once,
l3cd_data->l3cd);
}
}

View file

@ -8560,6 +8560,7 @@ nm_platform_ip4_address_generate_device_route(const NMPlatformIP4Address *addr,
int ifindex,
guint32 route_table,
guint32 route_metric,
gboolean force_commit,
NMPlatformIP4Route *dst)
{
in_addr_t network_4;
@ -8591,14 +8592,15 @@ nm_platform_ip4_address_generate_device_route(const NMPlatformIP4Address *addr,
}
*dst = (NMPlatformIP4Route){
.ifindex = ifindex,
.rt_source = NM_IP_CONFIG_SOURCE_KERNEL,
.network = network_4,
.plen = addr->plen,
.pref_src = addr->address,
.table_coerced = nm_platform_route_table_coerce(route_table),
.metric = route_metric,
.scope_inv = nm_platform_route_scope_inv(NM_RT_SCOPE_LINK),
.ifindex = ifindex,
.rt_source = NM_IP_CONFIG_SOURCE_KERNEL,
.network = network_4,
.plen = addr->plen,
.pref_src = addr->address,
.table_coerced = nm_platform_route_table_coerce(route_table),
.metric = route_metric,
.scope_inv = nm_platform_route_scope_inv(NM_RT_SCOPE_LINK),
.r_force_commit = force_commit,
};
nm_platform_ip_route_normalize(AF_INET, (NMPlatformIPRoute *) dst);

View file

@ -2421,6 +2421,7 @@ NMPlatformIP4Route *nm_platform_ip4_address_generate_device_route(const NMPlatfo
int ifindex,
guint32 route_table,
guint32 route_metric,
gboolean force_commit,
NMPlatformIP4Route *dst);
/*****************************************************************************/