Skip to content

Commit 4cc4394

Browse files
vladimirolteankuba-moo
authored andcommitted
net: dsa: add more extack messages in dsa_user_add_cls_matchall_mirred()
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c11ace1 commit 4cc4394

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

net/dsa/user.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,11 +1376,17 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev,
13761376
struct dsa_port *to_dp;
13771377
int err;
13781378

1379-
if (cls->common.protocol != htons(ETH_P_ALL))
1379+
if (cls->common.protocol != htons(ETH_P_ALL)) {
1380+
NL_SET_ERR_MSG_MOD(extack,
1381+
"Can only offload \"protocol all\" matchall filter");
13801382
return -EOPNOTSUPP;
1383+
}
13811384

1382-
if (!ds->ops->port_mirror_add)
1385+
if (!ds->ops->port_mirror_add) {
1386+
NL_SET_ERR_MSG_MOD(extack,
1387+
"Switch does not support mirroring operation");
13831388
return -EOPNOTSUPP;
1389+
}
13841390

13851391
if (!flow_action_basic_hw_stats_check(&cls->rule->action, extack))
13861392
return -EOPNOTSUPP;
@@ -1487,16 +1493,21 @@ static int dsa_user_add_cls_matchall(struct net_device *dev,
14871493
bool ingress)
14881494
{
14891495
const struct flow_action *action = &cls->rule->action;
1496+
struct netlink_ext_ack *extack = cls->common.extack;
14901497

1491-
if (!flow_offload_has_one_action(action))
1498+
if (!flow_offload_has_one_action(action)) {
1499+
NL_SET_ERR_MSG_MOD(extack,
1500+
"Cannot offload matchall filter with more than one action");
14921501
return -EOPNOTSUPP;
1502+
}
14931503

14941504
switch (action->entries[0].id) {
14951505
case FLOW_ACTION_MIRRED:
14961506
return dsa_user_add_cls_matchall_mirred(dev, cls, ingress);
14971507
case FLOW_ACTION_POLICE:
14981508
return dsa_user_add_cls_matchall_police(dev, cls, ingress);
14991509
default:
1510+
NL_SET_ERR_MSG_MOD(extack, "Unknown action");
15001511
break;
15011512
}
15021513

0 commit comments

Comments
 (0)