Patchwork [net-next,V1,04/10] net/mlx4_en: Validate VLAN IDs provided in ethtool flow steering rules

login
register
mail settings
Submitter Amir Vadai
Date Jan. 31, 2013, 9:07 a.m.
Message ID <1359623231-4491-5-git-send-email-amirv@mellanox.com>
Download mbox | patch
Permalink /patch/217133/
State Accepted
Delegated to: David Miller
Headers show

Comments

Amir Vadai - Jan. 31, 2013, 9:07 a.m.
From: Hadar Hen Zion <hadarh@mellanox.com>

When attaching flow steering rules via Ethtool accept only valid vlans IDs e.g
in the range: [0,4095].

Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 86afb5b..f33049f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -669,6 +669,10 @@  static int mlx4_en_validate_flow(struct net_device *dev,
 		    !(cmd->fs.m_ext.vlan_tci == 0 ||
 		      cmd->fs.m_ext.vlan_tci == cpu_to_be16(0xfff)))
 			return -EINVAL;
+		if (cmd->fs.m_ext.vlan_tci) {
+			if (be16_to_cpu(cmd->fs.h_ext.vlan_tci) >= VLAN_N_VID)
+				return -EINVAL;
+		}
 	}
 
 	return 0;