Commit ff672b9f authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

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.

Fixes: 2ad7bf36 ("ipvlan: Initial check-in of the IPVLAN driver.")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Mahesh Bandewar <maheshb@google.com>
Link: https://lore.kernel.org/r/20231026131446.3933175-1-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 6aff7cbf
...@@ -441,12 +441,12 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb) ...@@ -441,12 +441,12 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
err = ip_local_out(net, skb->sk, skb); err = ip_local_out(net, skb->sk, skb);
if (unlikely(net_xmit_eval(err))) if (unlikely(net_xmit_eval(err)))
dev->stats.tx_errors++; DEV_STATS_INC(dev, tx_errors);
else else
ret = NET_XMIT_SUCCESS; ret = NET_XMIT_SUCCESS;
goto out; goto out;
err: err:
dev->stats.tx_errors++; DEV_STATS_INC(dev, tx_errors);
kfree_skb(skb); kfree_skb(skb);
out: out:
return ret; return ret;
...@@ -482,12 +482,12 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb) ...@@ -482,12 +482,12 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
err = ip6_local_out(net, skb->sk, skb); err = ip6_local_out(net, skb->sk, skb);
if (unlikely(net_xmit_eval(err))) if (unlikely(net_xmit_eval(err)))
dev->stats.tx_errors++; DEV_STATS_INC(dev, tx_errors);
else else
ret = NET_XMIT_SUCCESS; ret = NET_XMIT_SUCCESS;
goto out; goto out;
err: err:
dev->stats.tx_errors++; DEV_STATS_INC(dev, tx_errors);
kfree_skb(skb); kfree_skb(skb);
out: out:
return ret; return ret;
......
...@@ -324,6 +324,7 @@ static void ipvlan_get_stats64(struct net_device *dev, ...@@ -324,6 +324,7 @@ static void ipvlan_get_stats64(struct net_device *dev,
s->rx_dropped = rx_errs; s->rx_dropped = rx_errs;
s->tx_dropped = tx_drps; 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) static int ipvlan_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment