-static void
-dp_netdev_modify_vlan_tci(struct ofpbuf *packet, flow_t *key,
- uint16_t tci, uint16_t mask)
-{
- struct vlan_eth_header *veh;
-
- if (key->dl_vlan != htons(ODP_VLAN_NONE)) {
- /* Modify 'mask' bits, but maintain other TCI bits. */
- veh = packet->l2;
- veh->veth_tci &= ~htons(mask);
- veh->veth_tci |= htons(tci);
- } else {
- /* Insert new 802.1Q header. */
- struct eth_header *eh = packet->l2;
- struct vlan_eth_header tmp;
- memcpy(tmp.veth_dst, eh->eth_dst, ETH_ADDR_LEN);
- memcpy(tmp.veth_src, eh->eth_src, ETH_ADDR_LEN);
- tmp.veth_type = htons(ETH_TYPE_VLAN);
- tmp.veth_tci = htons(tci);
- tmp.veth_next_type = eh->eth_type;
-
- veh = ofpbuf_push_uninit(packet, VLAN_HEADER_LEN);
- memcpy(veh, &tmp, sizeof tmp);
- packet->l2 = (char*)packet->l2 - VLAN_HEADER_LEN;
- }
-
- key->dl_vlan = veh->veth_tci & htons(VLAN_VID_MASK);
-}