datapath: Fix validation of ODPAT_SET_VLAN_PCP actions.
authorJean Tourrilhes <jt@hpl.hp.com>
Thu, 8 Oct 2009 17:37:43 +0000 (10:37 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 8 Oct 2009 17:41:48 +0000 (10:41 -0700)
The VLAN PCP mask is in the rightmost bits of the vlan_pcp member but we
were checking for it in its position in the VLAN tag field instead.

Slightly modified from Jean's original patch by adding and using the
VLAN_PCP_SHIFT macro.

datapath/datapath.c
datapath/datapath.h

index b0dbe7f..e0b0e2c 100644 (file)
@@ -783,7 +783,8 @@ static int validate_actions(const struct sw_flow_actions *actions)
                        break;
 
                case ODPAT_SET_VLAN_PCP:
-                       if (a->vlan_pcp.vlan_pcp & ~VLAN_PCP_MASK)
+                       if (a->vlan_pcp.vlan_pcp
+                           & ~(VLAN_PCP_MASK >> VLAN_PCP_SHIFT))
                                return -EINVAL;
                        break;
 
index eee1bbf..88bdbc6 100644 (file)
@@ -24,6 +24,7 @@
 /* Mask for the priority bits in a vlan header.  If we ever merge upstream
  * then this should go into include/linux/if_vlan.h. */
 #define VLAN_PCP_MASK 0xe000
+#define VLAN_PCP_SHIFT 13
 
 #define DP_MAX_PORTS 1024
 #define DP_MAX_GROUPS 16