Skip to contentSkip to conversation

sched: add new attr TCA_EXT_WARN_MSG to report tc extact message

PATCH Applied Hangbin Liu 6 participants 18 messages Jan 13, 2023 – Jan 31, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 sched: add new attr TCA_EXT_WARN_MSG to report tc extact message

We will report extack message if there is an error via netlink_ack(). But if the rule is not to be exclusively executed by the hardware, extack is not passed along and offloading failures don't get logged.

In commit 81c7288b170a ("sched: cls: enable verbose logging") Marcelo made cls could log verbose info for offloading failures, which helps improving Open vSwitch debuggability when using flower offloading.

It would also be helpful if userspace monitor tools, like "tc monitor", could log this kind of message, as it doesn't require vswitchd log level adjusment. Let's add a new tc attributes to report the extack message so the monitor program could receive the 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

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

In this patch I only report the extack message on add/del operations. It doesn't look like we need to report the extack message on get/dump operations.

Note this message not only reporte to multicast groups, it could also be reported unicast, which may affect the current usersapce tool's behaivor.

---
v4: use specific tc attributes to wrap the warn message
v3: also add this feature for qdisc, class, action, chain notify
v2: use NLMSG_ERROR instad of NLMSG_DONE to report the extack message

---
 include/uapi/linux/rtnetlink.h |  1 +
 net/sched/act_api.c            | 15 +++++---
 net/sched/cls_api.c            | 62 +++++++++++++++++++++-------------
 net/sched/sch_api.c            | 55 ++++++++++++++++++------------
 4 files changed, 84 insertions(+), 49 deletions(-)
include/uapi/linux/rtnetlink.h +1 -0
index eb2747d58a81..25a0af57dd5e 100644
@@ -635,6 +635,7 @@ enum {
 	TCA_INGRESS_BLOCK,
 	TCA_EGRESS_BLOCK,
 	TCA_DUMP_FLAGS,
+	TCA_EXT_WARN_MSG,
 	__TCA_MAX
 };
 
net/sched/act_api.c +10 -5
index 5b3c0ac495be..cd09ef49df22 100644
@@ -1582,7 +1582,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *p,
 
 static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],
 			u32 portid, u32 seq, u16 flags, int event, int bind,
-			int ref)
+			int ref, struct netlink_ext_ack *extack)
 {
 	struct tcamsg *t;
 	struct nlmsghdr *nlh;
@@ -1606,7 +1606,12 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],
 
 	nla_nest_end(skb, nest);
 
+	if (extack && extack->_msg &&
+	    nla_put_string(skb, TCA_EXT_WARN_MSG, extack->_msg))
+		goto out_nlmsg_trim;
+
 	nlh->nlmsg_len = skb_tail_pointer(skb) - b;
+
 	return skb->len;
 
 out_nlmsg_trim:
@@ -1625,7 +1630,7 @@ tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
 	if (!skb)
 		return -ENOBUFS;
 	if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, event,
