config: avoid cloning string during nm_config_data_get_connection_default() et al.

NMConfigData is immutable and with the previous commit are the strings
already cached internally. There is no need to clone it.

Of course, the callers must not assume that the string stays alive after
a config reload (SIGHUP), where the NMConfigData might change. So they
are not always alive, but long enough for all callers to avoid cloning
the string.
This commit is contained in:
Thomas Haller 2021-06-16 09:50:46 +02:00
parent 2f9ab1d528
commit 9452d69465
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
6 changed files with 120 additions and 164 deletions

View file

@ -820,8 +820,7 @@ _prop_get_connection_stable_id(NMDevice * self,
* Especially with ${RANDOM} stable-id we want to generate *one* configuration
* for each activation. */
if (G_UNLIKELY(!priv->current_stable_id)) {
gs_free char * default_id = NULL;
gs_free char * generated = NULL;
gs_free char * generated = NULL;
NMUtilsStableType stable_type;
NMSettingConnection *s_con;
gboolean hwaddr_is_fake;
@ -834,11 +833,10 @@ _prop_get_connection_stable_id(NMDevice * self,
stable_id = nm_setting_connection_get_stable_id(s_con);
if (!stable_id) {
default_id =
stable_id =
nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("connection.stable-id"),
self);
stable_id = default_id;
}
uuid = nm_connection_get_uuid(connection);
@ -897,7 +895,6 @@ _prop_get_ipv6_dhcp_duid(NMDevice * self,
{
NMSettingIPConfig *s_ip6;
const char * duid;
gs_free char * duid_default = NULL;
const char * duid_error;
GBytes * duid_out;
gboolean duid_enforce = TRUE;
@ -910,10 +907,9 @@ _prop_get_ipv6_dhcp_duid(NMDevice * self,
duid = nm_setting_ip6_config_get_dhcp_duid(NM_SETTING_IP6_CONFIG(s_ip6));
if (!duid) {
duid_default = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("ipv6.dhcp-duid"),
self);
duid = duid_default;
duid = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("ipv6.dhcp-duid"),
self);
if (!duid)
duid = "lease";
}
@ -1390,7 +1386,6 @@ _prop_get_ipvx_dhcp_iaid(NMDevice * self,
const int IS_IPv4 = NM_IS_IPv4(addr_family);
NMSettingIPConfig *s_ip;
const char * iaid_str;
gs_free char * iaid_str_free = NULL;
guint32 iaid;
const char * iface;
const char * fail_reason;
@ -1399,11 +1394,10 @@ _prop_get_ipvx_dhcp_iaid(NMDevice * self,
s_ip = nm_connection_get_setting_ip_config(connection, addr_family);
iaid_str = nm_setting_ip_config_get_dhcp_iaid(s_ip);
if (!iaid_str) {
iaid_str_free = nm_config_data_get_connection_default(
NM_CONFIG_GET_DATA,
IS_IPv4 ? NM_CON_DEFAULT("ipv4.dhcp-iaid") : NM_CON_DEFAULT("ipv6.dhcp-iaid"),
self);
iaid_str = iaid_str_free;
iaid_str = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
IS_IPv4 ? NM_CON_DEFAULT("ipv4.dhcp-iaid")
: NM_CON_DEFAULT("ipv6.dhcp-iaid"),
self);
if (!iaid_str) {
iaid_str = NM_IAID_IFNAME;
is_explicit = FALSE;
@ -1560,12 +1554,10 @@ _prop_get_ipvx_dhcp_hostname_flags(NMDevice *self, int addr_family)
}
static const char *
_prop_get_connection_mud_url(NMDevice *self, NMSettingConnection *s_con, char **out_mud_url)
_prop_get_connection_mud_url(NMDevice *self, NMSettingConnection *s_con)
{
const char * mud_url;
gs_free char *s = NULL;
nm_assert(out_mud_url && !*out_mud_url);
const char *mud_url;
const char *s;
mud_url = nm_setting_connection_get_mud_url(s_con);
@ -1582,7 +1574,7 @@ _prop_get_connection_mud_url(NMDevice *self, NMSettingConnection *s_con, char **
if (nm_streq(s, NM_CONNECTION_MUD_URL_NONE))
return NULL;
if (nm_sd_http_url_is_valid_https(s))
return (*out_mud_url = g_steal_pointer(&s));
return s;
}
return NULL;
@ -1593,7 +1585,6 @@ _prop_get_ipv4_dhcp_client_id(NMDevice *self, NMConnection *connection, GBytes *
{
NMSettingIPConfig *s_ip4;
const char * client_id;
gs_free char * client_id_default = NULL;
guint8 * client_id_buf;
const char * fail_reason;
guint8 hwaddr_bin_buf[_NM_UTILS_HWADDR_LEN_MAX];
@ -1607,13 +1598,12 @@ _prop_get_ipv4_dhcp_client_id(NMDevice *self, NMConnection *connection, GBytes *
client_id = nm_setting_ip4_config_get_dhcp_client_id(NM_SETTING_IP4_CONFIG(s_ip4));
if (!client_id) {
client_id_default =
nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("ipv4.dhcp-client-id"),
self);
if (client_id_default && client_id_default[0]) {
client_id = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("ipv4.dhcp-client-id"),
self);
if (client_id && !client_id[0]) {
/* a non-empty client-id is always valid, see nm_dhcp_utils_client_id_string_to_bytes(). */
client_id = client_id_default;
client_id = NULL;
}
}
@ -1745,8 +1735,7 @@ out_good:
static GBytes *
_prop_get_ipv4_dhcp_vendor_class_identifier(NMDevice *self, NMSettingIP4Config *s_ip4)
{
gs_free char *config_data_prop = NULL;
gs_free char *to_free = NULL;
gs_free char *to_free = NULL;
const char * conn_prop;
GBytes * bytes = NULL;
const char * bin;
@ -1756,13 +1745,13 @@ _prop_get_ipv4_dhcp_vendor_class_identifier(NMDevice *self, NMSettingIP4Config *
if (!conn_prop) {
/* set in NetworkManager.conf ? */
config_data_prop = nm_config_data_get_connection_default(
conn_prop = nm_config_data_get_connection_default(
NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("ipv4.dhcp-vendor-class-identifier"),
self);
if (config_data_prop && nm_utils_validate_dhcp4_vendor_class_id(config_data_prop, NULL))
conn_prop = config_data_prop;
if (conn_prop && !nm_utils_validate_dhcp4_vendor_class_id(conn_prop, NULL))
conn_prop = NULL;
}
if (conn_prop) {
@ -1828,16 +1817,11 @@ _prop_get_ipv6_ip6_privacy(NMDevice *self)
}
static const char *
_prop_get_x_cloned_mac_address(NMDevice * self,
NMConnection *connection,
gboolean is_wifi,
char ** out_addr)
_prop_get_x_cloned_mac_address(NMDevice *self, NMConnection *connection, gboolean is_wifi)
{
NMSetting * setting;
const char *addr = NULL;
nm_assert(out_addr && !*out_addr);
setting = nm_connection_get_setting(connection,
is_wifi ? NM_TYPE_SETTING_WIRELESS : NM_TYPE_SETTING_WIRED);
if (setting) {
@ -1846,7 +1830,7 @@ _prop_get_x_cloned_mac_address(NMDevice * self,
}
if (!addr) {
gs_free char *a = NULL;
const char *a;
a = nm_config_data_get_connection_default(
NM_CONFIG_GET_DATA,
@ -1861,36 +1845,28 @@ _prop_get_x_cloned_mac_address(NMDevice * self,
NMSettingMacRandomization v;
/* for backward compatibility, read the deprecated wifi.mac-address-randomization setting. */
a = nm_config_data_get_connection_default(
v = nm_config_data_get_connection_default_int64(
NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("wifi.mac-address-randomization"),
self);
v = _nm_utils_ascii_str_to_int64(a,
10,
NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
NM_SETTING_MAC_RANDOMIZATION_ALWAYS,
NM_SETTING_MAC_RANDOMIZATION_DEFAULT);
self,
NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
NM_SETTING_MAC_RANDOMIZATION_ALWAYS,
NM_SETTING_MAC_RANDOMIZATION_DEFAULT);
if (v == NM_SETTING_MAC_RANDOMIZATION_ALWAYS)
addr = NM_CLONED_MAC_RANDOM;
}
} else if (NM_CLONED_MAC_IS_SPECIAL(a) || nm_utils_hwaddr_valid(a, ETH_ALEN))
addr = *out_addr = g_steal_pointer(&a);
addr = a;
}
return addr;
}
static const char *
_prop_get_x_generate_mac_address_mask(NMDevice * self,
NMConnection *connection,
gboolean is_wifi,
char ** out_value)
_prop_get_x_generate_mac_address_mask(NMDevice *self, NMConnection *connection, gboolean is_wifi)
{
NMSetting * setting;
const char *value = NULL;
char * a;
nm_assert(out_value && !*out_value);
const char *value;
setting = nm_connection_get_setting(connection,
is_wifi ? NM_TYPE_SETTING_WIRELESS : NM_TYPE_SETTING_WIRED);
@ -1903,15 +1879,11 @@ _prop_get_x_generate_mac_address_mask(NMDevice * self,
return value;
}
a = nm_config_data_get_connection_default(
return nm_config_data_get_connection_default(
NM_CONFIG_GET_DATA,
is_wifi ? NM_CON_DEFAULT("wifi.generate-mac-address-mask")
: NM_CON_DEFAULT("ethernet.generate-mac-address-mask"),
self);
if (!a)
return NULL;
*out_value = a;
return a;
}
/*****************************************************************************/
@ -9417,7 +9389,6 @@ dhcp4_start(NMDevice *self)
gs_unref_bytes GBytes *hwaddr = NULL;
gs_unref_bytes GBytes *bcast_hwaddr = NULL;
gs_unref_bytes GBytes *client_id = NULL;
gs_free char * mud_url_free = NULL;
NMConnection * connection;
NMSettingConnection * s_con;
GError * error = NULL;
@ -9477,7 +9448,7 @@ dhcp4_start(NMDevice *self)
nm_setting_ip_config_get_dhcp_hostname(s_ip4),
nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip4)),
_prop_get_ipvx_dhcp_hostname_flags(self, AF_INET),
_prop_get_connection_mud_url(self, s_con, &mud_url_free),
_prop_get_connection_mud_url(self, s_con),
client_id,
_prop_get_ipvx_dhcp_timeout(self, AF_INET),
_device_get_dhcp_anycast_address(self),
@ -9881,8 +9852,7 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
gs_unref_bytes GBytes * duid = NULL;
gboolean enforce_duid = FALSE;
const NMPlatformLink * pllink;
gs_free char * mud_url_free = NULL;
GError * error = NULL;
GError * error = NULL;
guint32 iaid;
gboolean iaid_explicit;
NMSettingConnection * s_con;
@ -9927,7 +9897,7 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
nm_setting_ip_config_get_dhcp_send_hostname(s_ip6),
nm_setting_ip_config_get_dhcp_hostname(s_ip6),
_prop_get_ipvx_dhcp_hostname_flags(self, AF_INET6),
_prop_get_connection_mud_url(self, s_con, &mud_url_free),
_prop_get_connection_mud_url(self, s_con),
duid,
enforce_duid,
iaid,
@ -17277,14 +17247,13 @@ _hw_addr_get_cloned(NMDevice * self,
gboolean * preserve,
char ** hwaddr,
HwAddrType * hwaddr_type,
char ** hwaddr_detail,
const char ** hwaddr_detail,
GError ** error)
{
NMDevicePrivate *priv;
gs_free char * addr_setting_free = NULL;
gs_free char * hw_addr_generated = NULL;
gs_free char * generate_mac_address_mask_tmp = NULL;
const char * addr, *addr_setting;
gs_free char * hw_addr_generated = NULL;
const char * addr;
const char * addr_setting;
char * addr_out;
HwAddrType type_out;
@ -17297,15 +17266,16 @@ _hw_addr_get_cloned(NMDevice * self,
if (!connection)
g_return_val_if_reached(FALSE);
addr = addr_setting =
_prop_get_x_cloned_mac_address(self, connection, is_wifi, &addr_setting_free);
addr_setting = _prop_get_x_cloned_mac_address(self, connection, is_wifi);
addr = addr_setting;
if (nm_streq(addr, NM_CLONED_MAC_PRESERVE)) {
/* "preserve" means to reset the initial MAC address. */
NM_SET_OUT(preserve, TRUE);
NM_SET_OUT(hwaddr, NULL);
NM_SET_OUT(hwaddr_type, HW_ADDR_TYPE_UNSET);
NM_SET_OUT(hwaddr_detail, g_steal_pointer(&addr_setting_free) ?: g_strdup(addr_setting));
NM_SET_OUT(hwaddr_detail, addr_setting);
return TRUE;
}
@ -17318,8 +17288,7 @@ _hw_addr_get_cloned(NMDevice * self,
NM_SET_OUT(preserve, TRUE);
NM_SET_OUT(hwaddr, NULL);
NM_SET_OUT(hwaddr_type, HW_ADDR_TYPE_UNSET);
NM_SET_OUT(hwaddr_detail,
g_steal_pointer(&addr_setting_free) ?: g_strdup(addr_setting));
NM_SET_OUT(hwaddr_detail, addr_setting);
return TRUE;
} else if (!addr) {
g_set_error_literal(error,
@ -17339,10 +17308,7 @@ _hw_addr_get_cloned(NMDevice * self,
}
hw_addr_generated = nm_utils_hw_addr_gen_random_eth(
nm_device_get_initial_hw_address(self),
_prop_get_x_generate_mac_address_mask(self,
connection,
is_wifi,
&generate_mac_address_mask_tmp));
_prop_get_x_generate_mac_address_mask(self, connection, is_wifi));
if (!hw_addr_generated) {
g_set_error(error,
NM_DEVICE_ERROR,
@ -17370,10 +17336,7 @@ _hw_addr_get_cloned(NMDevice * self,
stable_id,
nm_device_get_ip_iface(self),
nm_device_get_initial_hw_address(self),
_prop_get_x_generate_mac_address_mask(self,
connection,
is_wifi,
&generate_mac_address_mask_tmp));
_prop_get_x_generate_mac_address_mask(self, connection, is_wifi));
if (!hw_addr_generated) {
g_set_error(error,
NM_DEVICE_ERROR,
@ -17397,7 +17360,7 @@ _hw_addr_get_cloned(NMDevice * self,
NM_SET_OUT(preserve, FALSE);
NM_SET_OUT(hwaddr, addr_out);
NM_SET_OUT(hwaddr_type, type_out);
NM_SET_OUT(hwaddr_detail, g_steal_pointer(&addr_setting_free) ?: g_strdup(addr_setting));
NM_SET_OUT(hwaddr_detail, addr_setting);
return TRUE;
out_no_action:
NM_SET_OUT(preserve, FALSE);
@ -17427,7 +17390,7 @@ nm_device_hw_addr_set_cloned(NMDevice *self, NMConnection *connection, gboolean
NMDevicePrivate *priv;
gboolean preserve = FALSE;
gs_free char * hwaddr = NULL;
gs_free char * detail = NULL;
const char * detail = NULL;
HwAddrType type = HW_ADDR_TYPE_UNSET;
gs_free_error GError *error = NULL;

View file

@ -1382,8 +1382,8 @@ _hw_addr_set_scanning(NMDeviceWifi *self, gboolean do_reset)
now = nm_utils_get_monotonic_timestamp_sec();
if (now >= priv->hw_addr_scan_expire) {
gs_free char *generate_mac_address_mask = NULL;
gs_free char *hw_addr_scan = NULL;
gs_free char *hw_addr_scan = NULL;
const char * generate_mac_address_mask;
/* the random MAC address for scanning expires after a while.
*

View file

@ -74,7 +74,8 @@ create_device(NMDeviceFactory * factory,
NMConnection * connection,
gboolean * out_ignore)
{
gs_free char *backend = NULL;
gs_free char *backend_free = NULL;
const char * backend;
g_return_val_if_fail(iface != NULL, NULL);
g_return_val_if_fail(plink != NULL, NULL);
@ -89,7 +90,7 @@ create_device(NMDeviceFactory * factory,
plink,
"wifi",
NULL);
nm_strstrip(backend);
backend = nm_strstrip_avoid_copy_a(300, backend, &backend_free);
nm_log_dbg(LOGD_PLATFORM | LOGD_WIFI,
"(%s) config: backend is %s%s%s%s",

View file

@ -359,9 +359,9 @@ nm_config_data_get_iwd_config_path(const NMConfigData *self)
gboolean
nm_config_data_get_ignore_carrier(const NMConfigData *self, NMDevice *device)
{
gs_free char *value = NULL;
gboolean has_match;
int m;
const char *value;
gboolean has_match;
int m;
g_return_val_if_fail(NM_IS_CONFIG_DATA(self), FALSE);
g_return_val_if_fail(NM_IS_DEVICE(device), FALSE);
@ -1397,7 +1397,7 @@ _match_section_infos_lookup(const MatchSectionInfo *match_section_infos,
NMDevice * device,
const NMPlatformLink * pllink,
const char * match_device_type,
char ** out_value)
const char ** out_value)
{
const char *match_dhcp_plugin;
@ -1436,7 +1436,7 @@ _match_section_infos_lookup(const MatchSectionInfo *match_section_infos,
match = TRUE;
if (match) {
*out_value = g_strdup(value);
*out_value = value;
return match_section_infos;
}
}
@ -1446,7 +1446,7 @@ out:
return NULL;
}
char *
const char *
nm_config_data_get_device_config(const NMConfigData *self,
const char * property,
NMDevice * device,
@ -1454,7 +1454,7 @@ nm_config_data_get_device_config(const NMConfigData *self,
{
const NMConfigDataPrivate *priv;
const MatchSectionInfo * connection_info;
char * value = NULL;
const char * value;
NM_SET_OUT(has_match, FALSE);
@ -1474,7 +1474,7 @@ nm_config_data_get_device_config(const NMConfigData *self,
return value;
}
char *
const char *
nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
const char * property,
const NMPlatformLink *pllink,
@ -1483,7 +1483,7 @@ nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
{
const NMConfigDataPrivate *priv;
const MatchSectionInfo * connection_info;
char * value = NULL;
const char * value;
g_return_val_if_fail(self, NULL);
g_return_val_if_fail(property && *property, NULL);
@ -1508,8 +1508,8 @@ nm_config_data_get_device_config_boolean(const NMConfigData *self,
int val_no_match,
int val_invalid)
{
gs_free char *value = NULL;
gboolean has_match;
const char *value;
gboolean has_match;
value = nm_config_data_get_device_config(self, property, device, &has_match);
if (!has_match)
@ -1527,8 +1527,8 @@ nm_config_data_get_device_config_int64(const NMConfigData *self,
gint64 val_no_match,
gint64 val_invalid)
{
gs_free char *value = NULL;
gboolean has_match;
const char *value;
gboolean has_match;
value = nm_config_data_get_device_config(self, property, device, &has_match);
if (!has_match) {
@ -1538,13 +1538,13 @@ nm_config_data_get_device_config_int64(const NMConfigData *self,
return _nm_utils_ascii_str_to_int64(value, base, min, max, val_invalid);
}
char *
const char *
nm_config_data_get_connection_default(const NMConfigData *self,
const char * property,
NMDevice * device)
{
const NMConfigDataPrivate *priv;
char * value = NULL;
const char * value;
g_return_val_if_fail(self, NULL);
g_return_val_if_fail(property && *property, NULL);
@ -1583,7 +1583,7 @@ nm_config_data_get_connection_default_int64(const NMConfigData *self,
gint64 max,
gint64 fallback)
{
gs_free char *value = NULL;
const char *value;
value = nm_config_data_get_connection_default(self, property, device);
return _nm_utils_ascii_str_to_int64(value, 10, min, max, fallback);

View file

@ -207,9 +207,9 @@ extern const char *__stop_connection_defaults[];
name; \
})
char *nm_config_data_get_connection_default(const NMConfigData *self,
const char * property,
NMDevice * device);
const char *nm_config_data_get_connection_default(const NMConfigData *self,
const char * property,
NMDevice * device);
gint64 nm_config_data_get_connection_default_int64(const NMConfigData *self,
const char * property,
@ -218,16 +218,16 @@ gint64 nm_config_data_get_connection_default_int64(const NMConfigData *self,
gint64 max,
gint64 fallback);
char *nm_config_data_get_device_config(const NMConfigData *self,
const char * property,
NMDevice * device,
gboolean * has_match);
const char *nm_config_data_get_device_config(const NMConfigData *self,
const char * property,
NMDevice * device,
gboolean * has_match);
char *nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
const char * property,
const NMPlatformLink *pllink,
const char * match_device_type,
gboolean * has_match);
const char *nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
const char * property,
const NMPlatformLink *pllink,
const char * match_device_type,
gboolean * has_match);
gboolean nm_config_data_get_device_config_boolean(const NMConfigData *self,
const char * property,

View file

@ -151,6 +151,7 @@ test_config_simple(void)
gs_unref_object NMConfig *config = NULL;
gs_strfreev char ** plugins = NULL;
char * value;
const char * cvalue;
gs_unref_object NMDevice *dev50 = nm_test_device_new("00:00:00:00:00:50");
gs_unref_object NMDevice *dev51 = nm_test_device_new("00:00:00:00:00:51");
gs_unref_object NMDevice *dev52 = nm_test_device_new("00:00:00:00:00:52");
@ -206,59 +207,50 @@ test_config_simple(void)
g_assert_cmpstr(value, ==, "51");
g_free(value);
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv6.route-metric",
NULL);
g_assert_cmpstr(value, ==, NULL);
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv6.route-metric",
NULL);
g_assert_cmpstr(cvalue, ==, NULL);
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.route-metric",
NULL);
g_assert_cmpstr(value, ==, "50");
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.route-metric",
NULL);
g_assert_cmpstr(cvalue, ==, "50");
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.route-metric",
dev50);
g_assert_cmpstr(value, ==, "50");
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.route-metric",
dev50);
g_assert_cmpstr(cvalue, ==, "50");
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.route-metric",
dev51);
g_assert_cmpstr(value, ==, "51");
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.route-metric",
dev51);
g_assert_cmpstr(cvalue, ==, "51");
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.route-metric",
dev52);
g_assert_cmpstr(value, ==, "52");
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.route-metric",
dev52);
g_assert_cmpstr(cvalue, ==, "52");
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ethernet.mtu",
dev51);
g_assert_cmpstr(value, ==, "9000");
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ethernet.mtu",
dev51);
g_assert_cmpstr(cvalue, ==, "9000");
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ethernet.mtu",
dev50);
g_assert_cmpstr(value, ==, "1400");
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ethernet.mtu",
dev50);
g_assert_cmpstr(cvalue, ==, "1400");
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.dns-priority",
dev51);
g_assert_cmpstr(value, ==, NULL);
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.dns-priority",
dev51);
g_assert_cmpstr(cvalue, ==, NULL);
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.dns-priority",
dev50);
g_assert_cmpstr(value, ==, "60");
g_free(value);
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
"ipv4.dns-priority",
dev50);
g_assert_cmpstr(cvalue, ==, "60");
}
static void
@ -616,7 +608,7 @@ test_config_confdir(void)
#define ASSERT_GET_CONN_DEFAULT(xconfig, xname, xvalue) \
G_STMT_START \
{ \
gs_free char *_value = \
const char *_value = \
nm_config_data_get_connection_default(nm_config_get_data_orig(xconfig), \
(xname), \
NULL); \