diff mbox series

[net-next,v7,08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit()

Message ID 20241009022830.83949-9-dongml2@chinatelecom.cn (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series net: vxlan: add skb drop reasons support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 45 this patch: 45
netdev/build_tools success Errors and warnings before: 0 (+1) this patch: 0 (+1)
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 99 this patch: 99
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 5040 this patch: 5040
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Menglong Dong <menglong8.dong@gmail.com>' != 'Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>' WARNING: line length of 85 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-12--12-00 (tests: 777)

Commit Message

Menglong Dong Oct. 9, 2024, 2:28 a.m. UTC
Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following
new skb drop reasons are introduced for vxlan:

/* no remote found for xmit */
SKB_DROP_REASON_VXLAN_NO_REMOTE
/* packet without necessary metadata reached a device which is
 * in "external" mode
 */
SKB_DROP_REASON_TUNNEL_TXINFO

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
v7:
- fix some typos in the document for SKB_DROP_REASON_TUNNEL_TXINFO
v6:
- fix some typos in the document for SKB_DROP_REASON_TUNNEL_TXINFO
v5:
- modify the document for SKB_DROP_REASON_TUNNEL_TXINFO
v2:
- move the drop reason "TXINFO" from vxlan to core
- rename VXLAN_DROP_REMOTE to VXLAN_DROP_NO_REMOTE
---
 drivers/net/vxlan/vxlan_core.c | 6 +++---
 include/net/dropreason-core.h  | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

Comments

Ido Schimmel Oct. 13, 2024, 12:43 p.m. UTC | #1
On Wed, Oct 09, 2024 at 10:28:26AM +0800, Menglong Dong wrote:
> Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following
> new skb drop reasons are introduced for vxlan:
> 
> /* no remote found for xmit */
> SKB_DROP_REASON_VXLAN_NO_REMOTE
> /* packet without necessary metadata reached a device which is
>  * in "external" mode
>  */
> SKB_DROP_REASON_TUNNEL_TXINFO
> 
> Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> Reviewed-by: Simon Horman <horms@kernel.org>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

The first reason might be useful for the bridge driver as well when
there are no ports to forward the packet to (because of egress filtering
for example), but we can make it more generic if / when the bridge
driver is annotated.
Menglong Dong Oct. 14, 2024, 12:35 p.m. UTC | #2
On Sun, Oct 13, 2024 at 8:43 PM Ido Schimmel <idosch@nvidia.com> wrote:
>
> On Wed, Oct 09, 2024 at 10:28:26AM +0800, Menglong Dong wrote:
> > Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following
> > new skb drop reasons are introduced for vxlan:
> >
> > /* no remote found for xmit */
> > SKB_DROP_REASON_VXLAN_NO_REMOTE
> > /* packet without necessary metadata reached a device which is
> >  * in "external" mode
> >  */
> > SKB_DROP_REASON_TUNNEL_TXINFO
> >
> > Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> > Reviewed-by: Simon Horman <horms@kernel.org>
>
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
>
> The first reason might be useful for the bridge driver as well when
> there are no ports to forward the packet to (because of egress filtering
> for example), but we can make it more generic if / when the bridge
> driver is annotated.

You are right. As we already need a new version, so we can
do something for this patch too. As you said, maybe we can rename the
reason VXLAN_NO_REMOTE to NO_REMOTE for more generic
usage?
Ido Schimmel Oct. 14, 2024, 3:47 p.m. UTC | #3
On Mon, Oct 14, 2024 at 08:35:57PM +0800, Menglong Dong wrote:
> On Sun, Oct 13, 2024 at 8:43 PM Ido Schimmel <idosch@nvidia.com> wrote:
> >
> > On Wed, Oct 09, 2024 at 10:28:26AM +0800, Menglong Dong wrote:
> > > Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following
> > > new skb drop reasons are introduced for vxlan:
> > >
> > > /* no remote found for xmit */
> > > SKB_DROP_REASON_VXLAN_NO_REMOTE
> > > /* packet without necessary metadata reached a device which is
> > >  * in "external" mode
> > >  */
> > > SKB_DROP_REASON_TUNNEL_TXINFO
> > >
> > > Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> > > Reviewed-by: Simon Horman <horms@kernel.org>
> >
> > Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> >
> > The first reason might be useful for the bridge driver as well when
> > there are no ports to forward the packet to (because of egress filtering
> > for example), but we can make it more generic if / when the bridge
> > driver is annotated.
> 
> You are right. As we already need a new version, so we can
> do something for this patch too. As you said, maybe we can rename the
> reason VXLAN_NO_REMOTE to NO_REMOTE for more generic
> usage?

"NO_REMOTE" is not really applicable to the bridge driver as there are
no remotes, but bridge ports. I'm fine with keeping it as is for now and
changing it later if / when needed.
Menglong Dong Oct. 15, 2024, 1:55 a.m. UTC | #4
On Mon, Oct 14, 2024 at 11:47 PM Ido Schimmel <idosch@nvidia.com> wrote:
>
> On Mon, Oct 14, 2024 at 08:35:57PM +0800, Menglong Dong wrote:
> > On Sun, Oct 13, 2024 at 8:43 PM Ido Schimmel <idosch@nvidia.com> wrote:
> > >
> > > On Wed, Oct 09, 2024 at 10:28:26AM +0800, Menglong Dong wrote:
> > > > Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following
> > > > new skb drop reasons are introduced for vxlan:
> > > >
> > > > /* no remote found for xmit */
> > > > SKB_DROP_REASON_VXLAN_NO_REMOTE
> > > > /* packet without necessary metadata reached a device which is
> > > >  * in "external" mode
> > > >  */
> > > > SKB_DROP_REASON_TUNNEL_TXINFO
> > > >
> > > > Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> > > > Reviewed-by: Simon Horman <horms@kernel.org>
> > >
> > > Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> > >
> > > The first reason might be useful for the bridge driver as well when
> > > there are no ports to forward the packet to (because of egress filtering
> > > for example), but we can make it more generic if / when the bridge
> > > driver is annotated.
> >
> > You are right. As we already need a new version, so we can
> > do something for this patch too. As you said, maybe we can rename the
> > reason VXLAN_NO_REMOTE to NO_REMOTE for more generic
> > usage?
>
> "NO_REMOTE" is not really applicable to the bridge driver as there are
> no remotes, but bridge ports. I'm fine with keeping it as is for now and
> changing it later if / when needed.

Okay!
diff mbox series

Patch

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 41191a28252a..b677ec901807 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2730,7 +2730,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;
 		}
 	}
