MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_flow_validate_item_tcp

Function mlx5_flow_validate_item_tcp

dpdk/drivers/net/mlx5/mlx5_flow.c:3135–3174  ·  view source on GitHub ↗

* Validate TCP 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[out] error * Pointer to error structure. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

3133 * 0 on success, a negative errno value otherwise and rte_errno is set.
3134 */
3135int
3136mlx5_flow_validate_item_tcp(const struct rte_flow_item *item,
3137 uint64_t item_flags,
3138 uint8_t target_protocol,
3139 const struct rte_flow_item_tcp *flow_mask,
3140 struct rte_flow_error *error)
3141{
3142 const struct rte_flow_item_tcp *mask = item->mask;
3143 const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
3144 const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3 :
3145 MLX5_FLOW_LAYER_OUTER_L3;
3146 const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 :
3147 MLX5_FLOW_LAYER_OUTER_L4;
3148 int ret;
3149
3150 MLX5_ASSERT(flow_mask);
3151 if (target_protocol != 0xff && target_protocol != IPPROTO_TCP)
3152 return rte_flow_error_set(error, EINVAL,
3153 RTE_FLOW_ERROR_TYPE_ITEM, item,
3154 "protocol filtering not compatible"
3155 " with TCP layer");
3156 if (!(item_flags & l3m))
3157 return rte_flow_error_set(error, EINVAL,
3158 RTE_FLOW_ERROR_TYPE_ITEM, item,
3159 "L3 is mandatory to filter on L4");
3160 if (item_flags & l4m)
3161 return rte_flow_error_set(error, EINVAL,
3162 RTE_FLOW_ERROR_TYPE_ITEM, item,
3163 "multiple L4 layers not supported");
3164 if (!mask)
3165 mask = &rte_flow_item_tcp_mask;
3166 ret = mlx5_flow_item_acceptable
3167 (item, (const uint8_t *)mask,
3168 (const uint8_t *)flow_mask,
3169 sizeof(struct rte_flow_item_tcp), MLX5_ITEM_RANGE_NOT_ACCEPTED,
3170 error);
3171 if (ret < 0)
3172 return ret;
3173 return 0;
3174}
3175
3176/**
3177 * Validate VXLAN item.

Callers 2

flow_dv_validateFunction · 0.85
flow_verbs_validateFunction · 0.85

Calls 2

rte_flow_error_setFunction · 0.85

Tested by

no test coverage detected