diff mbox series

[net,1/2] tun: fix missing dropped counter in tun_xdp_act

Message ID 1705659755-39828-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Accepted
Commit 5744ba05e7c4bff8fec133dd0f9e51ddffba92f5
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, 19 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 commit 8ae1aff0b331 ("tuntap: split out XDP logic") includes
dropped counter for XDP_DROP, XDP_ABORTED, and invalid XDP actions.
Unfortunately, that commit missed the dropped counter when error
occurs during XDP_TX and XDP_REDIRECT actions. This patch fixes
this issue.

Fixes: 8ae1aff0b331 ("tuntap: split out XDP logic")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/tun.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Willem de Bruijn Jan. 19, 2024, 3:22 p.m. UTC | #1
Yunjian Wang wrote:
> The commit 8ae1aff0b331 ("tuntap: split out XDP logic") includes
> dropped counter for XDP_DROP, XDP_ABORTED, and invalid XDP actions.
> Unfortunately, that commit missed the dropped counter when error
> occurs during XDP_TX and XDP_REDIRECT actions. This patch fixes
> this issue.
> 
> Fixes: 8ae1aff0b331 ("tuntap: split out XDP logic")
> 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:22 PM Yunjian Wang <wangyunjian@huawei.com> wrote:
>
> The commit 8ae1aff0b331 ("tuntap: split out XDP logic") includes
> dropped counter for XDP_DROP, XDP_ABORTED, and invalid XDP actions.
> Unfortunately, that commit missed the dropped counter when error
> occurs during XDP_TX and XDP_REDIRECT actions. This patch fixes
> this issue.
>
> Fixes: 8ae1aff0b331 ("tuntap: split out XDP logic")
> 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 afa5497f7c35..237fef557ba5 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1630,13 +1630,17 @@  static int tun_xdp_act(struct tun_struct *tun, struct bpf_prog *xdp_prog,
 	switch (act) {
 	case XDP_REDIRECT:
 		err = xdp_do_redirect(tun->dev, xdp, xdp_prog);
-		if (err)
+		if (err) {
+			dev_core_stats_rx_dropped_inc(tun->dev);
 			return err;
+		}
 		break;
 	case XDP_TX:
 		err = tun_xdp_tx(tun->dev, xdp);
-		if (err < 0)
+		if (err < 0) {
+			dev_core_stats_rx_dropped_inc(tun->dev);
 			return err;
+		}
 		break;
 	case XDP_PASS:
 		break;