mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 04:20:23 +01:00
l3cfg: fix setting default route table during nm_l3_config_data_merge()
We made the choice, that NMPlatformIPRoute does not contain the actual route table, instead it contains a "remapped" number: table_coerced. That remapping done, so that the default (which we want semantically to be 254, RT_TABLE_MAIN) is numerical zero so that struct initialization doesn't you require to explicitly set the default. Hence, we must always distinguish whether we have the real table number or the "table_coerced", and you must convert back and forth between the two. Now, the parameter of nm_l3_config_data_merge() are real table numbers (as also indicated by their name not having the term "coerced"). So usually they are set to actually 254. When we set the field of NMPlatformIPRoute, we must coerce it. This was wrong, and we would see wrong table numbers in the log: l3cfg[17b98e59a477b0f4,ifindex=2]: obj-state: track: [2a32eca99405767e, ip4-route, type unicast table 0 0.0.0.0/0 via ... Fixes:b4aa35e72d('l3cfg: extend nm_l3cfg_add_config() to accept default route table and metric') (cherry picked from commite23ebe9183)
This commit is contained in:
parent
ad26457d0f
commit
9e7f7a48be
1 changed files with 12 additions and 6 deletions
|
|
@ -2995,12 +2995,12 @@ nm_l3_config_data_merge(NML3ConfigData *self,
|
|||
NML3ConfigMergeHookAddObj hook_add_obj,
|
||||
gpointer hook_user_data)
|
||||
{
|
||||
static const guint32 x_default_route_table_x[2] = {RT_TABLE_MAIN, RT_TABLE_MAIN};
|
||||
static const guint32 x_default_route_metric_x[2] = {NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6,
|
||||
NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4};
|
||||
static const guint32 x_default_route_penalty_x[2] = {0, 0};
|
||||
static const int x_default_dns_priority_x[2] = {NM_DNS_PRIORITY_DEFAULT_NORMAL,
|
||||
NM_DNS_PRIORITY_DEFAULT_NORMAL};
|
||||
guint32 default_route_table_coerced_x[2];
|
||||
NMDedupMultiIter iter;
|
||||
const NMPObject *obj;
|
||||
int IS_IPv4;
|
||||
|
|
@ -3008,8 +3008,16 @@ nm_l3_config_data_merge(NML3ConfigData *self,
|
|||
nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE));
|
||||
nm_assert(_NM_IS_L3_CONFIG_DATA(src, TRUE));
|
||||
|
||||
if (!default_route_table_x)
|
||||
default_route_table_x = x_default_route_table_x;
|
||||
if (default_route_table_x) {
|
||||
default_route_table_coerced_x[0] = nm_platform_route_table_coerce(default_route_table_x[0]);
|
||||
default_route_table_coerced_x[1] = nm_platform_route_table_coerce(default_route_table_x[1]);
|
||||
} else {
|
||||
default_route_table_coerced_x[0] = nm_platform_route_table_coerce(RT_TABLE_MAIN);
|
||||
default_route_table_coerced_x[1] = nm_platform_route_table_coerce(RT_TABLE_MAIN);
|
||||
}
|
||||
nm_assert(nm_platform_route_table_uncoerce(default_route_table_coerced_x[0], FALSE) != 0);
|
||||
nm_assert(nm_platform_route_table_uncoerce(default_route_table_coerced_x[1], FALSE) != 0);
|
||||
|
||||
if (!default_route_metric_x)
|
||||
default_route_metric_x = x_default_route_metric_x;
|
||||
if (!default_route_penalty_x)
|
||||
|
|
@ -3017,8 +3025,6 @@ nm_l3_config_data_merge(NML3ConfigData *self,
|
|||
if (!default_dns_priority_x)
|
||||
default_dns_priority_x = x_default_dns_priority_x;
|
||||
|
||||
nm_assert(default_route_table_x[0] != 0);
|
||||
nm_assert(default_route_table_x[1] != 0);
|
||||
nm_assert(default_route_metric_x[0] != 0); /* IPv6 route metric cannot be zero. */
|
||||
|
||||
nm_assert(!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_CLONE)
|
||||
|
|
@ -3145,7 +3151,7 @@ nm_l3_config_data_merge(NML3ConfigData *self,
|
|||
if (r_src->table_any) {
|
||||
_ensure_r();
|
||||
r.rx.table_any = FALSE;
|
||||
r.rx.table_coerced = default_route_table_x[IS_IPv4];
|
||||
r.rx.table_coerced = default_route_table_coerced_x[IS_IPv4];
|
||||
}
|
||||
|
||||
if (r_src->metric_any) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue