From fc6b8ba1bf487321090de40b19766a04725b419f Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 14 Apr 2016 18:34:45 +0200 Subject: [PATCH] device/ethernet: ignore s390 'portname' attribute when not set The 'portname' sysfs attribute of s390 devices is deprecated since kernel 4.4 and always set to 'no portname required'. But even on older kernels such value must be interpreted as an unset portname and thus ignored. https://bugzilla.redhat.com/show_bug.cgi?id=1327204 (cherry picked from commit 0589e659ca1aab76be9ca11e705bef56c3b03f45) --- src/devices/nm-device-ethernet.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 7f950dd648..2eb622cf5d 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -200,16 +200,21 @@ _update_s390_subchannels (NMDeviceEthernet *self) } else if ( !strcmp (item, "layer2") || !strcmp (item, "portname") || !strcmp (item, "portno")) { - char *path, *value; + gs_free char *path = NULL, *value = NULL; + path = g_strdup_printf ("%s/%s", parent_path, item); value = nm_platform_sysctl_get (NM_PLATFORM_GET, path); - if (value && *value) - g_hash_table_insert (priv->s390_options, g_strdup (item), g_strdup (value)); - else + + if ( !strcmp (item, "portname") + && !g_strcmp0 (value, "no portname required")) { + /* Do nothing */ + } else if (value && *value) { + g_hash_table_insert (priv->s390_options, g_strdup (item), value); + value = NULL; + } else _LOGW (LOGD_DEVICE | LOGD_HW, "error reading %s", path); - g_free (path); - g_free (value); } + if (error) { _LOGW (LOGD_DEVICE | LOGD_HW, "%s", error->message); g_clear_error (&error);