diff mbox series

[net,2/2] tun: add missing rx stats accounting in tun_xdp_act

Message ID 1705659776-21108-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Accepted
Commit f1084c427f55d573fcd5688d9ba7b31b78019716
Delegated to: Netdev Maintainers
Headers show
Series fixes for tun | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1077 this patch: 1077
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1095 this patch: 1095
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1095 this patch: 1095
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-01-20--06-00 (tests: 403)

Commit Message

wangyunjian Jan. 19, 2024, 10:22 a.m. UTC
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: 761876c857cb ("tap: XDP support")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/tun.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Willem de Bruijn Jan. 19, 2024, 3:23 p.m. UTC | #1
Yunjian Wang wrote:
> 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: 761876c857cb ("tap: XDP support")
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>
Jason Wang Jan. 22, 2024, 3:40 a.m. UTC | #2
On Fri, Jan 19, 2024 at 6:23 PM Yunjian Wang <wangyunjian@huawei.com> wrote:
>
> 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: 761876c857cb ("tap: XDP support")
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks
diff mbox series

Patch

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 237fef557ba5..4a4f8c8e79fa 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -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);
 			return err;
 		}
+		dev_sw_netstats_rx_add(tun->dev, xdp->data_end - xdp->data);
 		break;
 	case XDP_TX:
 		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,
 			dev_core_stats_rx_dropped_inc(tun->dev);
 			return err;
 		}
+		dev_sw_netstats_rx_add(tun->dev, xdp->data_end - xdp->data);
 		break;
 	case XDP_PASS:
 		break;