[ovs-dev] [PATCH 01/16] dpif-netdev: Fix validation of VLAN PCP value in userspace datapath.

Ben Pfaff blp at nicira.com
Thu Feb 11 15:18:03 PST 2010


Reported-by: Jean Tourrilhes <jt at hpl.hp.com>
---
 lib/dpif-netdev.c |    2 +-
 lib/packets.h     |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index e9f006c..1daa93b 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -752,7 +752,7 @@ dpif_netdev_validate_actions(const union odp_action *actions, int n_actions,
 
 		case ODPAT_SET_VLAN_PCP:
             *mutates = true;
-			if (a->vlan_pcp.vlan_pcp & ~VLAN_PCP_MASK) {
+			if (a->vlan_pcp.vlan_pcp & ~(VLAN_PCP_MASK >> VLAN_PCP_SHIFT)) {
 				return EINVAL;
             }
 			break;
diff --git a/lib/packets.h b/lib/packets.h
index 2c33078..f0ccfdb 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -179,7 +179,10 @@ struct llc_snap_header {
 BUILD_ASSERT_DECL(LLC_SNAP_HEADER_LEN == sizeof(struct llc_snap_header));
 
 #define VLAN_VID_MASK 0x0fff
+#define VLAN_VID_SHIFT 0
+
 #define VLAN_PCP_MASK 0xe000
+#define VLAN_PCP_SHIFT 13
 
 #define VLAN_HEADER_LEN 4
 struct vlan_header {
-- 
1.6.6.1





More information about the dev mailing list