Skip to content

Commit ff672b9

Browse files
edumazetkuba-moo
authored andcommitted
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: 2ad7bf3 ("ipvlan: Initial check-in of the IPVLAN driver.") Signed-off-by: Eric Dumazet <[email protected]> Cc: Mahesh Bandewar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6aff7cb commit ff672b9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/net/ipvlan/ipvlan_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,12 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
441441

442442
err = ip_local_out(net, skb->sk, skb);
443443
if (unlikely(net_xmit_eval(err)))
444-
dev->stats.tx_errors++;
444+
DEV_STATS_INC(dev, tx_errors);
445445
else
446446
ret = NET_XMIT_SUCCESS;
447447
goto out;
448448
err:
449-
dev->stats.tx_errors++;
449+
DEV_STATS_INC(dev, tx_errors);
450450
kfree_skb(skb);
451451
out:
452452
return ret;
@@ -482,12 +482,12 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
482482

483483
err = ip6_local_out(net, skb->sk, skb);
484484
if (unlikely(net_xmit_eval(err)))
485-
dev->stats.tx_errors++;
485+
DEV_STATS_INC(dev, tx_errors);
486486
else
487487
ret = NET_XMIT_SUCCESS;
488488
goto out;
489489
err:
490-
dev->stats.tx_errors++;
490+
DEV_STATS_INC(dev, tx_errors);
491491
kfree_skb(skb);
492492
out:
493493
return ret;

drivers/net/ipvlan/ipvlan_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ static void ipvlan_get_stats64(struct net_device *dev,
324324
s->rx_dropped = rx_errs;
325325
s->tx_dropped = tx_drps;
326326
}
327+
s->tx_errors = DEV_STATS_READ(dev, tx_errors);
327328
}
328329

329330
static int ipvlan_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)

0 commit comments

Comments
 (0)