diff options
author | Nikolay Aleksandrov <nikolay@cumulusnetworks.com> | 2015-10-12 08:31:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-13 07:43:24 -0400 |
commit | 87aaf2caed8496404d3809edc30d38d4a4a5d273 (patch) | |
tree | ed9ac3f950aca975ce8fc23c8b8fa047d41d05c6 /net/switchdev/switchdev.c | |
parent | 1f225031fee6c39cbbf2a6c79cb150ff63f0556c (diff) |
switchdev: check if the vlan id is in the proper vlan range
VLANs 0 and 4095 are reserved and shouldn't be used, add checks to
switchdev similar to the bridge. Also make sure ids above 4095 cannot
be passed either.
Fixes: 47f8328bb1a4 ("switchdev: add new switchdev bridge setlink")
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Acked-by: Scott Feldman <sfeldma@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/switchdev/switchdev.c')
-rw-r--r-- | net/switchdev/switchdev.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index fda38f830a10..77f5d17e2612 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/notifier.h> | 16 | #include <linux/notifier.h> |
17 | #include <linux/netdevice.h> | 17 | #include <linux/netdevice.h> |
18 | #include <linux/if_bridge.h> | 18 | #include <linux/if_bridge.h> |
19 | #include <linux/if_vlan.h> | ||
19 | #include <net/ip_fib.h> | 20 | #include <net/ip_fib.h> |
20 | #include <net/switchdev.h> | 21 | #include <net/switchdev.h> |
21 | 22 | ||
@@ -634,6 +635,8 @@ static int switchdev_port_br_afspec(struct net_device *dev, | |||
634 | if (nla_len(attr) != sizeof(struct bridge_vlan_info)) | 635 | if (nla_len(attr) != sizeof(struct bridge_vlan_info)) |
635 | return -EINVAL; | 636 | return -EINVAL; |
636 | vinfo = nla_data(attr); | 637 | vinfo = nla_data(attr); |
638 | if (!vinfo->vid || vinfo->vid >= VLAN_VID_MASK) | ||
639 | return -EINVAL; | ||
637 | vlan->flags = vinfo->flags; | 640 | vlan->flags = vinfo->flags; |
638 | if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { | 641 | if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { |
639 | if (vlan->vid_begin) | 642 | if (vlan->vid_begin) |