diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index 8c3c4f1b4c..d41d95ecab 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -2712,6 +2712,7 @@ nm_l3_config_data_merge(NML3ConfigData * self, const guint32 * default_route_table_x /* length 2, for IS_IPv4 */, const guint32 * default_route_metric_x /* length 2, for IS_IPv4 */, const guint32 * default_route_penalty_x /* length 2, for IS_IPv4 */, + const int * default_dns_priority_x /* length 2, for IS_IPv4 */, NML3ConfigMergeHookAddObj hook_add_obj, gpointer hook_user_data) { @@ -2719,6 +2720,8 @@ nm_l3_config_data_merge(NML3ConfigData * self, 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}; NMDedupMultiIter iter; const NMPObject * obj; int IS_IPv4; @@ -2732,6 +2735,8 @@ nm_l3_config_data_merge(NML3ConfigData * self, default_route_metric_x = x_default_route_metric_x; if (!default_route_penalty_x) default_route_penalty_x = x_default_route_penalty_x; + 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); @@ -2893,7 +2898,12 @@ nm_l3_config_data_merge(NML3ConfigData * self, if (!NM_FLAGS_ANY(self->flags, has_dns_priority_flag) && NM_FLAGS_ANY(src->flags, has_dns_priority_flag)) { - self->dns_priority_x[IS_IPv4] = src->dns_priority_x[IS_IPv4]; + int p = src->dns_priority_x[IS_IPv4]; + + if (p == 0 && !NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_CLONE)) + p = default_dns_priority_x[IS_IPv4]; + + self->dns_priority_x[IS_IPv4] = p; self->flags |= has_dns_priority_flag; } @@ -2986,6 +2996,7 @@ nm_l3_config_data_new_clone(const NML3ConfigData *src, int ifindex) NULL, NULL, NULL, + NULL, NULL); nm_assert(nm_l3_config_data_cmp_full(src, self, NM_L3_CONFIG_CMP_FLAGS_IGNORE_IFINDEX) == 0); diff --git a/src/core/nm-l3-config-data.h b/src/core/nm-l3-config-data.h index b2f36b3ed1..d8999986a2 100644 --- a/src/core/nm-l3-config-data.h +++ b/src/core/nm-l3-config-data.h @@ -151,6 +151,7 @@ void nm_l3_config_data_merge(NML3ConfigData * self, const guint32 *default_route_table_x /* length 2, for IS_IPv4 */, const guint32 *default_route_metric_x /* length 2, for IS_IPv4 */, const guint32 *default_route_penalty_x /* length 2, for IS_IPv4 */, + const int * default_dns_priority_x /* length 2, for IS_IPv4 */, NML3ConfigMergeHookAddObj hook_add_obj, gpointer hook_user_data); diff --git a/src/core/nm-l3-ipv4ll.c b/src/core/nm-l3-ipv4ll.c index 521ff5ef24..d48b95ee4f 100644 --- a/src/core/nm-l3-ipv4ll.c +++ b/src/core/nm-l3-ipv4ll.c @@ -591,6 +591,8 @@ _l3cd_config_add(NML3IPv4LL *self) NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, 0, 0, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL, NM_L3_ACD_DEFEND_TYPE_ONCE, self->reg_timeout_msec, NM_L3CFG_CONFIG_FLAGS_ONLY_FOR_ACD, diff --git a/src/core/nm-l3-ipv6ll.c b/src/core/nm-l3-ipv6ll.c index 05149e66a6..e99f6f8902 100644 --- a/src/core/nm-l3-ipv6ll.c +++ b/src/core/nm-l3-ipv6ll.c @@ -414,6 +414,8 @@ _lladdr_handle_changed(NML3IPv6LL *self) NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, 0, 0, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL, NM_L3_ACD_DEFEND_TYPE_ALWAYS, 0, NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE, diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 1b9eadea32..a17511d6ed 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -189,6 +189,13 @@ typedef struct { }; guint32 default_route_penalty_x[2]; }; + union { + struct { + int default_dns_priority_6; + int default_dns_priority_4; + }; + int default_dns_priority_x[2]; + }; gconstpointer tag_confdata; guint64 pseudo_timestamp_confdata; int priority_confdata; @@ -3020,6 +3027,8 @@ nm_l3cfg_add_config(NML3Cfg * self, guint32 default_route_metric_6, guint32 default_route_penalty_4, guint32 default_route_penalty_6, + int default_dns_priority_4, + int default_dns_priority_6, NML3AcdDefendType acd_defend_type, guint32 acd_timeout_msec, NML3CfgConfigFlags config_flags, @@ -3095,6 +3104,8 @@ nm_l3cfg_add_config(NML3Cfg * self, .default_route_metric_6 = default_route_metric_6, .default_route_penalty_4 = default_route_penalty_4, .default_route_penalty_6 = default_route_penalty_6, + .default_dns_priority_4 = default_dns_priority_4, + .default_dns_priority_6 = default_dns_priority_6, .acd_defend_type_confdata = acd_defend_type, .acd_timeout_msec_confdata = acd_timeout_msec, .priority_confdata = priority, @@ -3143,6 +3154,14 @@ nm_l3cfg_add_config(NML3Cfg * self, l3_config_data->default_route_penalty_6 = default_route_penalty_6; changed = TRUE; } + if (l3_config_data->default_dns_priority_4 != default_dns_priority_4) { + l3_config_data->default_dns_priority_4 = default_dns_priority_4; + changed = TRUE; + } + if (l3_config_data->default_dns_priority_6 != default_dns_priority_6) { + l3_config_data->default_dns_priority_6 = default_dns_priority_6; + changed = TRUE; + } if (l3_config_data->acd_defend_type_confdata != acd_defend_type) { l3_config_data->acd_defend_type_confdata = acd_defend_type; changed = TRUE; @@ -3382,6 +3401,7 @@ _l3cfg_update_combined_config(NML3Cfg * self, l3cd_data->default_route_table_x, l3cd_data->default_route_metric_x, l3cd_data->default_route_penalty_x, + l3cd_data->default_dns_priority_x, _l3_hook_add_obj_cb, &hook_data); } diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h index 193ff72a7c..89fe4cae12 100644 --- a/src/core/nm-l3cfg.h +++ b/src/core/nm-l3cfg.h @@ -321,6 +321,8 @@ gboolean nm_l3cfg_add_config(NML3Cfg * self, guint32 default_route_metric_6, guint32 default_route_penalty_4, guint32 default_route_penalty_6, + int default_dns_priority_4, + int default_dns_priority_6, NML3AcdDefendType acd_defend_type, guint32 acd_timeout_msec, NML3CfgConfigFlags config_flags, diff --git a/src/core/tests/test-l3cfg.c b/src/core/tests/test-l3cfg.c index e4c6beb4b9..4a76c083fd 100644 --- a/src/core/tests/test-l3cfg.c +++ b/src/core/tests/test-l3cfg.c @@ -435,6 +435,8 @@ test_l3cfg(gconstpointer test_data) NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, 0, 0, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL, tdata->acd_defend_type_a, tdata->acd_timeout_msec_a, NM_L3CFG_CONFIG_FLAGS_NONE, @@ -597,6 +599,8 @@ _test_l3_ipv4ll_signal_notify(NML3Cfg * l3cfg, 105, 0, 0, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL, NM_L3_ACD_DEFEND_TYPE_ONCE, nmtst_get_rand_bool() ? tdata->acd_timeout_msec : 0u, NM_L3CFG_CONFIG_FLAGS_NONE,