* Make as much checks as possible on an IPv6 item, and if a flow is provided, * fill it appropriately with IPv6 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. */
| 685 | * 0 if checks are alright, -1 otherwise. |
| 686 | */ |
| 687 | static int |
| 688 | tap_flow_create_ipv6(const struct rte_flow_item *item, void *data) |
| 689 | { |
| 690 | struct convert_data *info = (struct convert_data *)data; |
| 691 | const struct rte_flow_item_ipv6 *spec = item->spec; |
| 692 | const struct rte_flow_item_ipv6 *mask = item->mask; |
| 693 | struct rte_flow *flow = info->flow; |
| 694 | uint8_t empty_addr[16] = { 0 }; |
| 695 | struct nlmsg *msg; |
| 696 | |
| 697 | /* use default mask if none provided */ |
| 698 | if (!mask) |
| 699 | mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_IPV6].default_mask; |
| 700 | /* check that previous eth type is compatible with ipv6 */ |
| 701 | if (info->eth_type && info->eth_type != htons(ETH_P_IPV6)) |
| 702 | return -1; |
| 703 | /* store ip_proto for consistency if udp/tcp pattern item comes next */ |
| 704 | if (spec) |
| 705 | info->ip_proto = spec->hdr.proto; |
| 706 | if (!flow) |
| 707 | return 0; |
| 708 | msg = &flow->msg; |
| 709 | if (!info->eth_type) |
| 710 | info->eth_type = htons(ETH_P_IPV6); |
| 711 | if (!spec) |
| 712 | return 0; |
| 713 | if (memcmp(mask->hdr.dst_addr, empty_addr, 16)) { |
| 714 | tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST, |
| 715 | sizeof(spec->hdr.dst_addr), &spec->hdr.dst_addr); |
| 716 | tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST_MASK, |
| 717 | sizeof(mask->hdr.dst_addr), &mask->hdr.dst_addr); |
| 718 | } |
| 719 | if (memcmp(mask->hdr.src_addr, empty_addr, 16)) { |
| 720 | tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC, |
| 721 | sizeof(spec->hdr.src_addr), &spec->hdr.src_addr); |
| 722 | tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC_MASK, |
| 723 | sizeof(mask->hdr.src_addr), &mask->hdr.src_addr); |
| 724 | } |
| 725 | if (spec->hdr.proto) |
| 726 | tap_nlattr_add8(&msg->nh, |
| 727 | TCA_FLOWER_KEY_IP_PROTO, spec->hdr.proto); |
| 728 | return 0; |
| 729 | } |
| 730 | |
| 731 | /** |
| 732 | * Make as much checks as possible on a UDP item, and if a flow is provided, |
nothing calls this directly
no test coverage detected