Subject: Re: [PATCH 07/12] flow_dissector: Parse vxlan in UDP

From: Simon Horman <[email-masked]>
Date: Thu, 1 Aug 2024 19:22:28 +0100

On Wed, Jul 31, 2024 at 10:23:27AM -0700, Tom Herbert wrote:
> Parse vxlan in a UDP encapsulation
> 
> Signed-off-by: Tom Herbert <[email-masked]>
> ---
>  net/core/flow_dissector.c | 57 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 57 insertions(+)
> 
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c

...

> @@ -756,6 +758,55 @@ __skb_flow_dissect_gre(const struct sk_buff *skb,
>  	return FLOW_DISSECT_RET_PROTO_AGAIN;
>  }
>  
> +static enum flow_dissect_ret
> +__skb_flow_dissect_vxlan(const struct sk_buff *skb,
> +			 struct flow_dissector *flow_dissector,
> +			 void *target_container, const void *data,
> +			 __be16 *p_proto, int *p_nhoff, int hlen,
> +			 unsigned int flags)
> +{
> +	struct vxlanhdr *hdr, _hdr;
> +	__be16 protocol;
> +
> +	hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), data, hlen,
> +				   &_hdr);
> +	if (!hdr)
> +		return FLOW_DISSECT_RET_OUT_BAD;
> +
> +	/* VNI flag always required to be set */
> +	if (!(hdr->vx_flags & VXLAN_HF_VNI))
> +		return FLOW_DISSECT_RET_OUT_BAD;
> +
> +	if (hdr->vx_flags & VXLAN_F_GPE) {

Hi Tom,

Sparse flags an byte-order miss match on the line above.
I expect this would resolve it (completely untested!):

	if (hdr->vx_flags & cpu_to_be32(VXLAN_F_GPE))

...