diff options
Diffstat (limited to 'libnm-util/nm-setting-infiniband.c')
| -rw-r--r-- | libnm-util/nm-setting-infiniband.c | 95 |
1 files changed, 68 insertions, 27 deletions
diff --git a/libnm-util/nm-setting-infiniband.c b/libnm-util/nm-setting-infiniband.c index 5af50448..1036702f 100644 --- a/libnm-util/nm-setting-infiniband.c +++ b/libnm-util/nm-setting-infiniband.c @@ -19,10 +19,12 @@ * Copyright 2011 - 2013 Red Hat, Inc. */ +#include "config.h" + #include <stdlib.h> #include <dbus/dbus-glib.h> #include <linux/if_infiniband.h> -#include <glib/gi18n.h> +#include <glib/gi18n-lib.h> #include "nm-setting-infiniband.h" #include "nm-param-spec-specialized.h" @@ -194,6 +196,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) { @@ -205,6 +208,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } + /* FIXME: verify() should not modify the setting, but return NORMALIZABLE success. */ if (!g_strcmp0 (priv->transport_mode, "datagram")) { if (priv->mtu > 2044) priv->mtu = 2044; @@ -249,6 +253,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; } @@ -359,14 +402,11 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class) **/ g_object_class_install_property (object_class, PROP_MAC_ADDRESS, - _nm_param_spec_specialized (NM_SETTING_INFINIBAND_MAC_ADDRESS, - "Device MAC Address", - "If specified, this connection will only apply to " - "the IPoIB device whose permanent MAC address matches. " - "This property does not change the MAC address " - "of the device (i.e. MAC spoofing).", + _nm_param_spec_specialized (NM_SETTING_INFINIBAND_MAC_ADDRESS, "", "", DBUS_TYPE_G_UCHAR_ARRAY, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE)); + G_PARAM_READWRITE | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS)); /** * NMSettingInfiniband:mtu: @@ -376,13 +416,12 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class) **/ g_object_class_install_property (object_class, PROP_MTU, - g_param_spec_uint (NM_SETTING_INFINIBAND_MTU, - "MTU", - "If non-zero, only transmit packets of the specified " - "size or smaller, breaking larger packets up into " - "multiple frames.", + g_param_spec_uint (NM_SETTING_INFINIBAND_MTU, "", "", 0, G_MAXUINT32, 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE)); + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_FUZZY_IGNORE | + G_PARAM_STATIC_STRINGS)); /** * NMSettingInfiniband:transport-mode: @@ -392,11 +431,12 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class) **/ g_object_class_install_property (object_class, PROP_TRANSPORT_MODE, - g_param_spec_string (NM_SETTING_INFINIBAND_TRANSPORT_MODE, - "Transport Mode", - "The IPoIB transport mode. Either 'datagram' or 'connected'.", + g_param_spec_string (NM_SETTING_INFINIBAND_TRANSPORT_MODE, "", "", NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE)); + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS)); /** * NMSettingInfiniband:p-key: @@ -408,12 +448,12 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class) **/ g_object_class_install_property (object_class, PROP_P_KEY, - g_param_spec_int (NM_SETTING_INFINIBAND_P_KEY, - "P_Key", - "The InfiniBand P_Key. Either -1 for the " - "default, or a 16-bit unsigned integer.", + g_param_spec_int (NM_SETTING_INFINIBAND_P_KEY, "", "", -1, 0xFFFF, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE)); + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS)); /** * NMSettingInfiniband:parent: @@ -425,10 +465,11 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class) **/ g_object_class_install_property (object_class, PROP_PARENT, - g_param_spec_string (NM_SETTING_INFINIBAND_PARENT, - "Parent", - "The interface name of the parent device, or NULL", + g_param_spec_string (NM_SETTING_INFINIBAND_PARENT, "", "", NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE)); + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS)); } |