From 9ff5e3b2a6e40f265623e6b341bf901bfe5774e1 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 4 Dec 2018 14:09:50 +0100 Subject: [PATCH] core: use NMTernary for SR-IOV autoprobe-drivers (cherry picked from commit e01a7c1154e0a580f09b76e7735448c54224b2e8) --- src/devices/nm-device.c | 6 +++--- src/platform/nm-linux-platform.c | 10 +++++----- src/platform/nm-platform.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 3527794171..52167b7852 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4140,7 +4140,7 @@ device_init_static_sriov_num_vfs (NMDevice *self) num_vfs = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT32, -1); if (num_vfs >= 0) { nm_platform_link_set_sriov_params (nm_device_get_platform (self), - priv->ifindex, num_vfs, -1); + priv->ifindex, num_vfs, NM_TERNARY_DEFAULT); } } } @@ -6206,7 +6206,7 @@ act_stage1_prepare (NMDevice *self, NMDeviceStateReason *out_failure_reason) nm_auto_freev NMPlatformVF **plat_vfs = NULL; gs_free_error GError *error = NULL; NMSriovVF *vf; - int autoprobe; + NMTernary autoprobe; autoprobe = nm_setting_sriov_get_autoprobe_drivers (s_sriov); if (autoprobe == NM_TERNARY_DEFAULT) { @@ -14766,7 +14766,7 @@ _set_state_full (NMDevice *self, if ( (s_sriov = nm_device_get_applied_setting (self, NM_TYPE_SETTING_SRIOV)) && priv->ifindex > 0) { nm_platform_link_set_sriov_params (nm_device_get_platform (self), - priv->ifindex, 0, 1); + priv->ifindex, 0, NM_TERNARY_TRUE); } _cancel_activation (self); diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index e73d5d8c3d..3283338bf7 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -5737,7 +5737,7 @@ static gboolean link_set_sriov_params (NMPlatform *platform, int ifindex, guint num_vfs, - int autoprobe) + NMTernary autoprobe) { nm_auto_pop_netns NMPNetns *netns = NULL; nm_auto_close int dirfd = -1; @@ -5782,7 +5782,7 @@ link_set_sriov_params (NMPlatform *platform, "device/sriov_drivers_autoprobe"), 10, 0, G_MAXUINT, 0); if ( current_num == num_vfs - && (autoprobe == -1 || current_autoprobe == autoprobe)) + && (autoprobe == NM_TERNARY_DEFAULT || current_autoprobe == autoprobe)) return TRUE; if (current_num != 0) { @@ -5800,14 +5800,14 @@ link_set_sriov_params (NMPlatform *platform, if (num_vfs == 0) return TRUE; - if ( autoprobe >= 0 + if ( NM_IN_SET (autoprobe, NM_TERNARY_TRUE, NM_TERNARY_FALSE) && current_autoprobe != autoprobe && !nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "device/sriov_drivers_autoprobe"), - nm_sprintf_buf (buf, "%d", autoprobe))) { - _LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", autoprobe, strerror (errno)); + nm_sprintf_buf (buf, "%d", (int) autoprobe))) { + _LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, strerror (errno)); return FALSE; } diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index e5a42030b9..757a0f43d8 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -1489,25 +1489,25 @@ nm_platform_link_supports_sriov (NMPlatform *self, int ifindex) * @self: platform instance * @ifindex: the index of the interface to change * @num_vfs: the number of VFs to create - * @autoprobe: -1 to keep the current autoprobe-drivers value, - * or {0,1} to set a new value + * @autoprobe: the new autoprobe-drivers value (pass + * %NM_TERNARY_DEFAULT to keep current value) */ gboolean nm_platform_link_set_sriov_params (NMPlatform *self, int ifindex, guint num_vfs, - int autoprobe) + NMTernary autoprobe) { _CHECK_SELF (self, klass, FALSE); g_return_val_if_fail (ifindex > 0, FALSE); - g_return_val_if_fail (NM_IN_SET (autoprobe, -1, 0, 1), FALSE); _LOGD ("link: setting %u total VFs and autoprobe %d for %s (%d)", num_vfs, - autoprobe, + (int) autoprobe, nm_strquote_a (25, nm_platform_link_get_name (self, ifindex)), ifindex); + return klass->link_set_sriov_params (self, ifindex, num_vfs, autoprobe); }