-			 0, 1) <= 0) {
+			 0, 1, NULL) <= 0) {
 		NL_SET_ERR_MSG(extack, "Failed to fill netlink attributes while adding TC action");
 		kfree_skb(skb);
 		return -EINVAL;
@@ -1799,7 +1804,7 @@ tcf_reoffload_del_notify(struct net *net, struct tc_action *action)
 	if (!skb)
 		return -ENOBUFS;
 
-	if (tca_get_fill(skb, actions, 0, 0, 0, RTM_DELACTION, 0, 1) <= 0) {
+	if (tca_get_fill(skb, actions, 0, 0, 0, RTM_DELACTION, 0, 1, NULL) <= 0) {
 		kfree_skb(skb);
 		return -EINVAL;
 	}
@@ -1886,7 +1891,7 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[],
 		return -ENOBUFS;
 
 	if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, RTM_DELACTION,
-			 0, 2) <= 0) {
+			 0, 2, extack) <= 0) {
 		NL_SET_ERR_MSG(extack, "Failed to fill netlink TC action attributes");
 		kfree_skb(skb);
 		return -EINVAL;
@@ -1965,7 +1970,7 @@ tcf_add_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[],
 		return -ENOBUFS;
 
 	if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, n->nlmsg_flags,
-			 RTM_NEWACTION, 0, 0) <= 0) {
+			 RTM_NEWACTION, 0, 0, extack) <= 0) {
 		NL_SET_ERR_MSG(extack, "Failed to fill netlink attributes while adding TC action");
 		kfree_skb(skb);
 		return -EINVAL;
net/sched/cls_api.c +39 -23

204 lines not on this page · raw message

net/sched/sch_api.c +34 -21

181 lines not on this page · raw message

Signature · 1 line
2.38.1
#1 lore raw

PATCH v2 1/2 Revert "tc/tc_monitor: print netlink extack message"

This reverts commit 0cc5533b ("tc/tc_monitor: print netlink extack message") as the commit mentioned is not applied to upstream.

---
 tc/tc_monitor.c | 3 ---
 1 file changed, 3 deletions(-)
tc/tc_monitor.c +0 -3
index 64f31491..b656cfbc 100644
@@ -42,9 +42,6 @@ static int accept_tcmsg(struct rtnl_ctrl_data *ctrl,
 	if (timestamp)
 		print_timestamp(fp);
 
-	if (n->nlmsg_type == NLMSG_DONE)
-		nl_dump_ext_ack_done(n, 0, 0);
-
 	if (n->nlmsg_type == RTM_NEWTFILTER ||
 	    n->nlmsg_type == RTM_DELTFILTER ||
 	    n->nlmsg_type == RTM_NEWCHAIN ||
Signature · 1 line
2.38.1
#2 lore raw

PATCH v2 2/2 tc: add new attr TCA_EXT_WARN_MSG

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

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

---
 include/uapi/linux/rtnetlink.h | 1 +
 tc/m_action.c                  | 6 ++++++
 tc/tc_filter.c                 | 5 +++++
 tc/tc_qdisc.c                  | 6 ++++++
 4 files changed, 18 insertions(+)
include/uapi/linux/rtnetlink.h +1 -0
index f4a540c0..217b25b9 100644
@@ -635,6 +635,7 @@ enum {
 	TCA_INGRESS_BLOCK,
 	TCA_EGRESS_BLOCK,
 	TCA_DUMP_FLAGS,
+	TCA_EXT_WARN_MSG,
 	__TCA_MAX
 };
 
tc/m_action.c +6 -0
index b3fd0193..7121c2fb 100644
@@ -590,6 +590,12 @@ 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);
+
+	if (tb[TCA_EXT_WARN_MSG]) {
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+
 	close_json_object();
 
 	return 0;
tc/tc_filter.c +5 -0
index 71be2e81..dac74f58 100644
@@ -371,6 +371,11 @@ int print_filter(struct nlmsghdr *n, void *arg)
 		print_nl();
 	}
 
+	if (tb[TCA_EXT_WARN_MSG]) {
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+
 	close_json_object();
 	fflush(fp);
 	return 0;
tc/tc_qdisc.c +6 -0
index 33a6665e..a84602b4 100644
@@ -346,6 +346,12 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
 			print_nl();
 		}
 	}
+
+	if (tb[TCA_EXT_WARN_MSG]) {
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+
 	close_json_object();
 	fflush(fp);
 	return 0;
Signature · 1 line
2.38.1
#3 lore raw

Re: [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG

Hi David,

Oh, I forgot to add --no-thread when send this patch. Sorry if this makes any trouble for you.

Hangbin

Quoted 89 lines · Hangbin Liu

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

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

---
 include/uapi/linux/rtnetlink.h | 1 +
 tc/m_action.c                  | 6 ++++++
 tc/tc_filter.c                 | 5 +++++
 tc/tc_qdisc.c                  | 6 ++++++
 4 files changed, 18 insertions(+)
include/uapi/linux/rtnetlink.h +1 -0
index f4a540c0..217b25b9 100644
@@ -635,6 +635,7 @@ enum {
 	TCA_INGRESS_BLOCK,
 	TCA_EGRESS_BLOCK,
 	TCA_DUMP_FLAGS,
+	TCA_EXT_WARN_MSG,
 	__TCA_MAX
 };
 
tc/m_action.c +6 -0
index b3fd0193..7121c2fb 100644
@@ -590,6 +590,12 @@ 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);
+
+	if (tb[TCA_EXT_WARN_MSG]) {
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+
 	close_json_object();
 
 	return 0;
tc/tc_filter.c +5 -0
index 71be2e81..dac74f58 100644
@@ -371,6 +371,11 @@ int print_filter(struct nlmsghdr *n, void *arg)
 		print_nl();
 	}
 
+	if (tb[TCA_EXT_WARN_MSG]) {
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+
 	close_json_object();
 	fflush(fp);
 	return 0;
tc/tc_qdisc.c +6 -0
index 33a6665e..a84602b4 100644
@@ -346,6 +346,12 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
 			print_nl();
 		}
 	}
+
+	if (tb[TCA_EXT_WARN_MSG]) {
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+
 	close_json_object();
 	fflush(fp);
 	return 0;
Signature · 1 line
2.38.1
#4 lore raw

Re: [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG

In reply to Hangbin Liu

tc/m_action.c int print_action(struct nlmsghdr *n, void *arg) · line 598

Quoted 5 lines · On Fri, 13 Jan 2023 11:46:17 +0800 Hangbin Liu <[email protected]> wrote:
	if (tb[TCA_EXT_WARN_MSG]) {
tc/m_action.c +4 -0
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+

Errors should go to stderr, and not to stdout. And no JSON support please.

#5 lore raw

Re: [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG

Quoted 10 lines · Stephen Hemminger

tc/m_action.c int print_action(struct nlmsghdr *n, void *arg) · line 598

Quoted 5 lines · On Fri, 13 Jan 2023 11:46:17 +0800 Hangbin Liu <[email protected]> wrote:
	if (tb[TCA_EXT_WARN_MSG]) {
tc/m_action.c +4 -0
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+

Errors should go to stderr, and not to stdout. And no JSON support please.

Thanks, I thought this belongs to an attr data. So I put it in the JSON object. I will adjust this to stderr and out side of JSON.

Hangbin

maintainer
#6 lore raw

Re: [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG

In reply to Stephen Hemminger

This is not really an error IMO (and therefore doesnt belong in stderr). If i send a request to add an
entry and ask that it is installed both in the kernel as well as offloaded into h/w and half of that
worked (example hardware rejected it for some reason) then the event generated (as observed by
f.e. tc mon) will appear in TCA_EXT_WARN_MSG and the consumer of that event needs to see it
if they are using the json format.

cheers,
jamal

Quoted 11 lines · Stephen Hemminger

tc/m_action.c int print_action(struct nlmsghdr *n, void *arg) · line 598

Quoted 5 lines · On Fri, 13 Jan 2023 11:46:17 +0800 Hangbin Liu <[email protected]> wrote:
      if (tb[TCA_EXT_WARN_MSG]) {
tc/m_action.c +4 -0
+             print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+             print_nl();
+     }
+

Errors should go to stderr, and not to stdout. And no JSON support please.

#7 lore raw

Re: [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG

Quoted 10 lines · On Sat, 14 Jan 2023 07:59:39 -0500 Jamal Hadi Salim <[email protected]> wrote:

This is not really an error IMO (and therefore doesnt belong in stderr). If i send a request to add an
entry and ask that it is installed both in the kernel as well as offloaded into h/w and half of that
worked (example hardware rejected it for some reason) then the event generated (as observed by
f.e. tc mon) will appear in TCA_EXT_WARN_MSG and the consumer of that event needs to see it
if they are using the json format.

Ok, but use lower case for JSON tag following existing conventions.

Note: json support in monitor mode is incomplete for many of the commands bridge, ip, tc, devlink. It doesn't always generate valid JSON yet.

maintainer
#8 lore raw

Re: [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG

Quoted 4 lines · Stephen Hemminger

On Sat, 14 Jan 2023 07:59:39 -0500
Jamal Hadi Salim <[email protected]> wrote:

[..]

Quoted 6 lines

Ok, but use lower case for JSON tag following existing conventions.

Note: json support in monitor mode is incomplete for many of the commands bridge, ip, tc, devlink. It doesn't always generate valid JSON yet.

We can work for starters with the tc one and maybe cover ip as well...

cheers,
jamal

#9 lore raw

Re: [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG

Quoted 7 lines · Jamal Hadi Salim
Quoted 5 lines

Ok, but use lower case for JSON tag following existing conventions.

Note: json support in monitor mode is incomplete for many of the commands bridge, ip, tc, devlink. It doesn't always generate valid JSON yet.

We can work for starters with the tc one and maybe cover ip as well...

I tried adding the JSON obj for ip monitor. There are 2 choices and some issues.

If we open JSON before/after accept_msg:

ip/ipmonitor.c +6 -1
index 9b055264..a6944636 100644
@@ -338,8 +338,13 @@ int do_ipmonitor(int argc, char **argv)
        netns_nsid_socket_init();
        netns_map_init();
 
-       if (rtnl_listen(&rth, accept_msg, stdout) < 0)
+       new_json_obj(json);
+       if (rtnl_listen(&rth, accept_msg, stdout) < 0) {
+               delete_json_obj();
                exit(2);
+       }
+
+       delete_json_obj();
 
        return 0;
 }

The JSON output looks like the following result, the ifindex is not quoted in the braces. And the JSON format is not complete at the end.

# ip/ip -j -p monitor
[ {
        "family": "inet",
        "interface": "veth0",
        "forwarding": false,
        "rp_filter": "strict",
        "mc_forwarding": false,
        "proxy_neigh": false,
        "ignore_routes_with_linkdown": false
    },{
        "family": "inet6",
        "interface": "veth0",
        "forwarding": false,
        "mc_forwarding": false,
        "proxy_neigh": false,
        "ignore_routes_with_linkdown": false
    },
    "ifindex": 17,
    "link": null,
    "ifname": "veth0",
    "flags": [ "BROADCAST","MULTICAST" ],
    "mtu": 1500,
    "qdisc": "noop",
    "operstate": "DOWN",
    "group": "default",
    "link_type": "ether",
    "address": "72:4f:8c:32:13:63",
    "broadcast": "ff:ff:ff:ff:ff:ff",{
        "family": "inet",
        "interface": "veth1",
        "forwarding": false,
        "rp_filter": "strict",
        "mc_forwarding": false,
        "proxy_neigh": false,
        "ignore_routes_with_linkdown": false
    },{
        "family": "inet6",
        "interface": "veth1",
        "forwarding": false,
        "mc_forwarding": false,
        "proxy_neigh": false,
        "ignore_routes_with_linkdown": false
    },
    "ifindex": 18,
    "link": "veth0",
    "ifname": "veth1",
    "flags": [ "BROADCAST","MULTICAST","M-DOWN" ],
    "mtu": 1500,
    "qdisc": "noop",
    "operstate": "DOWN",
    "group": "default",
    "link_type": "ether",
    "address": "42:75:b7:38:9c:ad",
    "broadcast": "ff:ff:ff:ff:ff:ff",{
        "dst": "fe80::ee3e:f701:b990:8a61",
        "dev": "eth0",
        "lladdr": "ec:3e:f7:90:8a:61",
        "router": null,
        "state": [ "STALE" ]
    }^C

If we open JSON in the accept_msg(). Like:

ip/ipmonitor.c +3 -2
index 9b055264..4af18a6c 100644
@@ -55,6 +55,7 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,
 {
        FILE *fp = (FILE *)arg;
 
+       new_json_obj(json);
        switch (n->nlmsg_type) {
        case RTM_NEWROUTE:
        case RTM_DELROUTE: {
@@ -63,21 +64,21 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,
 
                if (len < 0) {
                        fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
-                       return -1;
+                       goto err_out;
                }
 
                if (r->rtm_flags & RTM_F_CLONED)
-                       return 0;
+                       goto out;
 

[...]

@@ -170,7 +171,14 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,

                        n->nlmsg_flags, n->nlmsg_flags, n->nlmsg_len,
                        n->nlmsg_len);
        }
+
+out:
+       delete_json_obj();
        return 0;

+
+err_out:
+ delete_json_obj();
+ return -1;
}

The result would like:

# ./ip/ip -j monitor
[{"deleted":true,"family":"inet","interface":"veth0"}]
[{"deleted":true,"family":"inet6","interface":"veth0"}]
[{"deleted":true,"family":"inet","interface":"veth1"}]
[{"deleted":true,"family":"inet6","interface":"veth1"}]

This format looks good, but I'm not sure if the JSON output is valid with list for each line.

Any comments?

Thanks
Hangbin

#10 lore raw

Re: [PATCH iproute2-next 2/2] tc: add new attr TCA_EXT_WARN_MSG

In reply to Hangbin Liu
Quoted 5 lines · Hangbin Liu
tc/tc_qdisc.c +0 -0
index 33a6665e..a84602b4 100644

tc/tc_qdisc.c int print_qdisc(struct nlmsghdr *n, void *arg) · line 354

Quoted 9 lines
tc/tc_qdisc.c +6 -0
@@ -346,6 +346,12 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
 			print_nl();
 		}
 	}
+
+	if (tb[TCA_EXT_WARN_MSG]) {
+		print_string(PRINT_ANY, "Warn", "%s ", rta_getattr_str(tb[TCA_EXT_WARN_MSG]));
+		print_nl();
+	}
+

given the repetition with the WARN_MSG, how about a helper in tc_util.c

maintainer Acked-by on v4 1/1
#11 lore raw
In reply to Hangbin Liu
Quoted 3 lines · On Fri, 13 Jan 2023 11:43:53 +0800 Hangbin Liu wrote:

We will report extack message if there is an error via netlink_ack(). But if the rule is not to be exclusively executed by the hardware, extack is not passed along and offloading failures don't get logged.

#13 lore raw

v2 cover tc: add new attr TCA_EXT_WARN_MSG

In reply to Hangbin Liu

This patch set revert commit 0cc5533b ("tc/tc_monitor: print netlink extack message") as we never used it. Then add new attr TCA_EXT_WARN_MSG to print the extack message as we proposed in the net-next patch.

I would reply to the kernel patch directly as it's not updated.

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/[email protected]/

Hangbin Liu (2):
Revert "tc/tc_monitor: print netlink extack message"
tc: add new attr TCA_EXT_WARN_MSG

 include/uapi/linux/rtnetlink.h | 1 +
 tc/m_action.c                  | 1 +
 tc/tc_filter.c                 | 1 +
 tc/tc_monitor.c                | 3 ---
 tc/tc_qdisc.c                  | 2 ++
 tc/tc_util.c                   | 9 +++++++++
 tc/tc_util.h                   | 2 ++
 7 files changed, 16 insertions(+), 3 deletions(-)
Signature · 1 line
2.38.1
#14 lore raw

PATCH v2 1/2 Revert "tc/tc_monitor: print netlink extack message"

This reverts commit 0cc5533b ("tc/tc_monitor: print netlink extack message") as the commit mentioned is not applied to upstream.

---
v2: no update

---
 tc/tc_monitor.c | 3 ---
 1 file changed, 3 deletions(-)
tc/tc_monitor.c +0 -3
index 64f31491..b656cfbc 100644
@@ -42,9 +42,6 @@ static int accept_tcmsg(struct rtnl_ctrl_data *ctrl,
 	if (timestamp)
 		print_timestamp(fp);
 
-	if (n->nlmsg_type == NLMSG_DONE)
-		nl_dump_ext_ack_done(n, 0, 0);
-
 	if (n->nlmsg_type == RTM_NEWTFILTER ||
 	    n->nlmsg_type == RTM_DELTFILTER ||
 	    n->nlmsg_type == RTM_NEWCHAIN ||
Signature · 1 line
2.38.1
#15 lore raw

PATCH v2 2/2 tc: add new attr TCA_EXT_WARN_MSG

In reply to Hangbin Liu

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.

---
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/[email protected]/

---
 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(+)
include/uapi/linux/rtnetlink.h +1 -0
index f4a540c0..217b25b9 100644
@@ -635,6 +635,7 @@ enum {
 	TCA_INGRESS_BLOCK,
 	TCA_EGRESS_BLOCK,
 	TCA_DUMP_FLAGS,
+	TCA_EXT_WARN_MSG,
 	__TCA_MAX
 };
 
tc/m_action.c +1 -0
index b3fd0193..b45c4936 100644
@@ -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;
tc/tc_filter.c +1 -0
index 71be2e81..cfc72c00 100644
@@ -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;
tc/tc_qdisc.c +2 -0
index 33a6665e..faa8daed 100644
@@ -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;
tc/tc_util.c +9 -0
index d2622063..aee25f0b 100644
@@ -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();
+}
tc/tc_util.h +2 -0
index a3fa7360..c535dccb 100644
@@ -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
Signature · 1 line
2.38.1
#16 lore raw

Re: [PATCHv2 iproute2-next 0/2] tc: add new attr TCA_EXT_WARN_MSG

In reply to Hangbin Liu
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Hello:

This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Quoted 11 lines · On Tue, 17 Jan 2023 15:19:23 +0800 you wrote:

This patch set revert commit 0cc5533b ("tc/tc_monitor: print netlink extack message") as we never used it. Then add new attr TCA_EXT_WARN_MSG to print the extack message as we proposed in the net-next patch.

I would reply to the kernel patch directly as it's not updated.

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/[email protected]/

[...]

Here is the summary with links:
- [PATCHv2,iproute2-next,1/2] Revert "tc/tc_monitor: print netlink extack message"

    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=77d4425560ce

- [PATCHv2,iproute2-next,2/2] tc: add new attr TCA_EXT_WARN_MSG (no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#17 lore raw
In reply to Hangbin Liu
This patch was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Fri, 13 Jan 2023 11:43:53 +0800 you wrote:

We will report extack message if there is an error via netlink_ack(). But if the rule is not to be exclusively executed by the hardware, extack is not passed along and offloading failures don't get logged.

In commit 81c7288b170a ("sched: cls: enable verbose logging") Marcelo made cls could log verbose info for offloading failures, which helps improving Open vSwitch debuggability when using flower offloading.

[...]

Here is the summary with links:
- [PATCHv4,net-next] sched: add new attr TCA_EXT_WARN_MSG to report tc extact message

    https://git.kernel.org/netdev/net-next/c/0349b8779cc9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html