[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190221175436.10767-1-sthemmin@microsoft.com>
Date: Thu, 21 Feb 2019 09:54:36 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: Moshe Shemesh <moshe@...lanox.com>
Cc: netdev@...r.kernel.org, Stephen Hemminger <sthemmin@...rosoft.com>,
Stephen Hemminger <stephen@...workplumber.org>
Subject: [RFC] rtnetlink: handle multiple vlan tags in set_vf_vlan
The netlink API for IFLA_VF_VLAN_LIST allows multiple VLAN tags to
be passed (and the message was validated) but only the first VLAN
tag was being passed to the device. Change to iterate over each tag received.
Fixes: 79aab093a0b5 ("net: Update API for VF vlan protocol 802.1ad support")
Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
net/core/rtnetlink.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a51cab95ba64..3a9ec988ae21 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2207,11 +2207,10 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
if (tb[IFLA_VF_VLAN_LIST]) {
struct ifla_vf_vlan_info *ivvl[MAX_VLAN_LIST_LEN];
struct nlattr *attr;
- int rem, len = 0;
+ int i, rem, len = 0;
- err = -EOPNOTSUPP;
if (!ops->ndo_set_vf_vlan)
- return err;
+ return -EOPNOTSUPP;
nla_for_each_nested(attr, tb[IFLA_VF_VLAN_LIST], rem) {
if (nla_type(attr) != IFLA_VF_VLAN_INFO ||
@@ -2224,13 +2223,15 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
len++;
}
- if (len == 0)
- return -EINVAL;
- err = ops->ndo_set_vf_vlan(dev, ivvl[0]->vf, ivvl[0]->vlan,
- ivvl[0]->qos, ivvl[0]->vlan_proto);
- if (err < 0)
- return err;
+ err = -EINVAL; /* empty list error */
+ for (i = 0; i < len; i++) {
+ err = ops->ndo_set_vf_vlan(dev, ivvl[i]->vf,
+ ivvl[i]->vlan, ivvl[i]->qos,
+ ivvl[i]->vlan_proto);
+ if (err < 0)
+ return err;
+ }
}
if (tb[IFLA_VF_TX_RATE]) {
--
2.17.1
Powered by blists - more mailing lists