netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] vxlan: Fix vxlan counters.
@ 2024-04-26 15:27 Guillaume Nault
  2024-04-26 15:27 ` [PATCH net 1/2] vxlan: Fix racy device stats updates Guillaume Nault
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Guillaume Nault @ 2024-04-26 15:27 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: netdev, Ido Schimmel, Amit Cohen, Petr Machata,
	Nikolay Aleksandrov, Jiri Benc, Breno Leitao, Roopa Prabhu,
	stephen hemminger

Like most virtual devices, vxlan needs special care when updating its
netdevice counters. This is done in patch 1. Patch 2 just adds a
missing VNI counter update (found while working on patch 1).

Guillaume Nault (2):
  vxlan: Fix racy device stats updates.
  vxlan: Add missing VNI filter counter update in arp_reduce().

 drivers/net/vxlan/vxlan_core.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/2] vxlan: Fix racy device stats updates.
  2024-04-26 15:27 [PATCH net 0/2] vxlan: Fix vxlan counters Guillaume Nault
@ 2024-04-26 15:27 ` Guillaume Nault
  2024-04-26 16:02   ` Eric Dumazet
  2024-04-26 15:27 ` [PATCH net 2/2] vxlan: Add missing VNI filter counter update in arp_reduce() Guillaume Nault
  2024-04-29 12:40 ` [PATCH net 0/2] vxlan: Fix vxlan counters patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Guillaume Nault @ 2024-04-26 15:27 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: netdev, Ido Schimmel, Amit Cohen, Petr Machata,
	Nikolay Aleksandrov, Jiri Benc, Breno Leitao, Roopa Prabhu,
	stephen hemminger

VXLAN devices update their stats locklessly. Therefore these counters
should either be stored in per-cpu data structures or the updates
should be done using atomic increments.

Since the net_device_core_stats infrastructure is already used in
vxlan_rcv(), use it for the other rx_dropped and tx_dropped counter
updates. Update the other counters atomically using DEV_STATS_INC().

Fixes: d342894c5d2f ("vxlan: virtual extensible lan")
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 drivers/net/vxlan/vxlan_core.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index ba319fc21957..0cd9e44c7be8 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1766,8 +1766,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
 	skb_reset_network_header(skb);
 
 	if (!vxlan_ecn_decapsulate(vs, oiph, skb)) {
-		++vxlan->dev->stats.rx_frame_errors;
-		++vxlan->dev->stats.rx_errors;
+		DEV_STATS_INC(vxlan->dev, rx_frame_errors);
+		DEV_STATS_INC(vxlan->dev, rx_errors);
 		vxlan_vnifilter_count(vxlan, vni, vninode,
 				      VXLAN_VNI_STATS_RX_ERRORS, 0);
 		goto drop;
@@ -1837,7 +1837,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
 		goto out;
 
 	if (!pskb_may_pull(skb, arp_hdr_len(dev))) {
-		dev->stats.tx_dropped++;
+		dev_core_stats_tx_dropped_inc(dev);
 		goto out;
 	}
 	parp = arp_hdr(skb);
@@ -1893,7 +1893,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
 		reply->pkt_type = PACKET_HOST;
 
 		if (netif_rx(reply) == NET_RX_DROP) {
-			dev->stats.rx_dropped++;
+			dev_core_stats_rx_dropped_inc(dev);
 			vxlan_vnifilter_count(vxlan, vni, NULL,
 					      VXLAN_VNI_STATS_RX_DROPS, 0);
 		}
@@ -2052,7 +2052,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
 			goto out;
 
 		if (netif_rx(reply) == NET_RX_DROP) {
-			dev->stats.rx_dropped++;
+			dev_core_stats_rx_dropped_inc(dev);
 			vxlan_vnifilter_count(vxlan, vni, NULL,
 					      VXLAN_VNI_STATS_RX_DROPS, 0);
 		}
@@ -2263,7 +2263,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
 				      len);
 	} else {
 drop:
-		dev->stats.rx_dropped++;
+		dev_core_stats_rx_dropped_inc(dev);
 		vxlan_vnifilter_count(dst_vxlan, vni, NULL,
 				      VXLAN_VNI_STATS_RX_DROPS, 0);
 	}
@@ -2295,7 +2295,7 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,
 					   addr_family, dst_port,
 					   vxlan->cfg.flags);
 		if (!dst_vxlan) {
-			dev->stats.tx_errors++;
+			DEV_STATS_INC(dev, tx_errors);
 			vxlan_vnifilter_count(vxlan, vni, NULL,
 					      VXLAN_VNI_STATS_TX_ERRORS, 0);
 			kfree_skb(skb);
@@ -2559,7 +2559,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
 	return;
 
 drop:
-	dev->stats.tx_dropped++;
+	dev_core_stats_tx_dropped_inc(dev);
 	vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0);
 	dev_kfree_skb(skb);
 	return;
@@ -2567,11 +2567,11 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
 tx_error:
 	rcu_read_unlock();
 	if (err == -ELOOP)
-		dev->stats.collisions++;
+		DEV_STATS_INC(dev, collisions);
 	else if (err == -ENETUNREACH)
-		dev->stats.tx_carrier_errors++;
+		DEV_STATS_INC(dev, tx_carrier_errors);
 	dst_release(ndst);
-	dev->stats.tx_errors++;
+	DEV_STATS_INC(dev, tx_errors);
 	vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_ERRORS, 0);
 	kfree_skb(skb);
 }
@@ -2604,7 +2604,7 @@ static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev,
 	return;
 
 drop:
-	dev->stats.tx_dropped++;
+	dev_core_stats_tx_dropped_inc(dev);
 	vxlan_vnifilter_count(netdev_priv(dev), vni, NULL,
 			      VXLAN_VNI_STATS_TX_DROPS, 0);
 	dev_kfree_skb(skb);
@@ -2642,7 +2642,7 @@ static netdev_tx_t vxlan_xmit_nhid(struct sk_buff *skb, struct net_device *dev,
 	return NETDEV_TX_OK;
 
 drop:
-	dev->stats.tx_dropped++;
+	dev_core_stats_tx_dropped_inc(dev);
 	vxlan_vnifilter_count(netdev_priv(dev), vni, NULL,
 			      VXLAN_VNI_STATS_TX_DROPS, 0);
 	dev_kfree_skb(skb);
@@ -2739,7 +2739,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
 			    !is_multicast_ether_addr(eth->h_dest))
 				vxlan_fdb_miss(vxlan, eth->h_dest);
 
-			dev->stats.tx_dropped++;
+			dev_core_stats_tx_dropped_inc(dev);
 			vxlan_vnifilter_count(vxlan, vni, NULL,
 					      VXLAN_VNI_STATS_TX_DROPS, 0);
 			kfree_skb(skb);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/2] vxlan: Add missing VNI filter counter update in arp_reduce().
  2024-04-26 15:27 [PATCH net 0/2] vxlan: Fix vxlan counters Guillaume Nault
  2024-04-26 15:27 ` [PATCH net 1/2] vxlan: Fix racy device stats updates Guillaume Nault
@ 2024-04-26 15:27 ` Guillaume Nault
  2024-04-29 12:40 ` [PATCH net 0/2] vxlan: Fix vxlan counters patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Guillaume Nault @ 2024-04-26 15:27 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: netdev, Ido Schimmel, Amit Cohen, Petr Machata,
	Nikolay Aleksandrov, Jiri Benc, Breno Leitao, Roopa Prabhu,
	stephen hemminger

VXLAN stores per-VNI statistics using vxlan_vnifilter_count().
These statistics were not updated when arp_reduce() failed its
pskb_may_pull() call.

Use vxlan_vnifilter_count() to update the VNI counter when that
happens.

Fixes: 4095e0e1328a ("drivers: vxlan: vnifilter: per vni stats")
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 drivers/net/vxlan/vxlan_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 0cd9e44c7be8..c9e4e03ad214 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1838,6 +1838,8 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
 
 	if (!pskb_may_pull(skb, arp_hdr_len(dev))) {
 		dev_core_stats_tx_dropped_inc(dev);
+		vxlan_vnifilter_count(vxlan, vni, NULL,
+				      VXLAN_VNI_STATS_TX_DROPS, 0);
 		goto out;
 	}
 	parp = arp_hdr(skb);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net 1/2] vxlan: Fix racy device stats updates.
  2024-04-26 15:27 ` [PATCH net 1/2] vxlan: Fix racy device stats updates Guillaume Nault
@ 2024-04-26 16:02   ` Eric Dumazet
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2024-04-26 16:02 UTC (permalink / raw)
  To: Guillaume Nault
  Cc: David Miller, Jakub Kicinski, Paolo Abeni, netdev, Ido Schimmel,
	Amit Cohen, Petr Machata, Nikolay Aleksandrov, Jiri Benc,
	Breno Leitao, Roopa Prabhu, stephen hemminger

On Fri, Apr 26, 2024 at 5:27 PM Guillaume Nault <gnault@redhat.com> wrote:
>
> VXLAN devices update their stats locklessly. Therefore these counters
> should either be stored in per-cpu data structures or the updates
> should be done using atomic increments.
>
> Since the net_device_core_stats infrastructure is already used in
> vxlan_rcv(), use it for the other rx_dropped and tx_dropped counter
> updates. Update the other counters atomically using DEV_STATS_INC().
>
> Fixes: d342894c5d2f ("vxlan: virtual extensible lan")
> Signed-off-by: Guillaume Nault <gnault@redhat.com>
> ---

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net 0/2] vxlan: Fix vxlan counters.
  2024-04-26 15:27 [PATCH net 0/2] vxlan: Fix vxlan counters Guillaume Nault
  2024-04-26 15:27 ` [PATCH net 1/2] vxlan: Fix racy device stats updates Guillaume Nault
  2024-04-26 15:27 ` [PATCH net 2/2] vxlan: Add missing VNI filter counter update in arp_reduce() Guillaume Nault
@ 2024-04-29 12:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-29 12:40 UTC (permalink / raw)
  To: Guillaume Nault
  Cc: davem, kuba, pabeni, edumazet, netdev, idosch, amcohen, petrm,
	razor, jbenc, leitao, roopa, shemminger

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Fri, 26 Apr 2024 17:27:15 +0200 you wrote:
> Like most virtual devices, vxlan needs special care when updating its
> netdevice counters. This is done in patch 1. Patch 2 just adds a
> missing VNI counter update (found while working on patch 1).
> 
> Guillaume Nault (2):
>   vxlan: Fix racy device stats updates.
>   vxlan: Add missing VNI filter counter update in arp_reduce().
> 
> [...]

Here is the summary with links:
  - [net,1/2] vxlan: Fix racy device stats updates.
    https://git.kernel.org/netdev/net/c/6dee402daba4
  - [net,2/2] vxlan: Add missing VNI filter counter update in arp_reduce().
    https://git.kernel.org/netdev/net/c/b22ea4ef4c34

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-29 12:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-26 15:27 [PATCH net 0/2] vxlan: Fix vxlan counters Guillaume Nault
2024-04-26 15:27 ` [PATCH net 1/2] vxlan: Fix racy device stats updates Guillaume Nault
2024-04-26 16:02   ` Eric Dumazet
2024-04-26 15:27 ` [PATCH net 2/2] vxlan: Add missing VNI filter counter update in arp_reduce() Guillaume Nault
2024-04-29 12:40 ` [PATCH net 0/2] vxlan: Fix vxlan counters patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).