According to the documentation, the function
priv_set_flags(priv, keep, flags) should not modify the flags
in "keep" mask.

So 'flags' argument should be masked with '~keep' before ORing
it with the previous flags value.

This avoids to mess the kernel interface flags when calling
priv_set_flags(priv, ~IFF_UP, ~IFF_UP) in priv_set_link():

  $ ip link
  26: eth0: BROADCAST,MULTICAST,NOARP,ALLMULTI,PROMISC,DEBUG,\
      DYNAMIC,AUTOMEDIA,PORTSEL,NOTRAILERS

Fixes: 7fae69eeff13 ("mlx4: new poll mode driver")
Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 
adapters")

Reported-by: Fengtian Guo <fengtian.guo at 6wind.com>
Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
---
 drivers/net/mlx4/mlx4.c        | 2 +-
 drivers/net/mlx5/mlx5_ethdev.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index f8ed42b..1dd14f4 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -689,7 +689,7 @@ priv_set_flags(struct priv *priv, unsigned int keep, 
unsigned int flags)
        if (priv_get_sysfs_ulong(priv, "flags", &tmp) == -1)
                return -1;
        tmp &= keep;
-       tmp |= flags;
+       tmp |= (flags & (~keep));
        return priv_set_sysfs_ulong(priv, "flags", tmp);
 }

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 0e7ed01..6fef902 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -461,7 +461,7 @@ priv_set_flags(struct priv *priv, unsigned int keep, 
unsigned int flags)
        if (priv_get_sysfs_ulong(priv, "flags", &tmp) == -1)
                return -1;
        tmp &= keep;
-       tmp |= flags;
+       tmp |= (flags & (~keep));
        return priv_set_sysfs_ulong(priv, "flags", tmp);
 }

-- 
2.8.1

Reply via email to