* Validate UDP item. * * @param[in] item * Item specification. * @param[in] item_flags * Bit-fields that holds the items detected until now. * @param[in] target_protocol * The next protocol in the previous item. * @param[in] flow_mask * mlx5 flow-specific (DV, verbs, etc.) supported header fields mask. * @param[out] error * Pointer to error structure. * * @return * 0 on s
| 3079 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 3080 | */ |
| 3081 | int |
| 3082 | mlx5_flow_validate_item_udp(const struct rte_flow_item *item, |
| 3083 | uint64_t item_flags, |
| 3084 | uint8_t target_protocol, |
| 3085 | struct rte_flow_error *error) |
| 3086 | { |
| 3087 | const struct rte_flow_item_udp *mask = item->mask; |
| 3088 | const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); |
| 3089 | const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3 : |
| 3090 | MLX5_FLOW_LAYER_OUTER_L3; |
| 3091 | const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 : |
| 3092 | MLX5_FLOW_LAYER_OUTER_L4; |
| 3093 | int ret; |
| 3094 | |
| 3095 | if (target_protocol != 0xff && target_protocol != IPPROTO_UDP) |
| 3096 | return rte_flow_error_set(error, EINVAL, |
| 3097 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 3098 | "protocol filtering not compatible" |
| 3099 | " with UDP layer"); |
| 3100 | if (!(item_flags & l3m)) |
| 3101 | return rte_flow_error_set(error, EINVAL, |
| 3102 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 3103 | "L3 is mandatory to filter on L4"); |
| 3104 | if (item_flags & l4m) |
| 3105 | return rte_flow_error_set(error, EINVAL, |
| 3106 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 3107 | "multiple L4 layers not supported"); |
| 3108 | if (!mask) |
| 3109 | mask = &rte_flow_item_udp_mask; |
| 3110 | ret = mlx5_flow_item_acceptable |
| 3111 | (item, (const uint8_t *)mask, |
| 3112 | (const uint8_t *)&rte_flow_item_udp_mask, |
| 3113 | sizeof(struct rte_flow_item_udp), MLX5_ITEM_RANGE_NOT_ACCEPTED, |
| 3114 | error); |
| 3115 | if (ret < 0) |
| 3116 | return ret; |
| 3117 | return 0; |
| 3118 | } |
| 3119 | |
| 3120 | /** |
| 3121 | * Validate TCP item. |
no test coverage detected