[PATCH net-next 07/10] net: vxlan: use vxlan_kfree_skb() in vxlan_xmit()

Menglong Dong posted 10 patches 1 year, 5 months ago
There is a newer version of this series
[PATCH net-next 07/10] net: vxlan: use vxlan_kfree_skb() in vxlan_xmit()
Posted by Menglong Dong 1 year, 5 months ago
Replace kfree_skb() with vxlan_kfree_skb() in vxlan_xmit(). Following
new skb drop reasons are introduced:

/* txinfo is missed in "external" mode */
VXLAN_DROP_TXINFO
/* no remote found */
VXLAN_DROP_REMOTE

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
---
 drivers/net/vxlan/drop.h       | 2 ++
 drivers/net/vxlan/vxlan_core.c | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h
index cae1e0ea8c56..da30cb4a9ed9 100644
--- a/drivers/net/vxlan/drop.h
+++ b/drivers/net/vxlan/drop.h
@@ -12,6 +12,8 @@
 	R(VXLAN_DROP_FLAGS)			\
 	R(VXLAN_DROP_VNI)			\
 	R(VXLAN_DROP_MAC)			\
+	R(VXLAN_DROP_TXINFO)			\
+	R(VXLAN_DROP_REMOTE)			\
 	/* 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 9a61f04bb95d..22e2bf532ac3 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2729,7 +2729,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);
+				vxlan_kfree_skb(skb, VXLAN_DROP_TXINFO);
 			return NETDEV_TX_OK;
 		}
 	}
@@ -2792,7 +2792,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_REMOTE);
 			return NETDEV_TX_OK;
 		}
 	}
@@ -2815,7 +2815,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_REMOTE);
 	}
 
 	return NETDEV_TX_OK;
-- 
2.39.2
Re: [PATCH net-next 07/10] net: vxlan: use vxlan_kfree_skb() in vxlan_xmit()
Posted by Ido Schimmel 1 year, 5 months ago
On Thu, Aug 15, 2024 at 08:42:59PM +0800, Menglong Dong wrote:
> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index 9a61f04bb95d..22e2bf532ac3 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
> @@ -2729,7 +2729,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);
> +				vxlan_kfree_skb(skb, VXLAN_DROP_TXINFO);

This one probably belongs in include/net/dropreason-core.h as there are
other devices that support tunnel info with similar checks.

>  			return NETDEV_TX_OK;
>  		}
>  	}
> @@ -2792,7 +2792,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_REMOTE);
>  			return NETDEV_TX_OK;
>  		}
>  	}
> @@ -2815,7 +2815,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_REMOTE);

Maybe VXLAN_DROP_NO_REMOTE? Please add it to vxlan_mdb_xmit() as well

>  	}
>  
>  	return NETDEV_TX_OK;
> -- 
> 2.39.2
>
Re: [PATCH net-next 07/10] net: vxlan: use vxlan_kfree_skb() in vxlan_xmit()
Posted by Menglong Dong 1 year, 5 months ago
On Tue, Aug 20, 2024 at 8:29 PM Ido Schimmel <idosch@nvidia.com> wrote:
>
> On Thu, Aug 15, 2024 at 08:42:59PM +0800, Menglong Dong wrote:
> > diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> > index 9a61f04bb95d..22e2bf532ac3 100644
> > --- a/drivers/net/vxlan/vxlan_core.c
> > +++ b/drivers/net/vxlan/vxlan_core.c
> > @@ -2729,7 +2729,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);
> > +                             vxlan_kfree_skb(skb, VXLAN_DROP_TXINFO);
>
> This one probably belongs in include/net/dropreason-core.h as there are
> other devices that support tunnel info with similar checks.
>

OK, I'll add it to the drop reason core as SKB_DROP_REASON_TUNNEL_TXINFO.

> >                       return NETDEV_TX_OK;
> >               }
> >       }
> > @@ -2792,7 +2792,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_REMOTE);
> >                       return NETDEV_TX_OK;
> >               }
> >       }
> > @@ -2815,7 +2815,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_REMOTE);
>
> Maybe VXLAN_DROP_NO_REMOTE? Please add it to vxlan_mdb_xmit() as well
>

Okay!

> >       }
> >
> >       return NETDEV_TX_OK;
> > --
> > 2.39.2
> >