netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	David Ahern <dsahern@kernel.org>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCHv2 iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG
Date: Tue, 17 Jan 2023 15:19:25 +0800	[thread overview]
Message-ID: <20230117071925.3707106-3-liuhangbin@gmail.com> (raw)
In-Reply-To: <20230117071925.3707106-1-liuhangbin@gmail.com>

Currently, when the rule is not to be exclusively executed by the
hardware, extack is not passed along and offloading failures don't
get logged. Add a new attr TCA_EXT_WARN_MSG to log the extack message
so we can monitor the HW failures. e.g.

  # tc monitor
  added chain dev enp3s0f1np1 parent ffff: chain 0
  added filter dev enp3s0f1np1 ingress protocol all pref 49152 flower chain 0 handle 0x1
    ct_state +trk+new
    not_in_hw
          action order 1: gact action drop
           random type none pass val 0
           index 1 ref 1 bind 1

  mlx5_core: matching on ct_state +new isn't supported.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
v2: Add a helper to print the warn message. I still print the msg in
json ojbect given the disscuss in
https://lore.kernel.org/all/20230114090311.1adf0176@hermes.local/
---
 include/uapi/linux/rtnetlink.h | 1 +
 tc/m_action.c                  | 1 +
 tc/tc_filter.c                 | 1 +
 tc/tc_qdisc.c                  | 2 ++
 tc/tc_util.c                   | 9 +++++++++
 tc/tc_util.h                   | 2 ++
 6 files changed, 16 insertions(+)

diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index f4a540c0..217b25b9 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -635,6 +635,7 @@ enum {
 	TCA_INGRESS_BLOCK,
 	TCA_EGRESS_BLOCK,
 	TCA_DUMP_FLAGS,
+	TCA_EXT_WARN_MSG,
 	__TCA_MAX
 };
 
diff --git a/tc/m_action.c b/tc/m_action.c
index b3fd0193..b45c4936 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -590,6 +590,7 @@ int print_action(struct nlmsghdr *n, void *arg)
 
 	open_json_object(NULL);
 	tc_dump_action(fp, tb[TCA_ACT_TAB], tot_acts ? *tot_acts:0, false);
+	print_ext_msg(tb);
 	close_json_object();
 
 	return 0;
diff --git a/tc/tc_filter.c b/tc/tc_filter.c
index 71be2e81..cfc72c00 100644
--- a/tc/tc_filter.c
+++ b/tc/tc_filter.c
@@ -371,6 +371,7 @@ int print_filter(struct nlmsghdr *n, void *arg)
 		print_nl();
 	}
 
+	print_ext_msg(tb);
 	close_json_object();
 	fflush(fp);
 	return 0;
diff --git a/tc/tc_qdisc.c b/tc/tc_qdisc.c
index 33a6665e..faa8daed 100644
--- a/tc/tc_qdisc.c
+++ b/tc/tc_qdisc.c
@@ -346,6 +346,8 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
 			print_nl();
 		}
 	}
+
+	print_ext_msg(tb);
 	close_json_object();
 	fflush(fp);
 	return 0;
diff --git a/tc/tc_util.c b/tc/tc_util.c
index d2622063..aee25f0b 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -848,3 +848,12 @@ void print_masked_be16(const char *name, struct rtattr *attr,
 	print_masked_type(UINT16_MAX, __rta_getattr_be16_u32, name, attr,
 			  mask_attr, newline);
 }
+
+void print_ext_msg(struct rtattr **tb)
+{
+	if (!tb[TCA_EXT_WARN_MSG])
+		return;
+
+	print_string(PRINT_ANY, "warn", "%s", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+	print_nl();
+}
diff --git a/tc/tc_util.h b/tc/tc_util.h
index a3fa7360..c535dccb 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -133,4 +133,6 @@ void print_masked_u8(const char *name, struct rtattr *attr,
 		     struct rtattr *mask_attr, bool newline);
 void print_masked_be16(const char *name, struct rtattr *attr,
 		       struct rtattr *mask_attr, bool newline);
+
+void print_ext_msg(struct rtattr **tb);
 #endif
-- 
2.38.1


  parent reply	other threads:[~2023-01-17  7:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13  3:43 [PATCHv4 net-next] sched: add new attr TCA_EXT_WARN_MSG to report tc extact message Hangbin Liu
2023-01-13  3:46 ` [PATCH iproute2-next 1/2] Revert "tc/tc_monitor: print netlink extack message" Hangbin Liu
2023-01-13  3:46   ` [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG Hangbin Liu
2023-01-13  4:00     ` Hangbin Liu
2023-01-13  4:30     ` Stephen Hemminger
2023-01-13  6:20       ` Hangbin Liu
2023-01-14 12:59       ` Jamal Hadi Salim
2023-01-14 17:03         ` Stephen Hemminger
2023-01-17 15:09           ` Jamal Hadi Salim
2023-01-31  9:53             ` Hangbin Liu
2023-01-14  2:15     ` David Ahern
2023-01-14  6:15 ` [PATCHv4 net-next] sched: add new attr TCA_EXT_WARN_MSG to report tc extact message Jakub Kicinski
2023-01-14 12:19   ` Jamal Hadi Salim
2023-01-17  7:19 ` [PATCHv2 iproute2-next 0/2] tc: add new attr TCA_EXT_WARN_MSG Hangbin Liu
2023-01-17  7:19   ` [PATCHv2 iproute2-next 1/2] Revert "tc/tc_monitor: print netlink extack message" Hangbin Liu
2023-01-17  7:19   ` Hangbin Liu [this message]
2023-01-22 18:10   ` [PATCHv2 iproute2-next 0/2] tc: add new attr TCA_EXT_WARN_MSG patchwork-bot+netdevbpf
2023-01-17  8:50 ` [PATCHv4 net-next] sched: add new attr TCA_EXT_WARN_MSG to report tc extact message patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230117071925.3707106-3-liuhangbin@gmail.com \
    --to=liuhangbin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stephen@networkplumber.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).