aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2013-06-13 03:07:29 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-13 04:20:33 -0400
commit99ffc3e74fb0d9d321d2f19c6021e0dbaff2f4b2 (patch)
treea2ee090e38c77ed35834cc1fbb646f8866b8b234
parent26e04462c8b78d079d3231396ec72d58a14f114b (diff)
macvlan: don't touch promisc without passthrough
commit df8ef8f3aaa6692970a436204c4429210addb23a "macvlan: add FDB bridge ops and macvlan flags" added a way to control NOPROMISC macvlan flag through netlink. However, with a non passthrough device we never set promisc on open, even if NOPROMISC is off. As a result: If userspace clears NOPROMISC on open, then does not clear it on a netlink command, promisc counter is not decremented on stop and there will be no way to clear it once macvlan is detached. If userspace does not clear NOPROMISC on open, then sets NOPROMISC on a netlink command, promisc counter will be decremented from 0 and overflow to fffffffff with no way to clear promisc. To fix, simply ignore NOPROMISC flag in a netlink command for non-passthrough devices, same as we do at open/close. Since we touch this code anyway - check dev_set_promiscuity return code and pass it to users (though an error here is unlikely). Cc: "David S. Miller" <davem@davemloft.net> Reviewed-by: John Fastabend <john.r.fastabend@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/macvlan.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 1c502bb0c916..6e91931a1c2c 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -853,18 +853,24 @@ static int macvlan_changelink(struct net_device *dev,
853 struct nlattr *tb[], struct nlattr *data[]) 853 struct nlattr *tb[], struct nlattr *data[])
854{ 854{
855 struct macvlan_dev *vlan = netdev_priv(dev); 855 struct macvlan_dev *vlan = netdev_priv(dev);
856 if (data && data[IFLA_MACVLAN_MODE]) 856
857 vlan->mode = nla_get_u32(data[IFLA_MACVLAN_MODE]);
858 if (data && data[IFLA_MACVLAN_FLAGS]) { 857 if (data && data[IFLA_MACVLAN_FLAGS]) {
859 __u16 flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]); 858 __u16 flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]);
860 bool promisc = (flags ^ vlan->flags) & MACVLAN_FLAG_NOPROMISC; 859 bool promisc = (flags ^ vlan->flags) & MACVLAN_FLAG_NOPROMISC;
861 860 if (vlan->port->passthru && promisc) {
862 if (promisc && (flags & MACVLAN_FLAG_NOPROMISC)) 861 int err;
863 dev_set_promiscuity(vlan->lowerdev, -1); 862
864 else if (promisc && !(flags & MACVLAN_FLAG_NOPROMISC)) 863 if (flags & MACVLAN_FLAG_NOPROMISC)
865 dev_set_promiscuity(vlan->lowerdev, 1); 864 err = dev_set_promiscuity(vlan->lowerdev, -1);
865 else
866 err = dev_set_promiscuity(vlan->lowerdev, 1);
867 if (err < 0)
868 return err;
869 }
866 vlan->flags = flags; 870 vlan->flags = flags;
867 } 871 }
872 if (data && data[IFLA_MACVLAN_MODE])
873 vlan->mode = nla_get_u32(data[IFLA_MACVLAN_MODE]);
868 return 0; 874 return 0;
869} 875}
870 876