net: xfrm: use core API for updating/providing stats
Commit d3fd65484c
("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>
This commit is contained in:
Родитель
865e6ae02d
Коммит
0064c5c1b3
|
@ -319,12 +319,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
|
||||||
|
|
||||||
err = dst_output(xi->net, skb->sk, skb);
|
err = dst_output(xi->net, skb->sk, skb);
|
||||||
if (net_xmit_eval(err) == 0) {
|
if (net_xmit_eval(err) == 0) {
|
||||||
struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
|
dev_sw_netstats_tx_add(dev, 1, length);
|
||||||
|
|
||||||
u64_stats_update_begin(&tstats->syncp);
|
|
||||||
tstats->tx_bytes += length;
|
|
||||||
tstats->tx_packets++;
|
|
||||||
u64_stats_update_end(&tstats->syncp);
|
|
||||||
} else {
|
} else {
|
||||||
stats->tx_errors++;
|
stats->tx_errors++;
|
||||||
stats->tx_aborted_errors++;
|
stats->tx_aborted_errors++;
|
||||||
|
@ -538,15 +533,6 @@ static int xfrmi_update(struct xfrm_if *xi, struct xfrm_if_parms *p)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xfrmi_get_stats64(struct net_device *dev,
|
|
||||||
struct rtnl_link_stats64 *s)
|
|
||||||
{
|
|
||||||
dev_fetch_sw_netstats(s, dev->tstats);
|
|
||||||
|
|
||||||
s->rx_dropped = dev->stats.rx_dropped;
|
|
||||||
s->tx_dropped = dev->stats.tx_dropped;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int xfrmi_get_iflink(const struct net_device *dev)
|
static int xfrmi_get_iflink(const struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct xfrm_if *xi = netdev_priv(dev);
|
struct xfrm_if *xi = netdev_priv(dev);
|
||||||
|
@ -554,12 +540,11 @@ static int xfrmi_get_iflink(const struct net_device *dev)
|
||||||
return xi->p.link;
|
return xi->p.link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const struct net_device_ops xfrmi_netdev_ops = {
|
static const struct net_device_ops xfrmi_netdev_ops = {
|
||||||
.ndo_init = xfrmi_dev_init,
|
.ndo_init = xfrmi_dev_init,
|
||||||
.ndo_uninit = xfrmi_dev_uninit,
|
.ndo_uninit = xfrmi_dev_uninit,
|
||||||
.ndo_start_xmit = xfrmi_xmit,
|
.ndo_start_xmit = xfrmi_xmit,
|
||||||
.ndo_get_stats64 = xfrmi_get_stats64,
|
.ndo_get_stats64 = dev_get_tstats64,
|
||||||
.ndo_get_iflink = xfrmi_get_iflink,
|
.ndo_get_iflink = xfrmi_get_iflink,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче