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

Function mlx5_flow_validate_item_ipv4

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

* Validate IPV4 item. * * @param[in] item * Item specification. * @param[in] item_flags * Bit-fields that holds the items detected until now. * @param[in] last_item * Previous validated item in the pattern items. * @param[in] ether_type * Type in the ethernet layer header (including dot1q). * @param[in] acc_mask * Acceptable mask, if NULL default internal default mask * wil

Source from the content-addressed store, hash-verified

2870 * 0 on success, a negative errno value otherwise and rte_errno is set.
2871 */
2872int
2873mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item,
2874 uint64_t item_flags,
2875 uint64_t last_item,
2876 uint16_t ether_type,
2877 const struct rte_flow_item_ipv4 *acc_mask,
2878 bool range_accepted,
2879 struct rte_flow_error *error)
2880{
2881 const struct rte_flow_item_ipv4 *mask = item->mask;
2882 const struct rte_flow_item_ipv4 *spec = item->spec;
2883 const struct rte_flow_item_ipv4 nic_mask = {
2884 .hdr = {
2885 .src_addr = RTE_BE32(0xffffffff),
2886 .dst_addr = RTE_BE32(0xffffffff),
2887 .type_of_service = 0xff,
2888 .next_proto_id = 0xff,
2889 },
2890 };
2891 const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
2892 const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3 :
2893 MLX5_FLOW_LAYER_OUTER_L3;
2894 const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 :
2895 MLX5_FLOW_LAYER_OUTER_L4;
2896 int ret;
2897 uint8_t next_proto = 0xFF;
2898 const uint64_t l2_vlan = (MLX5_FLOW_LAYER_L2 |
2899 MLX5_FLOW_LAYER_OUTER_VLAN |
2900 MLX5_FLOW_LAYER_INNER_VLAN);
2901
2902 if ((last_item & l2_vlan) && ether_type &&
2903 ether_type != RTE_ETHER_TYPE_IPV4)
2904 return rte_flow_error_set(error, EINVAL,
2905 RTE_FLOW_ERROR_TYPE_ITEM, item,
2906 "IPv4 cannot follow L2/VLAN layer "
2907 "which ether type is not IPv4");
2908 if (item_flags & MLX5_FLOW_LAYER_IPIP) {
2909 if (mask && spec)
2910 next_proto = mask->hdr.next_proto_id &
2911 spec->hdr.next_proto_id;
2912 if (next_proto == IPPROTO_IPIP || next_proto == IPPROTO_IPV6)
2913 return rte_flow_error_set(error, EINVAL,
2914 RTE_FLOW_ERROR_TYPE_ITEM,
2915 item,
2916 "multiple tunnel "
2917 "not supported");
2918 }
2919 if (item_flags & MLX5_FLOW_LAYER_IPV6_ENCAP)
2920 return rte_flow_error_set(error, EINVAL,
2921 RTE_FLOW_ERROR_TYPE_ITEM, item,
2922 "wrong tunnel type - IPv6 specified "
2923 "but IPv4 item provided");
2924 if (item_flags & l3m)
2925 return rte_flow_error_set(error, ENOTSUP,
2926 RTE_FLOW_ERROR_TYPE_ITEM, item,
2927 "multiple L3 layers not supported");
2928 else if (item_flags & l4m)
2929 return rte_flow_error_set(error, EINVAL,

Callers 2

flow_verbs_validateFunction · 0.85

Calls 2

rte_flow_error_setFunction · 0.85

Tested by

no test coverage detected