Skip to content

Commit 0064c5c

Browse files
lstipakovkuba-moo
authored andcommitted
net: xfrm: use core API for updating/providing stats
Commit d3fd654 ("net: core: add dev_sw_netstats_tx_add") has added function "dev_sw_netstats_tx_add()" to update net device per-cpu TX stats. Use this function instead of own code. While on it, remove xfrmi_get_stats64() and replace it with dev_get_tstats64(). Signed-off-by: Lev Stipakov <lev@openvpn.net> Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com> Link: https://lore.kernel.org/r/20201113215939.147007-1-lev@openvpn.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 865e6ae commit 0064c5c

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

net/xfrm/xfrm_interface.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
319319

320320
err = dst_output(xi->net, skb->sk, skb);
321321
if (net_xmit_eval(err) == 0) {
322-
struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
323-
324-
u64_stats_update_begin(&tstats->syncp);
325-
tstats->tx_bytes += length;
326-
tstats->tx_packets++;
327-
u64_stats_update_end(&tstats->syncp);
322+
dev_sw_netstats_tx_add(dev, 1, length);
328323
} else {
329324
stats->tx_errors++;
330325
stats->tx_aborted_errors++;
@@ -538,28 +533,18 @@ static int xfrmi_update(struct xfrm_if *xi, struct xfrm_if_parms *p)
538533
return err;
539534
}
540535

541-
static void xfrmi_get_stats64(struct net_device *dev,
542-
struct rtnl_link_stats64 *s)
543-
{
544-
dev_fetch_sw_netstats(s, dev->tstats);
545-
546-
s->rx_dropped = dev->stats.rx_dropped;
547-
s->tx_dropped = dev->stats.tx_dropped;
548-
}
549-
550536
static int xfrmi_get_iflink(const struct net_device *dev)
551537
{
552538
struct xfrm_if *xi = netdev_priv(dev);
553539

554540
return xi->p.link;
555541
}
556542

557-
558543
static const struct net_device_ops xfrmi_netdev_ops = {
559544
.ndo_init = xfrmi_dev_init,
560545
.ndo_uninit = xfrmi_dev_uninit,
561546
.ndo_start_xmit = xfrmi_xmit,
562-
.ndo_get_stats64 = xfrmi_get_stats64,
547+
.ndo_get_stats64 = dev_get_tstats64,
563548
.ndo_get_iflink = xfrmi_get_iflink,
564549
};
565550

0 commit comments

Comments
 (0)