mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 12:05:03 +00:00
config: merge branch 'th/config-match-lookup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/894
This commit is contained in:
commit
3e7a589972
|
@ -820,8 +820,7 @@ _prop_get_connection_stable_id(NMDevice * self,
|
||||||
* Especially with ${RANDOM} stable-id we want to generate *one* configuration
|
* Especially with ${RANDOM} stable-id we want to generate *one* configuration
|
||||||
* for each activation. */
|
* for each activation. */
|
||||||
if (G_UNLIKELY(!priv->current_stable_id)) {
|
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;
|
NMUtilsStableType stable_type;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
gboolean hwaddr_is_fake;
|
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);
|
stable_id = nm_setting_connection_get_stable_id(s_con);
|
||||||
|
|
||||||
if (!stable_id) {
|
if (!stable_id) {
|
||||||
default_id =
|
stable_id =
|
||||||
nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
|
nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
|
||||||
NM_CON_DEFAULT("connection.stable-id"),
|
NM_CON_DEFAULT("connection.stable-id"),
|
||||||
self);
|
self);
|
||||||
stable_id = default_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uuid = nm_connection_get_uuid(connection);
|
uuid = nm_connection_get_uuid(connection);
|
||||||
|
@ -897,7 +895,6 @@ _prop_get_ipv6_dhcp_duid(NMDevice * self,
|
||||||
{
|
{
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
const char * duid;
|
const char * duid;
|
||||||
gs_free char * duid_default = NULL;
|
|
||||||
const char * duid_error;
|
const char * duid_error;
|
||||||
GBytes * duid_out;
|
GBytes * duid_out;
|
||||||
gboolean duid_enforce = TRUE;
|
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));
|
duid = nm_setting_ip6_config_get_dhcp_duid(NM_SETTING_IP6_CONFIG(s_ip6));
|
||||||
|
|
||||||
if (!duid) {
|
if (!duid) {
|
||||||
duid_default = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
|
duid = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
|
||||||
NM_CON_DEFAULT("ipv6.dhcp-duid"),
|
NM_CON_DEFAULT("ipv6.dhcp-duid"),
|
||||||
self);
|
self);
|
||||||
duid = duid_default;
|
|
||||||
if (!duid)
|
if (!duid)
|
||||||
duid = "lease";
|
duid = "lease";
|
||||||
}
|
}
|
||||||
|
@ -1390,7 +1386,6 @@ _prop_get_ipvx_dhcp_iaid(NMDevice * self,
|
||||||
const int IS_IPv4 = NM_IS_IPv4(addr_family);
|
const int IS_IPv4 = NM_IS_IPv4(addr_family);
|
||||||
NMSettingIPConfig *s_ip;
|
NMSettingIPConfig *s_ip;
|
||||||
const char * iaid_str;
|
const char * iaid_str;
|
||||||
gs_free char * iaid_str_free = NULL;
|
|
||||||
guint32 iaid;
|
guint32 iaid;
|
||||||
const char * iface;
|
const char * iface;
|
||||||
const char * fail_reason;
|
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);
|
s_ip = nm_connection_get_setting_ip_config(connection, addr_family);
|
||||||
iaid_str = nm_setting_ip_config_get_dhcp_iaid(s_ip);
|
iaid_str = nm_setting_ip_config_get_dhcp_iaid(s_ip);
|
||||||
if (!iaid_str) {
|
if (!iaid_str) {
|
||||||
iaid_str_free = nm_config_data_get_connection_default(
|
iaid_str = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
|
||||||
NM_CONFIG_GET_DATA,
|
IS_IPv4 ? NM_CON_DEFAULT("ipv4.dhcp-iaid")
|
||||||
IS_IPv4 ? NM_CON_DEFAULT("ipv4.dhcp-iaid") : NM_CON_DEFAULT("ipv6.dhcp-iaid"),
|
: NM_CON_DEFAULT("ipv6.dhcp-iaid"),
|
||||||
self);
|
self);
|
||||||
iaid_str = iaid_str_free;
|
|
||||||
if (!iaid_str) {
|
if (!iaid_str) {
|
||||||
iaid_str = NM_IAID_IFNAME;
|
iaid_str = NM_IAID_IFNAME;
|
||||||
is_explicit = FALSE;
|
is_explicit = FALSE;
|
||||||
|
@ -1560,12 +1554,10 @@ _prop_get_ipvx_dhcp_hostname_flags(NMDevice *self, int addr_family)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
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;
|
const char *mud_url;
|
||||||
gs_free char *s = NULL;
|
const char *s;
|
||||||
|
|
||||||
nm_assert(out_mud_url && !*out_mud_url);
|
|
||||||
|
|
||||||
mud_url = nm_setting_connection_get_mud_url(s_con);
|
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))
|
if (nm_streq(s, NM_CONNECTION_MUD_URL_NONE))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (nm_sd_http_url_is_valid_https(s))
|
if (nm_sd_http_url_is_valid_https(s))
|
||||||
return (*out_mud_url = g_steal_pointer(&s));
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1593,7 +1585,6 @@ _prop_get_ipv4_dhcp_client_id(NMDevice *self, NMConnection *connection, GBytes *
|
||||||
{
|
{
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
const char * client_id;
|
const char * client_id;
|
||||||
gs_free char * client_id_default = NULL;
|
|
||||||
guint8 * client_id_buf;
|
guint8 * client_id_buf;
|
||||||
const char * fail_reason;
|
const char * fail_reason;
|
||||||
guint8 hwaddr_bin_buf[_NM_UTILS_HWADDR_LEN_MAX];
|
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));
|
client_id = nm_setting_ip4_config_get_dhcp_client_id(NM_SETTING_IP4_CONFIG(s_ip4));
|
||||||
|
|
||||||
if (!client_id) {
|
if (!client_id) {
|
||||||
client_id_default =
|
client_id = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
|
||||||
nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
|
NM_CON_DEFAULT("ipv4.dhcp-client-id"),
|
||||||
NM_CON_DEFAULT("ipv4.dhcp-client-id"),
|
self);
|
||||||
self);
|
if (client_id && !client_id[0]) {
|
||||||
if (client_id_default && client_id_default[0]) {
|
|
||||||
/* a non-empty client-id is always valid, see nm_dhcp_utils_client_id_string_to_bytes(). */
|
/* 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 *
|
static GBytes *
|
||||||
_prop_get_ipv4_dhcp_vendor_class_identifier(NMDevice *self, NMSettingIP4Config *s_ip4)
|
_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;
|
const char * conn_prop;
|
||||||
GBytes * bytes = NULL;
|
GBytes * bytes = NULL;
|
||||||
const char * bin;
|
const char * bin;
|
||||||
|
@ -1756,13 +1745,13 @@ _prop_get_ipv4_dhcp_vendor_class_identifier(NMDevice *self, NMSettingIP4Config *
|
||||||
|
|
||||||
if (!conn_prop) {
|
if (!conn_prop) {
|
||||||
/* set in NetworkManager.conf ? */
|
/* 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_CONFIG_GET_DATA,
|
||||||
NM_CON_DEFAULT("ipv4.dhcp-vendor-class-identifier"),
|
NM_CON_DEFAULT("ipv4.dhcp-vendor-class-identifier"),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
if (config_data_prop && nm_utils_validate_dhcp4_vendor_class_id(config_data_prop, NULL))
|
if (conn_prop && !nm_utils_validate_dhcp4_vendor_class_id(conn_prop, NULL))
|
||||||
conn_prop = config_data_prop;
|
conn_prop = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn_prop) {
|
if (conn_prop) {
|
||||||
|
@ -1828,16 +1817,11 @@ _prop_get_ipv6_ip6_privacy(NMDevice *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_prop_get_x_cloned_mac_address(NMDevice * self,
|
_prop_get_x_cloned_mac_address(NMDevice *self, NMConnection *connection, gboolean is_wifi)
|
||||||
NMConnection *connection,
|
|
||||||
gboolean is_wifi,
|
|
||||||
char ** out_addr)
|
|
||||||
{
|
{
|
||||||
NMSetting * setting;
|
NMSetting * setting;
|
||||||
const char *addr = NULL;
|
const char *addr = NULL;
|
||||||
|
|
||||||
nm_assert(out_addr && !*out_addr);
|
|
||||||
|
|
||||||
setting = nm_connection_get_setting(connection,
|
setting = nm_connection_get_setting(connection,
|
||||||
is_wifi ? NM_TYPE_SETTING_WIRELESS : NM_TYPE_SETTING_WIRED);
|
is_wifi ? NM_TYPE_SETTING_WIRELESS : NM_TYPE_SETTING_WIRED);
|
||||||
if (setting) {
|
if (setting) {
|
||||||
|
@ -1846,7 +1830,7 @@ _prop_get_x_cloned_mac_address(NMDevice * self,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
gs_free char *a = NULL;
|
const char *a;
|
||||||
|
|
||||||
a = nm_config_data_get_connection_default(
|
a = nm_config_data_get_connection_default(
|
||||||
NM_CONFIG_GET_DATA,
|
NM_CONFIG_GET_DATA,
|
||||||
|
@ -1861,36 +1845,28 @@ _prop_get_x_cloned_mac_address(NMDevice * self,
|
||||||
NMSettingMacRandomization v;
|
NMSettingMacRandomization v;
|
||||||
|
|
||||||
/* for backward compatibility, read the deprecated wifi.mac-address-randomization setting. */
|
/* 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_CONFIG_GET_DATA,
|
||||||
NM_CON_DEFAULT("wifi.mac-address-randomization"),
|
NM_CON_DEFAULT("wifi.mac-address-randomization"),
|
||||||
self);
|
self,
|
||||||
v = _nm_utils_ascii_str_to_int64(a,
|
NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
|
||||||
10,
|
NM_SETTING_MAC_RANDOMIZATION_ALWAYS,
|
||||||
NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
|
NM_SETTING_MAC_RANDOMIZATION_DEFAULT);
|
||||||
NM_SETTING_MAC_RANDOMIZATION_ALWAYS,
|
|
||||||
NM_SETTING_MAC_RANDOMIZATION_DEFAULT);
|
|
||||||
if (v == NM_SETTING_MAC_RANDOMIZATION_ALWAYS)
|
if (v == NM_SETTING_MAC_RANDOMIZATION_ALWAYS)
|
||||||
addr = NM_CLONED_MAC_RANDOM;
|
addr = NM_CLONED_MAC_RANDOM;
|
||||||
}
|
}
|
||||||
} else if (NM_CLONED_MAC_IS_SPECIAL(a) || nm_utils_hwaddr_valid(a, ETH_ALEN))
|
} 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;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_prop_get_x_generate_mac_address_mask(NMDevice * self,
|
_prop_get_x_generate_mac_address_mask(NMDevice *self, NMConnection *connection, gboolean is_wifi)
|
||||||
NMConnection *connection,
|
|
||||||
gboolean is_wifi,
|
|
||||||
char ** out_value)
|
|
||||||
{
|
{
|
||||||
NMSetting * setting;
|
NMSetting * setting;
|
||||||
const char *value = NULL;
|
const char *value;
|
||||||
char * a;
|
|
||||||
|
|
||||||
nm_assert(out_value && !*out_value);
|
|
||||||
|
|
||||||
setting = nm_connection_get_setting(connection,
|
setting = nm_connection_get_setting(connection,
|
||||||
is_wifi ? NM_TYPE_SETTING_WIRELESS : NM_TYPE_SETTING_WIRED);
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = nm_config_data_get_connection_default(
|
return nm_config_data_get_connection_default(
|
||||||
NM_CONFIG_GET_DATA,
|
NM_CONFIG_GET_DATA,
|
||||||
is_wifi ? NM_CON_DEFAULT("wifi.generate-mac-address-mask")
|
is_wifi ? NM_CON_DEFAULT("wifi.generate-mac-address-mask")
|
||||||
: NM_CON_DEFAULT("ethernet.generate-mac-address-mask"),
|
: NM_CON_DEFAULT("ethernet.generate-mac-address-mask"),
|
||||||
self);
|
self);
|
||||||
if (!a)
|
|
||||||
return NULL;
|
|
||||||
*out_value = a;
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -5874,16 +5846,19 @@ sriov_op_queue(NMDevice * self,
|
||||||
static void
|
static void
|
||||||
device_init_static_sriov_num_vfs(NMDevice *self)
|
device_init_static_sriov_num_vfs(NMDevice *self)
|
||||||
{
|
{
|
||||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
|
||||||
gs_free char * value = NULL;
|
|
||||||
int num_vfs;
|
|
||||||
|
|
||||||
if (priv->ifindex > 0 && nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV)) {
|
if (priv->ifindex > 0 && nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV)) {
|
||||||
value = nm_config_data_get_device_config(NM_CONFIG_GET_DATA,
|
int num_vfs;
|
||||||
NM_CONFIG_KEYFILE_KEY_DEVICE_SRIOV_NUM_VFS,
|
|
||||||
self,
|
num_vfs = nm_config_data_get_device_config_int64(NM_CONFIG_GET_DATA,
|
||||||
NULL);
|
NM_CONFIG_KEYFILE_KEY_DEVICE_SRIOV_NUM_VFS,
|
||||||
num_vfs = _nm_utils_ascii_str_to_int64(value, 10, 0, G_MAXINT32, -1);
|
self,
|
||||||
|
10,
|
||||||
|
0,
|
||||||
|
G_MAXINT32,
|
||||||
|
-1,
|
||||||
|
-1);
|
||||||
if (num_vfs >= 0)
|
if (num_vfs >= 0)
|
||||||
sriov_op_queue(self, num_vfs, NM_OPTION_BOOL_DEFAULT, NULL, NULL);
|
sriov_op_queue(self, num_vfs, NM_OPTION_BOOL_DEFAULT, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@ -9414,7 +9389,6 @@ dhcp4_start(NMDevice *self)
|
||||||
gs_unref_bytes GBytes *hwaddr = NULL;
|
gs_unref_bytes GBytes *hwaddr = NULL;
|
||||||
gs_unref_bytes GBytes *bcast_hwaddr = NULL;
|
gs_unref_bytes GBytes *bcast_hwaddr = NULL;
|
||||||
gs_unref_bytes GBytes *client_id = NULL;
|
gs_unref_bytes GBytes *client_id = NULL;
|
||||||
gs_free char * mud_url_free = NULL;
|
|
||||||
NMConnection * connection;
|
NMConnection * connection;
|
||||||
NMSettingConnection * s_con;
|
NMSettingConnection * s_con;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
|
@ -9474,7 +9448,7 @@ dhcp4_start(NMDevice *self)
|
||||||
nm_setting_ip_config_get_dhcp_hostname(s_ip4),
|
nm_setting_ip_config_get_dhcp_hostname(s_ip4),
|
||||||
nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(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_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,
|
client_id,
|
||||||
_prop_get_ipvx_dhcp_timeout(self, AF_INET),
|
_prop_get_ipvx_dhcp_timeout(self, AF_INET),
|
||||||
_device_get_dhcp_anycast_address(self),
|
_device_get_dhcp_anycast_address(self),
|
||||||
|
@ -9878,8 +9852,7 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
|
||||||
gs_unref_bytes GBytes * duid = NULL;
|
gs_unref_bytes GBytes * duid = NULL;
|
||||||
gboolean enforce_duid = FALSE;
|
gboolean enforce_duid = FALSE;
|
||||||
const NMPlatformLink * pllink;
|
const NMPlatformLink * pllink;
|
||||||
gs_free char * mud_url_free = NULL;
|
GError * error = NULL;
|
||||||
GError * error = NULL;
|
|
||||||
guint32 iaid;
|
guint32 iaid;
|
||||||
gboolean iaid_explicit;
|
gboolean iaid_explicit;
|
||||||
NMSettingConnection * s_con;
|
NMSettingConnection * s_con;
|
||||||
|
@ -9924,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_send_hostname(s_ip6),
|
||||||
nm_setting_ip_config_get_dhcp_hostname(s_ip6),
|
nm_setting_ip_config_get_dhcp_hostname(s_ip6),
|
||||||
_prop_get_ipvx_dhcp_hostname_flags(self, AF_INET6),
|
_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,
|
duid,
|
||||||
enforce_duid,
|
enforce_duid,
|
||||||
iaid,
|
iaid,
|
||||||
|
@ -14043,13 +14016,14 @@ nm_device_is_up(NMDevice *self)
|
||||||
static gint64
|
static gint64
|
||||||
_get_carrier_wait_ms(NMDevice *self)
|
_get_carrier_wait_ms(NMDevice *self)
|
||||||
{
|
{
|
||||||
gs_free char *value = NULL;
|
return nm_config_data_get_device_config_int64(NM_CONFIG_GET_DATA,
|
||||||
|
NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT,
|
||||||
value = nm_config_data_get_device_config(NM_CONFIG_GET_DATA,
|
self,
|
||||||
NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT,
|
10,
|
||||||
self,
|
0,
|
||||||
NULL);
|
G_MAXINT32,
|
||||||
return _nm_utils_ascii_str_to_int64(value, 10, 0, G_MAXINT32, CARRIER_WAIT_TIME_MS);
|
CARRIER_WAIT_TIME_MS,
|
||||||
|
CARRIER_WAIT_TIME_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -17273,14 +17247,13 @@ _hw_addr_get_cloned(NMDevice * self,
|
||||||
gboolean * preserve,
|
gboolean * preserve,
|
||||||
char ** hwaddr,
|
char ** hwaddr,
|
||||||
HwAddrType * hwaddr_type,
|
HwAddrType * hwaddr_type,
|
||||||
char ** hwaddr_detail,
|
const char ** hwaddr_detail,
|
||||||
GError ** error)
|
GError ** error)
|
||||||
{
|
{
|
||||||
NMDevicePrivate *priv;
|
NMDevicePrivate *priv;
|
||||||
gs_free char * addr_setting_free = NULL;
|
gs_free char * hw_addr_generated = NULL;
|
||||||
gs_free char * hw_addr_generated = NULL;
|
const char * addr;
|
||||||
gs_free char * generate_mac_address_mask_tmp = NULL;
|
const char * addr_setting;
|
||||||
const char * addr, *addr_setting;
|
|
||||||
char * addr_out;
|
char * addr_out;
|
||||||
HwAddrType type_out;
|
HwAddrType type_out;
|
||||||
|
|
||||||
|
@ -17293,15 +17266,16 @@ _hw_addr_get_cloned(NMDevice * self,
|
||||||
if (!connection)
|
if (!connection)
|
||||||
g_return_val_if_reached(FALSE);
|
g_return_val_if_reached(FALSE);
|
||||||
|
|
||||||
addr = addr_setting =
|
addr_setting = _prop_get_x_cloned_mac_address(self, connection, is_wifi);
|
||||||
_prop_get_x_cloned_mac_address(self, connection, is_wifi, &addr_setting_free);
|
|
||||||
|
addr = addr_setting;
|
||||||
|
|
||||||
if (nm_streq(addr, NM_CLONED_MAC_PRESERVE)) {
|
if (nm_streq(addr, NM_CLONED_MAC_PRESERVE)) {
|
||||||
/* "preserve" means to reset the initial MAC address. */
|
/* "preserve" means to reset the initial MAC address. */
|
||||||
NM_SET_OUT(preserve, TRUE);
|
NM_SET_OUT(preserve, TRUE);
|
||||||
NM_SET_OUT(hwaddr, NULL);
|
NM_SET_OUT(hwaddr, NULL);
|
||||||
NM_SET_OUT(hwaddr_type, HW_ADDR_TYPE_UNSET);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17314,8 +17288,7 @@ _hw_addr_get_cloned(NMDevice * self,
|
||||||
NM_SET_OUT(preserve, TRUE);
|
NM_SET_OUT(preserve, TRUE);
|
||||||
NM_SET_OUT(hwaddr, NULL);
|
NM_SET_OUT(hwaddr, NULL);
|
||||||
NM_SET_OUT(hwaddr_type, HW_ADDR_TYPE_UNSET);
|
NM_SET_OUT(hwaddr_type, HW_ADDR_TYPE_UNSET);
|
||||||
NM_SET_OUT(hwaddr_detail,
|
NM_SET_OUT(hwaddr_detail, addr_setting);
|
||||||
g_steal_pointer(&addr_setting_free) ?: g_strdup(addr_setting));
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (!addr) {
|
} else if (!addr) {
|
||||||
g_set_error_literal(error,
|
g_set_error_literal(error,
|
||||||
|
@ -17335,10 +17308,7 @@ _hw_addr_get_cloned(NMDevice * self,
|
||||||
}
|
}
|
||||||
hw_addr_generated = nm_utils_hw_addr_gen_random_eth(
|
hw_addr_generated = nm_utils_hw_addr_gen_random_eth(
|
||||||
nm_device_get_initial_hw_address(self),
|
nm_device_get_initial_hw_address(self),
|
||||||
_prop_get_x_generate_mac_address_mask(self,
|
_prop_get_x_generate_mac_address_mask(self, connection, is_wifi));
|
||||||
connection,
|
|
||||||
is_wifi,
|
|
||||||
&generate_mac_address_mask_tmp));
|
|
||||||
if (!hw_addr_generated) {
|
if (!hw_addr_generated) {
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
NM_DEVICE_ERROR,
|
NM_DEVICE_ERROR,
|
||||||
|
@ -17366,10 +17336,7 @@ _hw_addr_get_cloned(NMDevice * self,
|
||||||
stable_id,
|
stable_id,
|
||||||
nm_device_get_ip_iface(self),
|
nm_device_get_ip_iface(self),
|
||||||
nm_device_get_initial_hw_address(self),
|
nm_device_get_initial_hw_address(self),
|
||||||
_prop_get_x_generate_mac_address_mask(self,
|
_prop_get_x_generate_mac_address_mask(self, connection, is_wifi));
|
||||||
connection,
|
|
||||||
is_wifi,
|
|
||||||
&generate_mac_address_mask_tmp));
|
|
||||||
if (!hw_addr_generated) {
|
if (!hw_addr_generated) {
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
NM_DEVICE_ERROR,
|
NM_DEVICE_ERROR,
|
||||||
|
@ -17393,7 +17360,7 @@ _hw_addr_get_cloned(NMDevice * self,
|
||||||
NM_SET_OUT(preserve, FALSE);
|
NM_SET_OUT(preserve, FALSE);
|
||||||
NM_SET_OUT(hwaddr, addr_out);
|
NM_SET_OUT(hwaddr, addr_out);
|
||||||
NM_SET_OUT(hwaddr_type, type_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;
|
return TRUE;
|
||||||
out_no_action:
|
out_no_action:
|
||||||
NM_SET_OUT(preserve, FALSE);
|
NM_SET_OUT(preserve, FALSE);
|
||||||
|
@ -17423,7 +17390,7 @@ nm_device_hw_addr_set_cloned(NMDevice *self, NMConnection *connection, gboolean
|
||||||
NMDevicePrivate *priv;
|
NMDevicePrivate *priv;
|
||||||
gboolean preserve = FALSE;
|
gboolean preserve = FALSE;
|
||||||
gs_free char * hwaddr = NULL;
|
gs_free char * hwaddr = NULL;
|
||||||
gs_free char * detail = NULL;
|
const char * detail = NULL;
|
||||||
HwAddrType type = HW_ADDR_TYPE_UNSET;
|
HwAddrType type = HW_ADDR_TYPE_UNSET;
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
|
|
||||||
|
|
|
@ -1382,8 +1382,8 @@ _hw_addr_set_scanning(NMDeviceWifi *self, gboolean do_reset)
|
||||||
now = nm_utils_get_monotonic_timestamp_sec();
|
now = nm_utils_get_monotonic_timestamp_sec();
|
||||||
|
|
||||||
if (now >= priv->hw_addr_scan_expire) {
|
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.
|
/* the random MAC address for scanning expires after a while.
|
||||||
*
|
*
|
||||||
|
|
|
@ -74,7 +74,8 @@ create_device(NMDeviceFactory * factory,
|
||||||
NMConnection * connection,
|
NMConnection * connection,
|
||||||
gboolean * out_ignore)
|
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(iface != NULL, NULL);
|
||||||
g_return_val_if_fail(plink != NULL, NULL);
|
g_return_val_if_fail(plink != NULL, NULL);
|
||||||
|
@ -89,7 +90,7 @@ create_device(NMDeviceFactory * factory,
|
||||||
plink,
|
plink,
|
||||||
"wifi",
|
"wifi",
|
||||||
NULL);
|
NULL);
|
||||||
nm_strstrip(backend);
|
backend = nm_strstrip_avoid_copy_a(300, backend, &backend_free);
|
||||||
|
|
||||||
nm_log_dbg(LOGD_PLATFORM | LOGD_WIFI,
|
nm_log_dbg(LOGD_PLATFORM | LOGD_WIFI,
|
||||||
"(%s) config: backend is %s%s%s%s",
|
"(%s) config: backend is %s%s%s%s",
|
||||||
|
|
|
@ -26,6 +26,8 @@ typedef struct {
|
||||||
gboolean has;
|
gboolean has;
|
||||||
GSList * spec;
|
GSList * spec;
|
||||||
} match_device;
|
} match_device;
|
||||||
|
gsize lookup_len;
|
||||||
|
const NMUtilsNamedValue *lookup_idx;
|
||||||
} MatchSectionInfo;
|
} MatchSectionInfo;
|
||||||
|
|
||||||
struct _NMGlobalDnsDomain {
|
struct _NMGlobalDnsDomain {
|
||||||
|
@ -116,6 +118,11 @@ G_DEFINE_TYPE(NMConfigData, nm_config_data, G_TYPE_OBJECT)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
_match_section_info_get_str(const MatchSectionInfo *m, GKeyFile *keyfile, const char *property);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
nm_config_data_get_config_main_file(const NMConfigData *self)
|
nm_config_data_get_config_main_file(const NMConfigData *self)
|
||||||
{
|
{
|
||||||
|
@ -352,9 +359,9 @@ nm_config_data_get_iwd_config_path(const NMConfigData *self)
|
||||||
gboolean
|
gboolean
|
||||||
nm_config_data_get_ignore_carrier(const NMConfigData *self, NMDevice *device)
|
nm_config_data_get_ignore_carrier(const NMConfigData *self, NMDevice *device)
|
||||||
{
|
{
|
||||||
gs_free char *value = NULL;
|
const char *value;
|
||||||
gboolean has_match;
|
gboolean has_match;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
g_return_val_if_fail(NM_IS_CONFIG_DATA(self), FALSE);
|
g_return_val_if_fail(NM_IS_CONFIG_DATA(self), FALSE);
|
||||||
g_return_val_if_fail(NM_IS_DEVICE(device), FALSE);
|
g_return_val_if_fail(NM_IS_DEVICE(device), FALSE);
|
||||||
|
@ -1390,18 +1397,18 @@ _match_section_infos_lookup(const MatchSectionInfo *match_section_infos,
|
||||||
NMDevice * device,
|
NMDevice * device,
|
||||||
const NMPlatformLink * pllink,
|
const NMPlatformLink * pllink,
|
||||||
const char * match_device_type,
|
const char * match_device_type,
|
||||||
char ** out_value)
|
const char ** out_value)
|
||||||
{
|
{
|
||||||
const char *match_dhcp_plugin;
|
const char *match_dhcp_plugin;
|
||||||
|
|
||||||
if (!match_section_infos)
|
if (!match_section_infos)
|
||||||
return NULL;
|
goto out;
|
||||||
|
|
||||||
match_dhcp_plugin = nm_dhcp_manager_get_config(nm_dhcp_manager_get());
|
match_dhcp_plugin = nm_dhcp_manager_get_config(nm_dhcp_manager_get());
|
||||||
|
|
||||||
for (; match_section_infos->group_name; match_section_infos++) {
|
for (; match_section_infos->group_name; match_section_infos++) {
|
||||||
char * value = NULL;
|
const char *value;
|
||||||
gboolean match;
|
gboolean match;
|
||||||
|
|
||||||
/* FIXME: Here we use g_key_file_get_string(). This should be in sync with what keyfile-reader
|
/* FIXME: Here we use g_key_file_get_string(). This should be in sync with what keyfile-reader
|
||||||
* does.
|
* does.
|
||||||
|
@ -1410,7 +1417,7 @@ _match_section_infos_lookup(const MatchSectionInfo *match_section_infos,
|
||||||
* string_to_value(keyfile_to_string(keyfile)) in one. Optimally, keyfile library would
|
* string_to_value(keyfile_to_string(keyfile)) in one. Optimally, keyfile library would
|
||||||
* expose both functions, and we would return here keyfile_to_string(keyfile).
|
* expose both functions, and we would return here keyfile_to_string(keyfile).
|
||||||
* The caller then could convert the string to the proper value via string_to_value(value). */
|
* The caller then could convert the string to the proper value via string_to_value(value). */
|
||||||
value = g_key_file_get_string(keyfile, match_section_infos->group_name, property, NULL);
|
value = _match_section_info_get_str(match_section_infos, keyfile, property);
|
||||||
if (!value && !match_section_infos->stop_match)
|
if (!value && !match_section_infos->stop_match)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1432,12 +1439,14 @@ _match_section_infos_lookup(const MatchSectionInfo *match_section_infos,
|
||||||
*out_value = value;
|
*out_value = value;
|
||||||
return match_section_infos;
|
return match_section_infos;
|
||||||
}
|
}
|
||||||
g_free(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
*out_value = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
nm_config_data_get_device_config(const NMConfigData *self,
|
nm_config_data_get_device_config(const NMConfigData *self,
|
||||||
const char * property,
|
const char * property,
|
||||||
NMDevice * device,
|
NMDevice * device,
|
||||||
|
@ -1445,7 +1454,7 @@ nm_config_data_get_device_config(const NMConfigData *self,
|
||||||
{
|
{
|
||||||
const NMConfigDataPrivate *priv;
|
const NMConfigDataPrivate *priv;
|
||||||
const MatchSectionInfo * connection_info;
|
const MatchSectionInfo * connection_info;
|
||||||
char * value = NULL;
|
const char * value;
|
||||||
|
|
||||||
NM_SET_OUT(has_match, FALSE);
|
NM_SET_OUT(has_match, FALSE);
|
||||||
|
|
||||||
|
@ -1465,7 +1474,7 @@ nm_config_data_get_device_config(const NMConfigData *self,
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
|
nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
|
||||||
const char * property,
|
const char * property,
|
||||||
const NMPlatformLink *pllink,
|
const NMPlatformLink *pllink,
|
||||||
|
@ -1474,7 +1483,7 @@ nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
|
||||||
{
|
{
|
||||||
const NMConfigDataPrivate *priv;
|
const NMConfigDataPrivate *priv;
|
||||||
const MatchSectionInfo * connection_info;
|
const MatchSectionInfo * connection_info;
|
||||||
char * value = NULL;
|
const char * value;
|
||||||
|
|
||||||
g_return_val_if_fail(self, NULL);
|
g_return_val_if_fail(self, NULL);
|
||||||
g_return_val_if_fail(property && *property, NULL);
|
g_return_val_if_fail(property && *property, NULL);
|
||||||
|
@ -1499,8 +1508,8 @@ nm_config_data_get_device_config_boolean(const NMConfigData *self,
|
||||||
int val_no_match,
|
int val_no_match,
|
||||||
int val_invalid)
|
int val_invalid)
|
||||||
{
|
{
|
||||||
gs_free char *value = NULL;
|
const char *value;
|
||||||
gboolean has_match;
|
gboolean has_match;
|
||||||
|
|
||||||
value = nm_config_data_get_device_config(self, property, device, &has_match);
|
value = nm_config_data_get_device_config(self, property, device, &has_match);
|
||||||
if (!has_match)
|
if (!has_match)
|
||||||
|
@ -1508,13 +1517,34 @@ nm_config_data_get_device_config_boolean(const NMConfigData *self,
|
||||||
return nm_config_parse_boolean(value, val_invalid);
|
return nm_config_parse_boolean(value, val_invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
gint64
|
||||||
|
nm_config_data_get_device_config_int64(const NMConfigData *self,
|
||||||
|
const char * property,
|
||||||
|
NMDevice * device,
|
||||||
|
int base,
|
||||||
|
gint64 min,
|
||||||
|
gint64 max,
|
||||||
|
gint64 val_no_match,
|
||||||
|
gint64 val_invalid)
|
||||||
|
{
|
||||||
|
const char *value;
|
||||||
|
gboolean has_match;
|
||||||
|
|
||||||
|
value = nm_config_data_get_device_config(self, property, device, &has_match);
|
||||||
|
if (!has_match) {
|
||||||
|
errno = ENOENT;
|
||||||
|
return val_no_match;
|
||||||
|
}
|
||||||
|
return _nm_utils_ascii_str_to_int64(value, base, min, max, val_invalid);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
nm_config_data_get_connection_default(const NMConfigData *self,
|
nm_config_data_get_connection_default(const NMConfigData *self,
|
||||||
const char * property,
|
const char * property,
|
||||||
NMDevice * device)
|
NMDevice * device)
|
||||||
{
|
{
|
||||||
const NMConfigDataPrivate *priv;
|
const NMConfigDataPrivate *priv;
|
||||||
char * value = NULL;
|
const char * value;
|
||||||
|
|
||||||
g_return_val_if_fail(self, NULL);
|
g_return_val_if_fail(self, NULL);
|
||||||
g_return_val_if_fail(property && *property, NULL);
|
g_return_val_if_fail(property && *property, NULL);
|
||||||
|
@ -1553,15 +1583,41 @@ nm_config_data_get_connection_default_int64(const NMConfigData *self,
|
||||||
gint64 max,
|
gint64 max,
|
||||||
gint64 fallback)
|
gint64 fallback)
|
||||||
{
|
{
|
||||||
gs_free char *value = NULL;
|
const char *value;
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(self, property, device);
|
value = nm_config_data_get_connection_default(self, property, device);
|
||||||
return _nm_utils_ascii_str_to_int64(value, 10, min, max, fallback);
|
return _nm_utils_ascii_str_to_int64(value, 10, min, max, fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static const char *
|
||||||
_get_connection_info_init(MatchSectionInfo *connection_info, GKeyFile *keyfile, char *group)
|
_match_section_info_get_str(const MatchSectionInfo *m, GKeyFile *keyfile, const char *property)
|
||||||
{
|
{
|
||||||
|
gssize idx;
|
||||||
|
const char *value;
|
||||||
|
|
||||||
|
idx = nm_utils_named_value_list_find(m->lookup_idx, m->lookup_len, property, TRUE);
|
||||||
|
value = idx >= 0 ? m->lookup_idx[idx].value_str : NULL;
|
||||||
|
|
||||||
|
#if NM_MORE_ASSERTS > 10
|
||||||
|
{
|
||||||
|
gs_free char *value2 = g_key_file_get_string(keyfile, m->group_name, property, NULL);
|
||||||
|
|
||||||
|
nm_assert(nm_streq0(value2, value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_match_section_info_init(MatchSectionInfo *connection_info, GKeyFile *keyfile, char *group)
|
||||||
|
{
|
||||||
|
char ** keys = NULL;
|
||||||
|
gsize n_keys;
|
||||||
|
gsize i;
|
||||||
|
gsize j;
|
||||||
|
NMUtilsNamedValue *vals;
|
||||||
|
|
||||||
/* pass ownership of @group on... */
|
/* pass ownership of @group on... */
|
||||||
connection_info->group_name = group;
|
connection_info->group_name = group;
|
||||||
|
|
||||||
|
@ -1572,18 +1628,66 @@ _get_connection_info_init(MatchSectionInfo *connection_info, GKeyFile *keyfile,
|
||||||
&connection_info->match_device.has);
|
&connection_info->match_device.has);
|
||||||
connection_info->stop_match =
|
connection_info->stop_match =
|
||||||
nm_config_keyfile_get_boolean(keyfile, group, NM_CONFIG_KEYFILE_KEY_STOP_MATCH, FALSE);
|
nm_config_keyfile_get_boolean(keyfile, group, NM_CONFIG_KEYFILE_KEY_STOP_MATCH, FALSE);
|
||||||
|
|
||||||
|
keys = g_key_file_get_keys(keyfile, group, &n_keys, NULL);
|
||||||
|
nm_utils_strv_sort(keys, n_keys);
|
||||||
|
|
||||||
|
vals = g_new(NMUtilsNamedValue, n_keys);
|
||||||
|
|
||||||
|
for (i = 0, j = 0; i < n_keys; i++) {
|
||||||
|
gs_free char *key = g_steal_pointer(&keys[i]);
|
||||||
|
char * value;
|
||||||
|
|
||||||
|
if (NM_IN_STRSET(key, NM_CONFIG_KEYFILE_KEY_STOP_MATCH, NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (j > 0 && nm_streq(vals[j - 1].name, key))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
value = g_key_file_get_string(keyfile, group, key, NULL);
|
||||||
|
if (!value)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
vals[j++] = (NMUtilsNamedValue){
|
||||||
|
.name = g_steal_pointer(&key),
|
||||||
|
.value_str = value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(keys);
|
||||||
|
|
||||||
|
if (n_keys != j) {
|
||||||
|
gs_free NMUtilsNamedValue *vals2 = vals;
|
||||||
|
|
||||||
|
/* since this buffer will be kept around for a long time,
|
||||||
|
* get rid of the excess allocation. */
|
||||||
|
vals = nm_memdup(vals2, sizeof(NMUtilsNamedValue) * j);
|
||||||
|
n_keys = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n_keys == 0)
|
||||||
|
nm_clear_g_free(&vals);
|
||||||
|
|
||||||
|
connection_info->lookup_idx = vals;
|
||||||
|
connection_info->lookup_len = n_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_match_section_infos_free(MatchSectionInfo *match_section_infos)
|
_match_section_infos_free(MatchSectionInfo *match_section_infos)
|
||||||
{
|
{
|
||||||
guint i;
|
MatchSectionInfo *m;
|
||||||
|
gsize i;
|
||||||
|
|
||||||
if (!match_section_infos)
|
if (!match_section_infos)
|
||||||
return;
|
return;
|
||||||
for (i = 0; match_section_infos[i].group_name; i++) {
|
for (m = match_section_infos; m->group_name; m++) {
|
||||||
g_free(match_section_infos[i].group_name);
|
g_free(m->group_name);
|
||||||
g_slist_free_full(match_section_infos[i].match_device.spec, g_free);
|
g_slist_free_full(m->match_device.spec, g_free);
|
||||||
|
for (i = 0; i < m->lookup_len; i++) {
|
||||||
|
g_free(m->lookup_idx[i].name_mutable);
|
||||||
|
g_free(m->lookup_idx[i].value_str_mutable);
|
||||||
|
}
|
||||||
|
g_free((gpointer) m->lookup_idx);
|
||||||
}
|
}
|
||||||
g_free(match_section_infos);
|
g_free(match_section_infos);
|
||||||
}
|
}
|
||||||
|
@ -1628,11 +1732,11 @@ _match_section_infos_construct(GKeyFile *keyfile, const char *prefix)
|
||||||
match_section_infos = g_new0(MatchSectionInfo, ngroups + 1 + (connection_tag ? 1 : 0));
|
match_section_infos = g_new0(MatchSectionInfo, ngroups + 1 + (connection_tag ? 1 : 0));
|
||||||
for (i = 0; i < ngroups; i++) {
|
for (i = 0; i < ngroups; i++) {
|
||||||
/* pass ownership of @group on... */
|
/* pass ownership of @group on... */
|
||||||
_get_connection_info_init(&match_section_infos[i], keyfile, groups[ngroups - i - 1]);
|
_match_section_info_init(&match_section_infos[i], keyfile, groups[ngroups - i - 1]);
|
||||||
}
|
}
|
||||||
if (connection_tag) {
|
if (connection_tag) {
|
||||||
/* pass ownership of @connection_tag on... */
|
/* pass ownership of @connection_tag on... */
|
||||||
_get_connection_info_init(&match_section_infos[i], keyfile, connection_tag);
|
_match_section_info_init(&match_section_infos[i], keyfile, connection_tag);
|
||||||
}
|
}
|
||||||
g_free(groups);
|
g_free(groups);
|
||||||
|
|
||||||
|
|
|
@ -207,9 +207,9 @@ extern const char *__stop_connection_defaults[];
|
||||||
name; \
|
name; \
|
||||||
})
|
})
|
||||||
|
|
||||||
char *nm_config_data_get_connection_default(const NMConfigData *self,
|
const char *nm_config_data_get_connection_default(const NMConfigData *self,
|
||||||
const char * property,
|
const char * property,
|
||||||
NMDevice * device);
|
NMDevice * device);
|
||||||
|
|
||||||
gint64 nm_config_data_get_connection_default_int64(const NMConfigData *self,
|
gint64 nm_config_data_get_connection_default_int64(const NMConfigData *self,
|
||||||
const char * property,
|
const char * property,
|
||||||
|
@ -218,22 +218,30 @@ gint64 nm_config_data_get_connection_default_int64(const NMConfigData *self,
|
||||||
gint64 max,
|
gint64 max,
|
||||||
gint64 fallback);
|
gint64 fallback);
|
||||||
|
|
||||||
char *nm_config_data_get_device_config(const NMConfigData *self,
|
const char *nm_config_data_get_device_config(const NMConfigData *self,
|
||||||
const char * property,
|
const char * property,
|
||||||
NMDevice * device,
|
NMDevice * device,
|
||||||
gboolean * has_match);
|
gboolean * has_match);
|
||||||
|
|
||||||
char *nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
|
const char *nm_config_data_get_device_config_by_pllink(const NMConfigData * self,
|
||||||
const char * property,
|
const char * property,
|
||||||
const NMPlatformLink *pllink,
|
const NMPlatformLink *pllink,
|
||||||
const char * match_device_type,
|
const char * match_device_type,
|
||||||
gboolean * has_match);
|
gboolean * has_match);
|
||||||
|
|
||||||
gboolean nm_config_data_get_device_config_boolean(const NMConfigData *self,
|
gboolean nm_config_data_get_device_config_boolean(const NMConfigData *self,
|
||||||
const char * property,
|
const char * property,
|
||||||
NMDevice * device,
|
NMDevice * device,
|
||||||
int val_no_match,
|
int val_no_match,
|
||||||
int val_invalid);
|
int val_invalid);
|
||||||
|
gint64 nm_config_data_get_device_config_int64(const NMConfigData *self,
|
||||||
|
const char * property,
|
||||||
|
NMDevice * device,
|
||||||
|
int base,
|
||||||
|
gint64 min,
|
||||||
|
gint64 max,
|
||||||
|
gint64 val_no_match,
|
||||||
|
gint64 val_invalid);
|
||||||
|
|
||||||
char ** nm_config_data_get_groups(const NMConfigData *self);
|
char ** nm_config_data_get_groups(const NMConfigData *self);
|
||||||
char ** nm_config_data_get_keys(const NMConfigData *self, const char *group);
|
char ** nm_config_data_get_keys(const NMConfigData *self, const char *group);
|
||||||
|
|
|
@ -151,6 +151,7 @@ test_config_simple(void)
|
||||||
gs_unref_object NMConfig *config = NULL;
|
gs_unref_object NMConfig *config = NULL;
|
||||||
gs_strfreev char ** plugins = NULL;
|
gs_strfreev char ** plugins = NULL;
|
||||||
char * value;
|
char * value;
|
||||||
|
const char * cvalue;
|
||||||
gs_unref_object NMDevice *dev50 = nm_test_device_new("00:00:00:00:00:50");
|
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 *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");
|
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_assert_cmpstr(value, ==, "51");
|
||||||
g_free(value);
|
g_free(value);
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ipv6.route-metric",
|
"ipv6.route-metric",
|
||||||
NULL);
|
NULL);
|
||||||
g_assert_cmpstr(value, ==, NULL);
|
g_assert_cmpstr(cvalue, ==, NULL);
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ipv4.route-metric",
|
"ipv4.route-metric",
|
||||||
NULL);
|
NULL);
|
||||||
g_assert_cmpstr(value, ==, "50");
|
g_assert_cmpstr(cvalue, ==, "50");
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ipv4.route-metric",
|
"ipv4.route-metric",
|
||||||
dev50);
|
dev50);
|
||||||
g_assert_cmpstr(value, ==, "50");
|
g_assert_cmpstr(cvalue, ==, "50");
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ipv4.route-metric",
|
"ipv4.route-metric",
|
||||||
dev51);
|
dev51);
|
||||||
g_assert_cmpstr(value, ==, "51");
|
g_assert_cmpstr(cvalue, ==, "51");
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ipv4.route-metric",
|
"ipv4.route-metric",
|
||||||
dev52);
|
dev52);
|
||||||
g_assert_cmpstr(value, ==, "52");
|
g_assert_cmpstr(cvalue, ==, "52");
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ethernet.mtu",
|
"ethernet.mtu",
|
||||||
dev51);
|
dev51);
|
||||||
g_assert_cmpstr(value, ==, "9000");
|
g_assert_cmpstr(cvalue, ==, "9000");
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ethernet.mtu",
|
"ethernet.mtu",
|
||||||
dev50);
|
dev50);
|
||||||
g_assert_cmpstr(value, ==, "1400");
|
g_assert_cmpstr(cvalue, ==, "1400");
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ipv4.dns-priority",
|
"ipv4.dns-priority",
|
||||||
dev51);
|
dev51);
|
||||||
g_assert_cmpstr(value, ==, NULL);
|
g_assert_cmpstr(cvalue, ==, NULL);
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
value = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
cvalue = nm_config_data_get_connection_default(nm_config_get_data_orig(config),
|
||||||
"ipv4.dns-priority",
|
"ipv4.dns-priority",
|
||||||
dev50);
|
dev50);
|
||||||
g_assert_cmpstr(value, ==, "60");
|
g_assert_cmpstr(cvalue, ==, "60");
|
||||||
g_free(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -616,7 +608,7 @@ test_config_confdir(void)
|
||||||
#define ASSERT_GET_CONN_DEFAULT(xconfig, xname, xvalue) \
|
#define ASSERT_GET_CONN_DEFAULT(xconfig, xname, xvalue) \
|
||||||
G_STMT_START \
|
G_STMT_START \
|
||||||
{ \
|
{ \
|
||||||
gs_free char *_value = \
|
const char *_value = \
|
||||||
nm_config_data_get_connection_default(nm_config_get_data_orig(xconfig), \
|
nm_config_data_get_connection_default(nm_config_get_data_orig(xconfig), \
|
||||||
(xname), \
|
(xname), \
|
||||||
NULL); \
|
NULL); \
|
||||||
|
|
|
@ -3244,11 +3244,8 @@ void
|
||||||
nm_utils_named_value_clear_with_g_free(NMUtilsNamedValue *val)
|
nm_utils_named_value_clear_with_g_free(NMUtilsNamedValue *val)
|
||||||
{
|
{
|
||||||
if (val) {
|
if (val) {
|
||||||
gs_free gpointer x_name = NULL;
|
nm_clear_g_free(&val->name_mutable);
|
||||||
gs_free gpointer x_value = NULL;
|
nm_clear_g_free(&val->value_ptr);
|
||||||
|
|
||||||
x_name = (gpointer) g_steal_pointer(&val->name);
|
|
||||||
x_value = g_steal_pointer(&val->value_ptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue