ipvlan: properly track tx_errors
Subsystems (2)
PATCH 1/1 ipvlan: properly track tx_errors
Both ipvlan_process_v4_outbound() and ipvlan_process_v6_outbound() increment dev->stats.tx_errors in case of errors.
Unfortunately there are two issues :
1) ipvlan_get_stats64() does not propagate dev->stats.tx_errors to user.
2) Increments are not atomic. KCSAN would complain eventually.
Use DEV_STATS_INC() to not miss an update, and change ipvlan_get_stats64() to copy the value back to user.
--- drivers/net/ipvlan/ipvlan_core.c | 8 ++++---- drivers/net/ipvlan/ipvlan_main.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/ipvlan/ipvlan_core.c +4 -4
@@ -441,12 +441,12 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb) err =ip_local_out (net, skb->sk, skb);if (unlikely (net_xmit_eval (err))) - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);else ret =NET_XMIT_SUCCESS ; goto out; err: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb); out:return ret;
@@ -482,12 +482,12 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb) err =ip6_local_out (net, skb->sk, skb);if (unlikely (net_xmit_eval (err))) - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);else ret =NET_XMIT_SUCCESS ; goto out; err: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb); out:return ret;
drivers/net/ipvlan/ipvlan_main.c +1 -0
@@ -324,6 +324,7 @@ static void ipvlan_get_stats64(struct net_device *dev, s->rx_dropped = rx_errs; s->tx_dropped = tx_drps; } + s->tx_errors =DEV_STATS_READ (dev, tx_errors); }static int ipvlan_vlan_rx_add_vid (struct net_device *dev,__be16 proto,u16 vid)
Signature · 1 line
2.42.0.758.gaed0368e0e-goog
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 26 Oct 2023 13:14:46 +0000 you wrote:
Both
ipvlan_process_v4_outbound()andipvlan_process_v6_outbound()incrementdev->stats.tx_errorsin case of errors.Unfortunately there are two issues :
1)
ipvlan_get_stats64()does not propagatedev->stats.tx_errorsto user.[...]
Here is the summary with links:
- [net-next] ipvlan: properly track tx_errors
https://git.kernel.org/netdev/net-next/c/ff672b9ffeb3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html