mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-08 22:00:29 +01:00
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.
This commit is contained in:
parent
00c1e560f9
commit
6295865e0f
2 changed files with 42 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue