net/sched: flower: Take verbose flag into account when logging error messages
authorIdo Schimmel <idosch@nvidia.com>
Thu, 7 Apr 2022 07:35:21 +0000 (10:35 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Apr 2022 12:45:43 +0000 (13:45 +0100)
The verbose flag was added in commit 81c7288b170a ("sched: cls: enable
verbose logging") to avoid suppressing logging of error messages that
occur "when the rule is not to be exclusively executed by the hardware".

However, such error messages are currently suppressed when setup of flow
action fails. Take the verbose flag into account to avoid suppressing
error messages. This is done by using the extack pointer initialized by
tc_cls_common_offload_init(), which performs the necessary checks.

Before:

 # tc filter add dev dummy0 ingress pref 1 proto ip flower dst_ip 198.51.100.1 action police rate 100Mbit burst 10000
 # tc filter add dev dummy0 ingress pref 2 proto ip flower verbose dst_ip 198.51.100.1 action police rate 100Mbit burst 10000

After:

 # tc filter add dev dummy0 ingress pref 1 proto ip flower dst_ip 198.51.100.1 action police rate 100Mbit burst 10000
 # tc filter add dev dummy0 ingress pref 2 proto ip flower verbose dst_ip 198.51.100.1 action police rate 100Mbit burst 10000
 Warning: cls_flower: Failed to setup flow action.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_flower.c

index c80fc49..70e95ce 100644 (file)
@@ -467,11 +467,10 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
        err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts);
        if (err) {
                kfree(cls_flower.rule);
-               if (skip_sw) {
-                       NL_SET_ERR_MSG_MOD(extack, "Failed to setup flow action");
-                       return err;
-               }
-               return 0;
+               NL_SET_ERR_MSG_MOD(cls_flower.common.extack,
+                                  "Failed to setup flow action");
+
+               return skip_sw ? err : 0;
        }
 
        err = tc_setup_cb_add(block, tp, TC_SETUP_CLSFLOWER, &cls_flower,
@@ -2357,8 +2356,9 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb,
                err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts);
                if (err) {
                        kfree(cls_flower.rule);
+                       NL_SET_ERR_MSG_MOD(cls_flower.common.extack,
+                                          "Failed to setup flow action");
                        if (tc_skip_sw(f->flags)) {
-                               NL_SET_ERR_MSG_MOD(extack, "Failed to setup flow action");
                                __fl_put(f);
                                return err;
                        }