Commit 4947e730 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_matchall: Perform protocol check earlier

Perform the protocol check earlier in the function instead of repeating
it for every action. Example:

 # tc filter add dev swp1 ingress proto ip matchall skip_sw action sample group 1 rate 100
 Error: matchall rules only supported with 'all' protocol.
 We have an error talking to the kernel
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 32e67c0a
...@@ -238,6 +238,11 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp, ...@@ -238,6 +238,11 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp,
flower_prio_valid = true; flower_prio_valid = true;
} }
if (protocol != htons(ETH_P_ALL)) {
NL_SET_ERR_MSG(f->common.extack, "matchall rules only supported with 'all' protocol");
return -EOPNOTSUPP;
}
mall_entry = kzalloc(sizeof(*mall_entry), GFP_KERNEL); mall_entry = kzalloc(sizeof(*mall_entry), GFP_KERNEL);
if (!mall_entry) if (!mall_entry)
return -ENOMEM; return -ENOMEM;
...@@ -247,7 +252,7 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp, ...@@ -247,7 +252,7 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp,
act = &f->rule->action.entries[0]; act = &f->rule->action.entries[0];
if (act->id == FLOW_ACTION_MIRRED && protocol == htons(ETH_P_ALL)) { if (act->id == FLOW_ACTION_MIRRED) {
if (flower_prio_valid && mall_entry->ingress && if (flower_prio_valid && mall_entry->ingress &&
mall_entry->priority >= flower_min_prio) { mall_entry->priority >= flower_min_prio) {
NL_SET_ERR_MSG(f->common.extack, "Failed to add behind existing flower rules"); NL_SET_ERR_MSG(f->common.extack, "Failed to add behind existing flower rules");
...@@ -262,8 +267,7 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp, ...@@ -262,8 +267,7 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp,
} }
mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_MIRROR; mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_MIRROR;
mall_entry->mirror.to_dev = act->dev; mall_entry->mirror.to_dev = act->dev;
} else if (act->id == FLOW_ACTION_SAMPLE && } else if (act->id == FLOW_ACTION_SAMPLE) {
protocol == htons(ETH_P_ALL)) {
if (flower_prio_valid && if (flower_prio_valid &&
mall_entry->priority >= flower_min_prio) { mall_entry->priority >= flower_min_prio) {
NL_SET_ERR_MSG(f->common.extack, "Failed to add behind existing flower rules"); NL_SET_ERR_MSG(f->common.extack, "Failed to add behind existing flower rules");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment