diff options
author | Thomas Haller <thaller@redhat.com> | 2017-12-13 15:33:33 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-12-27 09:18:54 +0100 |
commit | 6295865e0f088d6be796f9ad44454d79fc18eeab (patch) | |
tree | 6ea24861d33d90c32bb417b0e2d04a0db051d48f | |
parent | 00c1e560f9a3bdf6cfe8fee44365ce04fbf0eb55 (diff) | |
download | NetworkManager-6295865e0f088d6be796f9ad44454d79fc18eeab.tar.gz |
core: add nm_config_data_get_device_config_by_pllink() to lookup per-device config
... by platform link.
One caveat is that without having a NMDevice instance, matching by
several paramters won't work. Like, matching against the driver would
require us to look it up via ethtool. When having an NMDevice instance,
the driver is cached there, it's unclear we want to call ethtool for
lookup in this case -- though it could be done.
For other options, it's more complicated. Like, the type basically
depends on the NMDevice class. Usually that also works without a
netdev known to kernel (like bluetooth).
The inconsistency that certain matches are not implemented is ugly
indeed. But the effect is as if the spec doesn't match.
-rw-r--r-- | src/nm-config-data.c | 40 | ||||
-rw-r--r-- | src/nm-config-data.h | 5 |
2 files changed, 42 insertions, 3 deletions
diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 00e5c635b5..d22c7c6bf3 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -1196,6 +1196,7 @@ _match_section_infos_lookup (const MatchSectionInfo *match_section_infos, GKeyFile *keyfile, const char *property, NMDevice *device, + const NMPlatformLink *pllink, char **out_value) { if (!match_section_infos) @@ -1216,9 +1217,15 @@ _match_section_infos_lookup (const MatchSectionInfo *match_section_infos, if (!value && !match_section_infos->stop_match) continue; - match = TRUE; - if (match_section_infos->match_device.has) - match = device && nm_device_spec_match_list (device, match_section_infos->match_device.spec); + if (match_section_infos->match_device.has) { + 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); + else + match = FALSE; + } else + match = TRUE; if (match) { *out_value = value; @@ -1248,6 +1255,32 @@ nm_config_data_get_device_config (const NMConfigData *self, priv->keyfile, property, device, + NULL, + &value); + NM_SET_OUT (has_match, !!connection_info); + return value; +} + +char * +nm_config_data_get_device_config_by_pllink (const NMConfigData *self, + const char *property, + const NMPlatformLink *pllink, + gboolean *has_match) +{ + const NMConfigDataPrivate *priv; + const MatchSectionInfo *connection_info; + char *value = NULL; + + g_return_val_if_fail (self, NULL); + g_return_val_if_fail (property && *property, NULL); + + priv = NM_CONFIG_DATA_GET_PRIVATE (self); + + connection_info = _match_section_infos_lookup (&priv->device_infos[0], + priv->keyfile, + property, + NULL, + pllink, &value); NM_SET_OUT (has_match, !!connection_info); return value; @@ -1287,6 +1320,7 @@ nm_config_data_get_connection_default (const NMConfigData *self, priv->keyfile, property, device, + NULL, &value); return value; } diff --git a/src/nm-config-data.h b/src/nm-config-data.h index 3092a87f6c..10db46d148 100644 --- a/src/nm-config-data.h +++ b/src/nm-config-data.h @@ -188,6 +188,11 @@ char *nm_config_data_get_device_config (const NMConfigData *self, NMDevice *device, gboolean *has_match); +char *nm_config_data_get_device_config_by_pllink (const NMConfigData *self, + const char *property, + const NMPlatformLink *pllink, + gboolean *has_match); + gboolean nm_config_data_get_device_config_boolean (const NMConfigData *self, const char *property, NMDevice *device, |