device: handle default for unset ignore-carrier option depending on device

Currently, device types like Bond hack around ignore-carrier
setting, as they always want to ignore-carrier.

Prepare so that also for such master types, we rely and honor the
ignore-carrier setting better. In the next commit, bond, bridge and
team devices they will get ignore-carrier turned on by default.
This commit is contained in:
Thomas Haller 2017-06-01 22:38:51 +02:00
parent 7ee1af5f8a
commit 98651b90a1
3 changed files with 19 additions and 2 deletions

View file

@ -3829,6 +3829,14 @@ nm_device_is_available (NMDevice *self, NMDeviceCheckDevAvailableFlags flags)
return NM_DEVICE_GET_CLASS (self)->is_available (self, flags);
}
gboolean
nm_device_ignore_carrier_by_default (NMDevice *self)
{
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
return FALSE;
}
gboolean
nm_device_get_enabled (NMDevice *self)
{

View file

@ -493,6 +493,8 @@ NMSetting * nm_device_get_applied_setting (NMDevice *dev, GType setting_ty
void nm_device_removed (NMDevice *self, gboolean unconfigure_ip_config);
gboolean nm_device_ignore_carrier_by_default (NMDevice *self);
gboolean nm_device_is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags);
gboolean nm_device_has_carrier (NMDevice *dev);

View file

@ -304,15 +304,22 @@ nm_config_data_get_ignore_carrier (const NMConfigData *self, NMDevice *device)
{
gs_free char *value = NULL;
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);
value = nm_config_data_get_device_config (self, NM_CONFIG_KEYFILE_KEY_DEVICE_IGNORE_CARRIER, device, &has_match);
if (has_match)
return nm_config_parse_boolean (value, FALSE);
m = nm_config_parse_boolean (value, -1);
else
m = nm_device_spec_match_list_full (device, NM_CONFIG_DATA_GET_PRIVATE (self)->ignore_carrier, -1);
return nm_device_spec_match_list (device, NM_CONFIG_DATA_GET_PRIVATE (self)->ignore_carrier);
if (NM_IN_SET (m, TRUE, FALSE))
return m;
/* if ignore-carrier is not explicitly configed, then it depends on the device (type). */
return nm_device_ignore_carrier_by_default (device);
}
gboolean