summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-12-04 14:09:50 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2018-12-12 14:20:32 +0100
commitef39721d60dac86b876040b710eda4c3d5064ecd (patch)
tree51158fcc06b5f20fda76caeca53f1d2c75dbc6b7
parentd48f389cbf6a24f6e58f1422e5b5a8a8d649c973 (diff)
downloadNetworkManager-ef39721d60dac86b876040b710eda4c3d5064ecd.tar.gz
core: use NMTernary for SR-IOV autoprobe-drivers
Fixes: 53c2951f61fa9a11efeb36bbebff88e62297ea15
-rw-r--r--src/devices/nm-device.c6
-rw-r--r--src/platform/nm-linux-platform.c10
-rw-r--r--src/platform/nm-platform.c9
3 files changed, 12 insertions, 13 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index e402857244..87d168b3e7 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -4227,7 +4227,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);
}
}
}
@@ -6294,7 +6294,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) {
@@ -14934,7 +14934,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 82f872f54e..4189176f9e 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 e119707009..f41517bd41 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -1468,21 +1468,20 @@ 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);
- _LOG3D ("link: setting %u total VFs and autoprobe %d", num_vfs, autoprobe);
+ _LOG3D ("link: setting %u total VFs and autoprobe %d", num_vfs, (int) autoprobe);
return klass->link_set_sriov_params (self, ifindex, num_vfs, autoprobe);
}