net/mlx: ensure MTU update is effective

There is no guarantee that the new MTU is effective after writing its value
to sysfs. Retrieve it to be sure.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
This commit is contained in:
Adrien Mazarguil 2016-06-08 11:43:26 +02:00 committed by Bruce Richardson
parent 6e0eab3802
commit f3b492d7b4
2 changed files with 18 additions and 2 deletions

View File

@ -658,7 +658,15 @@ priv_get_mtu(struct priv *priv, uint16_t *mtu)
static int
priv_set_mtu(struct priv *priv, uint16_t mtu)
{
return priv_set_sysfs_ulong(priv, "mtu", mtu);
uint16_t new_mtu;
if (priv_set_sysfs_ulong(priv, "mtu", mtu) ||
priv_get_mtu(priv, &new_mtu))
return -1;
if (new_mtu == mtu)
return 0;
errno = EINVAL;
return -1;
}
/**

View File

@ -397,7 +397,15 @@ priv_get_mtu(struct priv *priv, uint16_t *mtu)
static int
priv_set_mtu(struct priv *priv, uint16_t mtu)
{
return priv_set_sysfs_ulong(priv, "mtu", mtu);
uint16_t new_mtu;
if (priv_set_sysfs_ulong(priv, "mtu", mtu) ||
priv_get_mtu(priv, &new_mtu))
return -1;
if (new_mtu == mtu)
return 0;
errno = EINVAL;
return -1;
}
/**