summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-12-27 09:30:49 +0100
committerThomas Haller <thaller@redhat.com>2017-12-27 09:42:05 +0100
commit969eb98d528b1311c50584b649315b415e53954f (patch)
tree5279d23dec34587638d811ef7c242a72ab252be5
parentbbea0656a5e364ef79adf8e6a140c5d1fde7e9cb (diff)
downloadNetworkManager-969eb98d528b1311c50584b649315b415e53954f.tar.gz
core: extend nm_match_spec_device_by_pllink() with the device-type
nm_match_spec_device_by_pllink() does not support matching on all parameters, unlike nm_match_spec_device(). The reason is that certain parameters are only available when having a NMDevice instance. Add an argument "match_device_type", so that the caller can inject the device type to be used. Note that for NMDevice, the device-type is nm_device_get_type_description(), which usually depends on the device class only. The only caller of nm_match_spec_device_by_pllink() is the wifi factory, and it already knows that it wants to create a device of type NMDeviceWifi. Hence, it knows and can specify "wifi" as match_device_type.
-rw-r--r--src/NetworkManagerUtils.c3
-rw-r--r--src/NetworkManagerUtils.h1
-rw-r--r--src/devices/wifi/nm-wifi-factory.c1
-rw-r--r--src/nm-config-data.c7
-rw-r--r--src/nm-config-data.h1
5 files changed, 11 insertions, 2 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index a24d7bc1b2..2259fc7e76 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -938,6 +938,7 @@ nm_utils_g_value_set_object_path_array (GValue *value,
int
nm_match_spec_device_by_pllink (const NMPlatformLink *pllink,
+ const char *match_device_type,
const GSList *specs,
int no_match_value)
{
@@ -950,7 +951,7 @@ nm_match_spec_device_by_pllink (const NMPlatformLink *pllink,
* which match even in that case. */
m = nm_match_spec_device (specs,
pllink ? pllink->name : NULL,
- NULL,
+ match_device_type,
pllink ? pllink->driver : NULL,
NULL,
NULL,
diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h
index 989ae9405c..16b0873664 100644
--- a/src/NetworkManagerUtils.h
+++ b/src/NetworkManagerUtils.h
@@ -65,6 +65,7 @@ void nm_utils_g_value_set_object_path_array (GValue *value,
gpointer user_data);
int nm_match_spec_device_by_pllink (const NMPlatformLink *pllink,
+ const char *match_device_type,
const GSList *specs,
int no_match_value);
diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c
index d3800469b6..6b8e5fb85a 100644
--- a/src/devices/wifi/nm-wifi-factory.c
+++ b/src/devices/wifi/nm-wifi-factory.c
@@ -107,6 +107,7 @@ create_device (NMDeviceFactory *factory,
backend = nm_config_data_get_device_config_by_pllink (NM_CONFIG_GET_DATA,
NM_CONFIG_KEYFILE_KEY_DEVICE_WIFI_BACKEND,
plink,
+ "wifi",
NULL);
nm_strstrip (backend);
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index d22c7c6bf3..e71ac95a63 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -1197,6 +1197,7 @@ _match_section_infos_lookup (const MatchSectionInfo *match_section_infos,
const char *property,
NMDevice *device,
const NMPlatformLink *pllink,
+ const char *match_device_type,
char **out_value)
{
if (!match_section_infos)
@@ -1221,7 +1222,7 @@ _match_section_infos_lookup (const MatchSectionInfo *match_section_infos,
if (device)
match = nm_device_spec_match_list (device, match_section_infos->match_device.spec);
else if (pllink)
- match = nm_match_spec_device_by_pllink (pllink, match_section_infos->match_device.spec, FALSE);
+ match = nm_match_spec_device_by_pllink (pllink, match_device_type, match_section_infos->match_device.spec, FALSE);
else
match = FALSE;
} else
@@ -1256,6 +1257,7 @@ nm_config_data_get_device_config (const NMConfigData *self,
property,
device,
NULL,
+ NULL,
&value);
NM_SET_OUT (has_match, !!connection_info);
return value;
@@ -1265,6 +1267,7 @@ 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 NMConfigDataPrivate *priv;
@@ -1281,6 +1284,7 @@ nm_config_data_get_device_config_by_pllink (const NMConfigData *self,
property,
NULL,
pllink,
+ match_device_type,
&value);
NM_SET_OUT (has_match, !!connection_info);
return value;
@@ -1321,6 +1325,7 @@ nm_config_data_get_connection_default (const NMConfigData *self,
property,
device,
NULL,
+ NULL,
&value);
return value;
}
diff --git a/src/nm-config-data.h b/src/nm-config-data.h
index 10db46d148..87cb83ba12 100644
--- a/src/nm-config-data.h
+++ b/src/nm-config-data.h
@@ -191,6 +191,7 @@ char *nm_config_data_get_device_config (const NMConfigData *self,
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,