* Make as much checks as possible on an IPv4 item, and if a flow is provided, * fill it appropriately with IPv4 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. */
| 630 | * 0 if checks are alright, -1 otherwise. |
| 631 | */ |
| 632 | static int |
| 633 | tap_flow_create_ipv4(const struct rte_flow_item *item, void *data) |
| 634 | { |
| 635 | struct convert_data *info = (struct convert_data *)data; |
| 636 | const struct rte_flow_item_ipv4 *spec = item->spec; |
| 637 | const struct rte_flow_item_ipv4 *mask = item->mask; |
| 638 | struct rte_flow *flow = info->flow; |
| 639 | struct nlmsg *msg; |
| 640 | |
| 641 | /* use default mask if none provided */ |
| 642 | if (!mask) |
| 643 | mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_IPV4].default_mask; |
| 644 | /* check that previous eth type is compatible with ipv4 */ |
| 645 | if (info->eth_type && info->eth_type != htons(ETH_P_IP)) |
| 646 | return -1; |
| 647 | /* store ip_proto for consistency if udp/tcp pattern item comes next */ |
| 648 | if (spec) |
| 649 | info->ip_proto = spec->hdr.next_proto_id; |
| 650 | if (!flow) |
| 651 | return 0; |
| 652 | msg = &flow->msg; |
| 653 | if (!info->eth_type) |
| 654 | info->eth_type = htons(ETH_P_IP); |
| 655 | if (!spec) |
| 656 | return 0; |
| 657 | if (mask->hdr.dst_addr) { |
| 658 | tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST, |
| 659 | spec->hdr.dst_addr); |
| 660 | tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST_MASK, |
| 661 | mask->hdr.dst_addr); |
| 662 | } |
| 663 | if (mask->hdr.src_addr) { |
| 664 | tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC, |
| 665 | spec->hdr.src_addr); |
| 666 | tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC_MASK, |
| 667 | mask->hdr.src_addr); |
| 668 | } |
| 669 | if (spec->hdr.next_proto_id) |
| 670 | tap_nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, |
| 671 | spec->hdr.next_proto_id); |
| 672 | return 0; |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * Make as much checks as possible on an IPv6 item, and if a flow is provided, |
nothing calls this directly
no test coverage detected