mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 15:40:10 +01:00
libnm: merge branch 'th/libnm-fix-compare-dns'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1442
This commit is contained in:
commit
a13fa05754
7 changed files with 129 additions and 27 deletions
|
|
@ -5743,6 +5743,20 @@ _nm_setting_ip_config_compare_fcn_routes(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
NMTernary
|
||||
_nm_setting_ip_config_compare_fcn_dns(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil)
|
||||
{
|
||||
if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE))
|
||||
return NM_TERNARY_DEFAULT;
|
||||
|
||||
if (!set_b)
|
||||
return TRUE;
|
||||
|
||||
return (nm_strv_ptrarray_cmp(NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a)->dns,
|
||||
NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b)->dns)
|
||||
== 0);
|
||||
}
|
||||
|
||||
static NMTernary
|
||||
compare_fcn_routing_rules(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil)
|
||||
{
|
||||
|
|
@ -5972,8 +5986,8 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family)
|
|||
"dns-data",
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("as"),
|
||||
.to_dbus_fcn = dns_data_to_dbus,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_ignore,
|
||||
.from_dbus_fcn = dns_data_from_dbus, ));
|
||||
.from_dbus_fcn = dns_data_from_dbus,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_ignore, ));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
|
|
|
|||
|
|
@ -972,7 +972,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
properties_override,
|
||||
g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_DNS),
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("au"),
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_default,
|
||||
.compare_fcn = _nm_setting_ip_config_compare_fcn_dns,
|
||||
.to_dbus_fcn = ip4_dns_to_dbus,
|
||||
.from_dbus_fcn = ip4_dns_from_dbus, ),
|
||||
.to_dbus_only_in_manager_process = TRUE,
|
||||
|
|
|
|||
|
|
@ -981,7 +981,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
properties_override,
|
||||
g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_DNS),
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aay"),
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_default,
|
||||
.compare_fcn = _nm_setting_ip_config_compare_fcn_dns,
|
||||
.to_dbus_fcn = ip6_dns_to_dbus,
|
||||
.from_dbus_fcn = ip6_dns_from_dbus, ),
|
||||
.to_dbus_only_in_manager_process = TRUE,
|
||||
|
|
|
|||
|
|
@ -1069,6 +1069,8 @@ NMTernary _nm_setting_ip_config_compare_fcn_addresses(_NM_SETT_INFO_PROP_COMPARE
|
|||
|
||||
NMTernary _nm_setting_ip_config_compare_fcn_routes(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
||||
|
||||
NMTernary _nm_setting_ip_config_compare_fcn_dns(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
||||
|
||||
gboolean _nm_sett_info_prop_missing_from_dbus_fcn_cloned_mac_address(
|
||||
_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil);
|
||||
|
||||
|
|
|
|||
|
|
@ -1783,30 +1783,36 @@ property_to_dbus(const NMSettInfoSetting *sett_info,
|
|||
|| NM_FLAGS_HAS(property_info->param_spec->flags, G_PARAM_WRITABLE)
|
||||
|| property_info->property_type == &nm_sett_info_propert_type_setting_name);
|
||||
|
||||
if (property_info->to_dbus_only_in_manager_process && !_nm_utils_is_manager_process)
|
||||
return NULL;
|
||||
if (ignore_flags) {
|
||||
/* We are called from _nm_setting_property_compare_fcn_default(). We want
|
||||
* to serialize the property, and ignore the flags. */
|
||||
} else {
|
||||
if (property_info->to_dbus_only_in_manager_process && !_nm_utils_is_manager_process)
|
||||
return NULL;
|
||||
|
||||
if (property_info->param_spec && !ignore_flags
|
||||
&& !NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS)) {
|
||||
if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) {
|
||||
NMSettingSecretFlags f = NM_SETTING_SECRET_FLAG_NONE;
|
||||
if (property_info->param_spec
|
||||
&& !NM_FLAGS_HAS(property_info->param_spec->flags,
|
||||
NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS)) {
|
||||
if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) {
|
||||
NMSettingSecretFlags f = NM_SETTING_SECRET_FLAG_NONE;
|
||||
|
||||
if (NM_FLAGS_ANY(flags,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED
|
||||
| NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED
|
||||
| NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_SAVED)) {
|
||||
if (!nm_setting_get_secret_flags(setting,
|
||||
property_info->param_spec->name,
|
||||
&f,
|
||||
NULL))
|
||||
if (NM_FLAGS_ANY(flags,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED
|
||||
| NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED
|
||||
| NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_SAVED)) {
|
||||
if (!nm_setting_get_secret_flags(setting,
|
||||
property_info->param_spec->name,
|
||||
&f,
|
||||
NULL))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_nm_connection_serialize_secrets(flags, f))
|
||||
return NULL;
|
||||
} else {
|
||||
if (!_nm_connection_serialize_non_secret(flags))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_nm_connection_serialize_secrets(flags, f))
|
||||
return NULL;
|
||||
} else {
|
||||
if (!_nm_connection_serialize_non_secret(flags))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3897,7 +3897,7 @@ ensure_diffs(GHashTable *diffs, const DiffSetting *check, gsize n_check)
|
|||
{
|
||||
guint i;
|
||||
|
||||
g_assert(g_hash_table_size(diffs) == n_check);
|
||||
g_assert_cmpint(g_hash_table_size(diffs), ==, n_check);
|
||||
|
||||
/* Loop through the settings */
|
||||
for (i = 0; i < n_check; i++) {
|
||||
|
|
@ -3910,14 +3910,14 @@ ensure_diffs(GHashTable *diffs, const DiffSetting *check, gsize n_check)
|
|||
/* Get the number of keys to check */
|
||||
while (check[i].keys[z].key_name)
|
||||
z++;
|
||||
g_assert(g_hash_table_size(setting_hash) == z);
|
||||
g_assert_cmpint(g_hash_table_size(setting_hash), ==, z);
|
||||
|
||||
/* Now compare the actual keys */
|
||||
for (z = 0; check[i].keys[z].key_name; z++) {
|
||||
NMSettingDiffResult result;
|
||||
|
||||
result = GPOINTER_TO_UINT(g_hash_table_lookup(setting_hash, check[i].keys[z].key_name));
|
||||
g_assert(result == check[i].keys[z].result);
|
||||
g_assert_cmpint(result, ==, check[i].keys[z].result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5068,6 +5068,84 @@ test_6lowpan_1(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_settings_dns(void)
|
||||
{
|
||||
int i_run;
|
||||
|
||||
for (i_run = 0; i_run < 10; i_run++) {
|
||||
gs_unref_object NMConnection *con1 = NULL;
|
||||
gs_unref_object NMConnection *con2 = NULL;
|
||||
int IS_IPv4;
|
||||
guint n_dns;
|
||||
guint i;
|
||||
gboolean same = TRUE;
|
||||
|
||||
con1 =
|
||||
nmtst_create_minimal_connection("test-dns", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL);
|
||||
nmtst_connection_normalize(con1);
|
||||
|
||||
con2 = nmtst_connection_duplicate_and_normalize(con1);
|
||||
|
||||
nmtst_assert_connection_equals(con1, nmtst_get_rand_bool(), con2, nmtst_get_rand_bool());
|
||||
|
||||
for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) {
|
||||
const char *nameservers[2][7] = {
|
||||
[0] =
|
||||
{
|
||||
"11:22::b:0",
|
||||
"11:22::b:1#hello1",
|
||||
"11:22::b:2",
|
||||
"11:22::b:3#hello2",
|
||||
"11:22::b:4",
|
||||
"11:22::b:5",
|
||||
"bogus6",
|
||||
},
|
||||
[1] =
|
||||
{
|
||||
"1.1.1.0",
|
||||
"1.1.1.1#foo1",
|
||||
"1.1.1.2",
|
||||
"1.1.1.3#foo2",
|
||||
"1.1.1.4",
|
||||
"1.1.1.5",
|
||||
"bogus4",
|
||||
},
|
||||
};
|
||||
GType gtype = IS_IPv4 ? NM_TYPE_SETTING_IP4_CONFIG : NM_TYPE_SETTING_IP6_CONFIG;
|
||||
NMSettingIPConfig *s_ip1 = _nm_connection_get_setting(con1, gtype);
|
||||
NMSettingIPConfig *s_ip2 = _nm_connection_get_setting(con2, gtype);
|
||||
|
||||
n_dns = nmtst_get_rand_uint32() % G_N_ELEMENTS(nameservers[0]);
|
||||
for (i = 0; i < n_dns; i++) {
|
||||
const char *d =
|
||||
nameservers[IS_IPv4][nmtst_get_rand_uint32() % G_N_ELEMENTS(nameservers[0])];
|
||||
|
||||
if (!nmtst_get_rand_one_case_in(4))
|
||||
nm_setting_ip_config_add_dns(s_ip1, d);
|
||||
if (!nmtst_get_rand_one_case_in(4))
|
||||
nm_setting_ip_config_add_dns(s_ip2, d);
|
||||
}
|
||||
|
||||
if (nm_strv_ptrarray_cmp(_nm_setting_ip_config_get_dns_array(s_ip1),
|
||||
_nm_setting_ip_config_get_dns_array(s_ip2))
|
||||
!= 0)
|
||||
same = FALSE;
|
||||
}
|
||||
|
||||
_nm_utils_is_manager_process = nmtst_get_rand_bool();
|
||||
if (same) {
|
||||
nmtst_assert_connection_equals(con1, FALSE, con2, FALSE);
|
||||
g_assert(nm_connection_compare(con1, con2, NM_SETTING_COMPARE_FLAG_EXACT));
|
||||
} else {
|
||||
g_assert(!nm_connection_compare(con1, con2, NM_SETTING_COMPARE_FLAG_EXACT));
|
||||
}
|
||||
_nm_utils_is_manager_process = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_bond_meta(void)
|
||||
{
|
||||
|
|
@ -5170,6 +5248,8 @@ main(int argc, char **argv)
|
|||
|
||||
g_test_add_func("/libnm/settings/6lowpan/1", test_6lowpan_1);
|
||||
|
||||
g_test_add_func("/libnm/settings/dns", test_settings_dns);
|
||||
|
||||
g_test_add_func("/libnm/settings/sriov/vf", test_sriov_vf);
|
||||
g_test_add_func("/libnm/settings/sriov/vf-dup", test_sriov_vf_dup);
|
||||
g_test_add_func("/libnm/settings/sriov/vf-vlan", test_sriov_vf_vlan);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue