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 b0dbe7fc23604b449a992e067278b3713fc2a2b3..e0b0e2c26d861ee541face2b094e5f1df73b65e9 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 eee1bbfc585f1cf38aef4fca9f230077365518ab..88bdbc65784f812d7fdb1e253e8dd80e7ce572e6 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