diff options
author | Francesco Giudici <fgiudici@redhat.com> | 2016-11-24 16:26:10 +0100 |
---|---|---|
committer | Francesco Giudici <fgiudici@redhat.com> | 2016-11-24 17:51:52 +0100 |
commit | b029e9256963b3adfde35d1e5adad50b838fdb1d (patch) | |
tree | cee44b37726b8472ecd1779345826ad9fdb2fb7c /libnm-core | |
parent | d61c2264d45e28d14ee4e885de596a32332f40b5 (diff) | |
download | NetworkManager-b029e9256963b3adfde35d1e5adad50b838fdb1d.tar.gz |
libnm-core: normalize ethernet_link properties when auto-negotiate is off
If auto-negotiate is switched off, enforce that both speed and duplex
are set or unset (which would mean "ignore"): if only one is set, reset
both silently and ignore link configuration.
Diffstat (limited to 'libnm-core')
-rw-r--r-- | libnm-core/nm-connection.c | 4 | ||||
-rw-r--r-- | libnm-core/nm-setting-wired.c | 26 |
2 files changed, 22 insertions, 8 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 7bb7d4d9d0..923df3d976 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -727,7 +727,9 @@ _normalize_ethernet_link_neg (NMConnection *self) guint32 speed = nm_setting_wired_get_speed (s_wired); const char *duplex = nm_setting_wired_get_duplex (s_wired); - if (autoneg && (speed || duplex)) { + if ( (autoneg && (speed || duplex)) + || (!autoneg && ( (speed && !duplex) + || (!speed && duplex)))) { speed = 0; duplex = NULL; g_object_set (s_wired, diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index b070f2f6b8..37a2ac082b 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -775,6 +775,15 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_SPEED); return NM_SETTING_VERIFY_NORMALIZABLE_ERROR; } + } else { + if ( ((priv->speed) && (!priv->duplex)) + || ((!priv->speed) && (priv->duplex))) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("both speed and duplex are required for static link configuration")); + return NM_SETTING_VERIFY_NORMALIZABLE_ERROR; + } } return TRUE; @@ -1020,8 +1029,10 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_wired_class) /** * NMSettingWired:speed: * - * If non-zero, request that the device use only the specified speed. In - * Mbit/s, ie 100 == 100Mbit/s. + * Can be set to a value grater than zero only when "auto-negotiate" is "off". + * In that case, statically configures the device to use that specified speed. + * In Mbit/s, ie 100 == 100Mbit/s. + * Must be set together with the "duplex" property when non-zero. **/ /* ---ifcfg-rh--- * property: speed @@ -1041,8 +1052,9 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_wired_class) /** * NMSettingWired:duplex: * - * If specified, request that the device only use the specified duplex mode. - * Either "half" or "full". + * Can be specified only when "auto-negotiate" is "off". In that case, statically + * configures the device to use that specified duplex mode, either "half" or "full". + * Must be set together with the "speed" property if specified. **/ /* ---ifcfg-rh--- * property: duplex @@ -1061,9 +1073,9 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_wired_class) /** * NMSettingWired:auto-negotiate: * - * If %TRUE, allow auto-negotiation of port speed and duplex mode. If - * %FALSE, do not allow auto-negotiation, in which case the "speed" and - * "duplex" properties should be set. + * If %TRUE, enforce auto-negotiation of port speed and duplex mode. If + * %FALSE, "speed" and "duplex" properties should be both set or link configuration + * will be skipped. **/ /* ---ifcfg-rh--- * property: auto-negotiate |