[PATCH net-next v2 08/12] net: vxlan: use vxlan_kfree_skb() in vxlan_xmit()
From: Menglong Dong
Date: Thu Aug 29 2024 - 22:04:50 EST
Replace kfree_skb() with vxlan_kfree_skb() in vxlan_xmit(). Following
new skb drop reasons are introduced for vxlan:
/* no remote found */
VXLAN_DROP_NO_REMOTE
And following drop reason is introduced to dropreason-core:
/* txinfo is missed in "external" mode */
SKB_DROP_REASON_TUNNEL_TXINFO
Signed-off-by: Menglong Dong <dongml2@xxxxxxxxxxxxxxx>
---
v2:
- move the drop reason "TXINFO" from vxlan to core
- rename VXLAN_DROP_REMOTE to VXLAN_DROP_NO_REMOTE
---
drivers/net/vxlan/drop.h | 3 +++
drivers/net/vxlan/vxlan_core.c | 6 +++---
include/net/dropreason-core.h | 3 +++
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h
index 416532633881..a8ad96e0a502 100644
--- a/drivers/net/vxlan/drop.h
+++ b/drivers/net/vxlan/drop.h
@@ -13,6 +13,7 @@
R(VXLAN_DROP_ENTRY_EXISTS) \
R(VXLAN_DROP_INVALID_HDR) \
R(VXLAN_DROP_VNI_NOT_FOUND) \
+ R(VXLAN_DROP_NO_REMOTE) \
/* deliberate comment for trailing \ */
enum vxlan_drop_reason {
@@ -33,6 +34,8 @@ enum vxlan_drop_reason {
VXLAN_DROP_INVALID_HDR,
/** @VXLAN_DROP_VNI_NOT_FOUND: no vxlan device found for the vni */
VXLAN_DROP_VNI_NOT_FOUND,
+ /** @VXLAN_DROP_NO_REMOTE: no remote found to transmit the packet */
+ VXLAN_DROP_NO_REMOTE,
};
static inline void
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index ab1c14a807f2..c3bdac6834d4 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2728,7 +2728,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
if (info && info->mode & IP_TUNNEL_INFO_TX)
vxlan_xmit_one(skb, dev, vni, NULL, false);
else
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_TUNNEL_TXINFO);
return NETDEV_TX_OK;
}
}
@@ -2791,7 +2791,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
dev_core_stats_tx_dropped_inc(dev);
vxlan_vnifilter_count(vxlan, vni, NULL,
VXLAN_VNI_STATS_TX_DROPS, 0);
- kfree_skb(skb);
+ vxlan_kfree_skb(skb, VXLAN_DROP_NO_REMOTE);
return NETDEV_TX_OK;
}
}
@@ -2814,7 +2814,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
if (fdst)
vxlan_xmit_one(skb, dev, vni, fdst, did_rsc);
else
- kfree_skb(skb);
+ vxlan_kfree_skb(skb, VXLAN_DROP_NO_REMOTE);
}
return NETDEV_TX_OK;
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index d38371f33e2b..77bd92f507d8 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -93,6 +93,7 @@
FN(TC_CHAIN_NOTFOUND) \
FN(TC_RECLASSIFY_LOOP) \
FN(IP_TUNNEL_ECN) \
+ FN(TUNNEL_TXINFO) \
FNe(MAX)
/**
@@ -424,6 +425,8 @@ enum skb_drop_reason {
* RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
*/
SKB_DROP_REASON_IP_TUNNEL_ECN,
+ /** @SKB_DROP_REASON_TUNNEL_TXINFO: tx info for tunnel is missed */
+ SKB_DROP_REASON_TUNNEL_TXINFO,
/**
* @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
* shouldn't be used as a real 'reason' - only for tracing code gen
--
2.39.2