Re: [PATCH net-next v2 07/12] net: vxlan: add skb drop reasons to vxlan_rcv()

From: Alexander Lobakin
Date: Fri Aug 30 2024 - 11:05:02 EST


From: Menglong Dong <menglong8.dong@xxxxxxxxx>
Date: Fri, 30 Aug 2024 09:59:56 +0800

> Introduce skb drop reasons to the function vxlan_rcv(). Following new
> vxlan drop reasons are added:
>
> VXLAN_DROP_INVALID_HDR
> VXLAN_DROP_VNI_NOT_FOUND
>
> And Following core skb drop reason is added:

"the following", lowercase + "the".

>
> SKB_DROP_REASON_IP_TUNNEL_ECN
>
> Signed-off-by: Menglong Dong <dongml2@xxxxxxxxxxxxxxx>

[...]

> @@ -23,6 +25,14 @@ enum vxlan_drop_reason {
> * one pointing to a nexthop
> */
> VXLAN_DROP_ENTRY_EXISTS,
> + /**
> + * @VXLAN_DROP_INVALID_HDR: the vxlan header is invalid, such as:

Same as before, "VXLAN" in uppercase I'd say.

> + * 1) the reserved fields are not zero
> + * 2) the "I" flag is not set
> + */
> + VXLAN_DROP_INVALID_HDR,
> + /** @VXLAN_DROP_VNI_NOT_FOUND: no vxlan device found for the vni */

^

> + VXLAN_DROP_VNI_NOT_FOUND,
> };

[...]

> if (!raw_proto) {
> - if (!vxlan_set_mac(vxlan, vs, skb, vni))
> + reason = vxlan_set_mac(vxlan, vs, skb, vni);
> + if (reason)
> goto drop;

This piece must go in the previous patch, see my comment there.

[...]

> @@ -1814,8 +1830,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
> return 0;
>
> drop:
> + reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;

Is this possible that @reason will be 0 (NOT_DROPPED_YET) here? At the
beginning of the function, it's not initialized, then each error path
sets it to a specific value. In most paths, you check for it being != 0
as a sign of error, so I doubt it can be 0 here.

> /* Consume bad packet */
> - kfree_skb(skb);
> + kfree_skb_reason(skb, reason);
> return 0;
> }

Thanks,
Olek