Commit f1084c42 authored by Yunjian Wang's avatar Yunjian Wang Committed by David S. Miller

tun: add missing rx stats accounting in tun_xdp_act

The TUN can be used as vhost-net backend, and it is necessary to
count the packets transmitted from TUN to vhost-net/virtio-net.
However, there are some places in the receive path that were not
taken into account when using XDP. It would be beneficial to also
include new accounting for successfully received bytes using
dev_sw_netstats_rx_add.

Fixes: 761876c8 ("tap: XDP support")
Signed-off-by: default avatarYunjian Wang <wangyunjian@huawei.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5744ba05
...@@ -1634,6 +1634,7 @@ static int tun_xdp_act(struct tun_struct *tun, struct bpf_prog *xdp_prog, ...@@ -1634,6 +1634,7 @@ static int tun_xdp_act(struct tun_struct *tun, struct bpf_prog *xdp_prog,
dev_core_stats_rx_dropped_inc(tun->dev); dev_core_stats_rx_dropped_inc(tun->dev);
return err; return err;
} }
dev_sw_netstats_rx_add(tun->dev, xdp->data_end - xdp->data);
break; break;
case XDP_TX: case XDP_TX:
err = tun_xdp_tx(tun->dev, xdp); err = tun_xdp_tx(tun->dev, xdp);
...@@ -1641,6 +1642,7 @@ static int tun_xdp_act(struct tun_struct *tun, struct bpf_prog *xdp_prog, ...@@ -1641,6 +1642,7 @@ static int tun_xdp_act(struct tun_struct *tun, struct bpf_prog *xdp_prog,
dev_core_stats_rx_dropped_inc(tun->dev); dev_core_stats_rx_dropped_inc(tun->dev);
return err; return err;
} }
dev_sw_netstats_rx_add(tun->dev, xdp->data_end - xdp->data);
break; break;
case XDP_PASS: case XDP_PASS:
break; break;
......
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