summaryrefslogtreecommitdiff
path: root/libnm-util/nm-setting-infiniband.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2013-11-29 13:13:41 +0100
committerThomas Haller <thaller@redhat.com>2014-06-30 18:35:46 +0200
commit2deaa5397a879a31c8ec0ca34553c0a97eaea69b (patch)
tree262f14267e96682c25a1ea59a319bc964be4d3c5 /libnm-util/nm-setting-infiniband.c
parentde5656a5707a5d2b23ec3f2738476ad59d9edd04 (diff)
downloadNetworkManager-2deaa5397a879a31c8ec0ca34553c0a97eaea69b.tar.gz
libnm-util: normalize virtual_iface_name in NMSettings
Some type-specific NMSetting implementations (bond, bridge, team, vlan) have their own 'interface-name' property. This property will be deprecated in favour of 'interface-name' in NMSettingConnection. Change verify() and normalize() to check that the redundant values match and repair/normalize the properties. Force the virtual interface name of the type-specific setting to be equal to NMSettingConnection:interface_name. This way, the depreacted field stays valid and backward compatible. NMSettingInfiniband is special, because it does not have a backing property for the interface name, although it implements get_virtual_iface_name(). To account for this, some special handling is needed in order not to change the behaviour of get_virtual_iface_name(). Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'libnm-util/nm-setting-infiniband.c')
-rw-r--r--libnm-util/nm-setting-infiniband.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libnm-util/nm-setting-infiniband.c b/libnm-util/nm-setting-infiniband.c
index 2552cd9c46..b244a9d4c5 100644
--- a/libnm-util/nm-setting-infiniband.c
+++ b/libnm-util/nm-setting-infiniband.c
@@ -194,6 +194,7 @@ get_virtual_iface_name (NMSetting *setting)
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
+ NMSettingConnection *s_con;
NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (setting);
if (priv->mac_address && priv->mac_address->len != INFINIBAND_ALEN) {
@@ -249,6 +250,45 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
}
+ s_con = NM_SETTING_CONNECTION (nm_setting_find_in_list (all_settings, NM_SETTING_CONNECTION_SETTING_NAME));
+ if (s_con) {
+ const char *interface_name = nm_setting_connection_get_interface_name (s_con);
+
+ if (!interface_name)
+ ;
+ else if (!nm_utils_iface_valid_name (interface_name)) {
+ /* report the error for NMSettingConnection:interface-name, because
+ * it's that property that is invalid -- although we currently verify()
+ * NMSettingInfiniband.
+ **/
+ g_set_error (error,
+ NM_SETTING_CONNECTION_ERROR,
+ NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("'%s' is not a valid interface name"),
+ interface_name);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
+ return FALSE;
+ } else {
+ if (priv->p_key != -1) {
+ if (!priv->virtual_iface_name)
+ priv->virtual_iface_name = g_strdup_printf ("%s.%04x", priv->parent, priv->p_key);
+
+ if (strcmp (interface_name, priv->virtual_iface_name) != 0) {
+ /* We don't support renaming software infiniband devices. Later we might, but
+ * for now just reject such connections.
+ **/
+ g_set_error (error,
+ NM_SETTING_CONNECTION_ERROR,
+ NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("interface name of software infiniband device must be '%s' or unset (instead it is '%s')"),
+ priv->virtual_iface_name, interface_name);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
+ return FALSE;
+ }
+ }
+ }
+ }
+
return TRUE;
}