* Make as much checks as possible on a UDP item, and if a flow is provided, * fill it appropriately with UDP 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. */
| 741 | * 0 if checks are alright, -1 otherwise. |
| 742 | */ |
| 743 | static int |
| 744 | tap_flow_create_udp(const struct rte_flow_item *item, void *data) |
| 745 | { |
| 746 | struct convert_data *info = (struct convert_data *)data; |
| 747 | const struct rte_flow_item_udp *spec = item->spec; |
| 748 | const struct rte_flow_item_udp *mask = item->mask; |
| 749 | struct rte_flow *flow = info->flow; |
| 750 | struct nlmsg *msg; |
| 751 | |
| 752 | /* use default mask if none provided */ |
| 753 | if (!mask) |
| 754 | mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_UDP].default_mask; |
| 755 | /* check that previous ip_proto is compatible with udp */ |
| 756 | if (info->ip_proto && info->ip_proto != IPPROTO_UDP) |
| 757 | return -1; |
| 758 | /* TC does not support UDP port masking. Only accept if exact match. */ |
| 759 | if ((mask->hdr.src_port && mask->hdr.src_port != 0xffff) || |
| 760 | (mask->hdr.dst_port && mask->hdr.dst_port != 0xffff)) |
| 761 | return -1; |
| 762 | if (!flow) |
| 763 | return 0; |
| 764 | msg = &flow->msg; |
| 765 | tap_nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, IPPROTO_UDP); |
| 766 | if (!spec) |
| 767 | return 0; |
| 768 | if (mask->hdr.dst_port) |
| 769 | tap_nlattr_add16(&msg->nh, TCA_FLOWER_KEY_UDP_DST, |
| 770 | spec->hdr.dst_port); |
| 771 | if (mask->hdr.src_port) |
| 772 | tap_nlattr_add16(&msg->nh, TCA_FLOWER_KEY_UDP_SRC, |
| 773 | spec->hdr.src_port); |
| 774 | return 0; |
| 775 | } |
| 776 | |
| 777 | /** |
| 778 | * Make as much checks as possible on a TCP item, and if a flow is provided, |
nothing calls this directly
no test coverage detected