@@ -2793,7 +2793,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);
+			kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE);
 			return NETDEV_TX_OK;
 		}
 	}
@@ -2816,7 +2816,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);
+			kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE);
 	}
 
 	return NETDEV_TX_OK;
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index fbf92d442c1b..d59bb96c5a02 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -96,7 +96,9 @@ 
 	FN(VXLAN_VNI_NOT_FOUND)		\
 	FN(MAC_INVALID_SOURCE)		\
 	FN(VXLAN_ENTRY_EXISTS)		\
+	FN(VXLAN_NO_REMOTE)		\
 	FN(IP_TUNNEL_ECN)		\
+	FN(TUNNEL_TXINFO)		\
 	FN(LOCAL_MAC)			\
 	FNe(MAX)
 
@@ -439,11 +441,18 @@  enum skb_drop_reason {
 	 * entry or an entry pointing to a nexthop.
 	 */
 	SKB_DROP_REASON_VXLAN_ENTRY_EXISTS,
+	/** @SKB_DROP_REASON_VXLAN_NO_REMOTE: no remote found for xmit */
+	SKB_DROP_REASON_VXLAN_NO_REMOTE,
 	/**
 	 * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to
 	 * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
 	 */
 	SKB_DROP_REASON_IP_TUNNEL_ECN,
+	/**
+	 * @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metadata
+	 * reached a device which is in "external" mode.
+	 */
+	SKB_DROP_REASON_TUNNEL_TXINFO,
 	/**
 	 * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
 	 * the MAC address of the local netdev.