about summary refs log tree commit diff
path: root/src/libnm-core-impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-core-impl')
-rw-r--r--src/libnm-core-impl/nm-setting-infiniband.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/libnm-core-impl/nm-setting-infiniband.c b/src/libnm-core-impl/nm-setting-infiniband.c
index eb6c9536..787b838b 100644
--- a/src/libnm-core-impl/nm-setting-infiniband.c
+++ b/src/libnm-core-impl/nm-setting-infiniband.c
@@ -241,6 +241,14 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
             g_prefix_error(error, "%s: ", NM_SETTING_INFINIBAND_PARENT);
             return FALSE;
         }
+        if (NM_IN_SET(priv->p_key, 0, 0x8000)) {
+            g_set_error_literal(error,
+                                NM_CONNECTION_ERROR,
+                                NM_CONNECTION_ERROR_INVALID_PROPERTY,
+                                _("the values 0 and 0x8000 are not allowed"));
+            g_prefix_error(error, "%s: ", NM_SETTING_INFINIBAND_P_KEY);
+            return FALSE;
+        }
     }
 
     if (connection)
@@ -254,17 +262,27 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
             virtual_iface_name =
                 nm_setting_infiniband_get_virtual_interface_name(NM_SETTING_INFINIBAND(setting));
 
-            if (!nm_streq(interface_name, virtual_iface_name)) {
+            if (!nm_streq0(interface_name, virtual_iface_name)) {
                 /* We don't support renaming software infiniband devices. Later we might, but
                  * for now just reject such connections.
                  **/
-                g_set_error(error,
-                            NM_CONNECTION_ERROR,
-                            NM_CONNECTION_ERROR_INVALID_PROPERTY,
-                            _("interface name of software infiniband device must be '%s' or unset "
-                              "(instead it is '%s')"),
-                            virtual_iface_name,
-                            interface_name);
+                if (virtual_iface_name) {
+                    g_set_error(
+                        error,
+                        NM_CONNECTION_ERROR,
+                        NM_CONNECTION_ERROR_INVALID_PROPERTY,
+                        _("interface name of software infiniband device must be '%s' or unset "
+                          "(instead it is '%s')"),
+                        virtual_iface_name,
+                        interface_name);
+                } else {
+                    g_set_error(error,
+                                NM_CONNECTION_ERROR,
+                                NM_CONNECTION_ERROR_INVALID_PROPERTY,
+                                _("interface name of software infiniband device with MAC address "
+                                  "must be unset (instead it is '%s')"),
+                                interface_name);
+                }
                 g_prefix_error(error,
                                "%s.%s: ",
                                NM_SETTING_CONNECTION_SETTING_NAME,