]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: dsa: add more extack messages in dsa_user_add_cls_matchall_mirred()
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 23 Oct 2024 13:52:49 +0000 (16:52 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 31 Oct 2024 00:33:54 +0000 (17:33 -0700)
Do not leave -EOPNOTSUPP errors without an explanation. It is confusing
for the user to figure out what is wrong otherwise.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20241023135251.1752488-5-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/dsa/user.c

index a89425a8de2e5e3467a40fee5c0db756e73a1196..398418cd0b78a8a02b0d9542e9eab28d9c020b07 100644 (file)
@@ -1376,11 +1376,17 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev,
        struct dsa_port *to_dp;
        int err;
 
-       if (cls->common.protocol != htons(ETH_P_ALL))
+       if (cls->common.protocol != htons(ETH_P_ALL)) {
+               NL_SET_ERR_MSG_MOD(extack,
+                                  "Can only offload \"protocol all\" matchall filter");
                return -EOPNOTSUPP;
+       }
 
-       if (!ds->ops->port_mirror_add)
+       if (!ds->ops->port_mirror_add) {
+               NL_SET_ERR_MSG_MOD(extack,
+                                  "Switch does not support mirroring operation");
                return -EOPNOTSUPP;
+       }
 
        if (!flow_action_basic_hw_stats_check(&cls->rule->action, extack))
                return -EOPNOTSUPP;
@@ -1487,9 +1493,13 @@ static int dsa_user_add_cls_matchall(struct net_device *dev,
                                     bool ingress)
 {
        const struct flow_action *action = &cls->rule->action;
+       struct netlink_ext_ack *extack = cls->common.extack;
 
-       if (!flow_offload_has_one_action(action))
+       if (!flow_offload_has_one_action(action)) {
+               NL_SET_ERR_MSG_MOD(extack,
+                                  "Cannot offload matchall filter with more than one action");
                return -EOPNOTSUPP;
+       }
 
        switch (action->entries[0].id) {
        case FLOW_ACTION_MIRRED:
@@ -1497,6 +1507,7 @@ static int dsa_user_add_cls_matchall(struct net_device *dev,
        case FLOW_ACTION_POLICE:
                return dsa_user_add_cls_matchall_police(dev, cls, ingress);
        default:
+               NL_SET_ERR_MSG_MOD(extack, "Unknown action");
                break;
        }