X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fdpif-netdev.c;h=e19cb34a272076c576b02674a1a0c37204a6cd39;hb=b09d5ec96a32c906bb35770937120401f64e90b7;hp=ca5e8eb25c22c393f51ee966e8b1cf80bde56bec;hpb=f1193301162788fadc0f6faa1af9441f93a623d8;p=openvswitch diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index ca5e8eb2..e19cb34a 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -22,8 +22,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -751,7 +751,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; @@ -1080,6 +1080,15 @@ dp_netdev_wait(void) } } + +/* Modify the TCI field of 'packet'. If a VLAN tag is not present, one + * is added with the TCI field set to 'tci'. If a VLAN tag is present, + * then 'mask' bits are cleared before 'tci' is logically OR'd into the + * TCI field. + * + * Note that the function does not ensure that 'tci' does not affect + * bits outside of 'mask'. + */ static void dp_netdev_modify_vlan_tci(struct ofpbuf *packet, flow_t *key, uint16_t tci, uint16_t mask) @@ -1087,7 +1096,7 @@ dp_netdev_modify_vlan_tci(struct ofpbuf *packet, flow_t *key, struct vlan_eth_header *veh; if (key->dl_vlan != htons(ODP_VLAN_NONE)) { - /* Modify 'mask' bits, but maintain other TCI bits. */ + /* Clear 'mask' bits, but maintain other TCI bits. */ veh = packet->l2; veh->veth_tci &= ~htons(mask); veh->veth_tci |= htons(tci); @@ -1290,8 +1299,9 @@ dp_netdev_execute_actions(struct dp_netdev *dp, break; case ODPAT_SET_VLAN_PCP: - dp_netdev_modify_vlan_tci(packet, key, a->vlan_pcp.vlan_pcp << 13, - VLAN_PCP_MASK); + dp_netdev_modify_vlan_tci( + packet, key, a->vlan_pcp.vlan_pcp << VLAN_PCP_SHIFT, + VLAN_PCP_MASK); break; case ODPAT_STRIP_VLAN: