Re: [PATCH net-next 06/10] net: vxlan: add skb drop reasons to vxlan_rcv()
From: Jakub Kicinski <kuba@kernel.org>
Date: 2024-08-17 02:22:45
Also in:
lkml
On Thu, 15 Aug 2024 20:42:58 +0800 Menglong Dong wrote:
#define VXLAN_DROP_REASONS(R) \ + R(VXLAN_DROP_FLAGS) \ + R(VXLAN_DROP_VNI) \ + R(VXLAN_DROP_MAC) \
Drop reasons should be documented. I don't think name of a header field is a great fit for a reason.
quoted hunk ↗ jump to hunk
/* deliberate comment for trailing \ */ enum vxlan_drop_reason {diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index e971c4785962..9a61f04bb95d 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c@@ -1668,6 +1668,7 @@ static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph, /* Callback from net/ipv4/udp.c to receive packets */ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) { + enum skb_drop_reason reason = pskb_may_pull_reason(skb, VXLAN_HLEN);
Do not call complex functions inline as variable init..
quoted hunk ↗ jump to hunk
struct vxlan_vni_node *vninode = NULL; struct vxlan_dev *vxlan; struct vxlan_sock *vs;@@ -1681,7 +1682,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) int nh; /* Need UDP and VXLAN header to be present */ - if (!pskb_may_pull(skb, VXLAN_HLEN)) + if (reason != SKB_NOT_DROPPED_YET)
please don't compare against "not dropped yet", just: if (reason)
quoted hunk ↗ jump to hunk
@@ -1815,8 +1831,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) return 0; drop: + SKB_DR_RESET(reason);
the name of this macro is very confusing, I don't think it should exist in the first place. nothing should goto drop without initialing reason
/* Consume bad packet */ - kfree_skb(skb); + kfree_skb_reason(skb, reason); return 0; }