* Make as much checks as possible on a VLAN item, and if a flow is provided, * fill it appropriately with VLAN info. * * @param[in] item * Item specification. * @param[in, out] data * Additional data structure to tell next layers we've been here. * * @return * 0 if checks are alright, -1 otherwise. */
| 570 | * 0 if checks are alright, -1 otherwise. |
| 571 | */ |
| 572 | static int |
| 573 | tap_flow_create_vlan(const struct rte_flow_item *item, void *data) |
| 574 | { |
| 575 | struct convert_data *info = (struct convert_data *)data; |
| 576 | const struct rte_flow_item_vlan *spec = item->spec; |
| 577 | const struct rte_flow_item_vlan *mask = item->mask; |
| 578 | struct rte_flow *flow = info->flow; |
| 579 | struct nlmsg *msg; |
| 580 | |
| 581 | /* use default mask if none provided */ |
| 582 | if (!mask) |
| 583 | mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_VLAN].default_mask; |
| 584 | /* Outer TPID cannot be matched. */ |
| 585 | if (info->eth_type) |
| 586 | return -1; |
| 587 | /* Double-tagging not supported. */ |
| 588 | if (info->vlan) |
| 589 | return -1; |
| 590 | info->vlan = 1; |
| 591 | if (mask->hdr.eth_proto) { |
| 592 | /* TC does not support partial eth_type masking */ |
| 593 | if (mask->hdr.eth_proto != RTE_BE16(0xffff)) |
| 594 | return -1; |
| 595 | info->eth_type = spec->hdr.eth_proto; |
| 596 | } |
| 597 | if (!flow) |
| 598 | return 0; |
| 599 | msg = &flow->msg; |
| 600 | msg->t.tcm_info = TC_H_MAKE(msg->t.tcm_info, htons(ETH_P_8021Q)); |
| 601 | #define VLAN_PRIO(tci) ((tci) >> 13) |
| 602 | #define VLAN_ID(tci) ((tci) & 0xfff) |
| 603 | if (!spec) |
| 604 | return 0; |
| 605 | if (spec->hdr.vlan_tci) { |
| 606 | uint16_t tci = ntohs(spec->hdr.vlan_tci) & mask->hdr.vlan_tci; |
| 607 | uint16_t prio = VLAN_PRIO(tci); |
| 608 | uint8_t vid = VLAN_ID(tci); |
| 609 | |
| 610 | if (prio) |
| 611 | tap_nlattr_add8(&msg->nh, |
| 612 | TCA_FLOWER_KEY_VLAN_PRIO, prio); |
| 613 | if (vid) |
| 614 | tap_nlattr_add16(&msg->nh, |
| 615 | TCA_FLOWER_KEY_VLAN_ID, vid); |
| 616 | } |
| 617 | return 0; |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Make as much checks as possible on an IPv4 item, and if a flow is provided, |
nothing calls this directly
no test coverage detected