mlxsw: spectrum_flower: Disable mixed bound blocks to contain action drop
Action drop is going to be tracked by two separate traps, one for ingress and one for egress. Prepare for it and disallow the possibility to have drop action in blocks which are bound to both ingress and egress. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
68cc7ecc1b
commit
86272d3397
|
@ -645,6 +645,7 @@ struct mlxsw_sp_acl_rule_info {
|
|||
struct mlxsw_afk_element_values values;
|
||||
struct mlxsw_afa_block *act_block;
|
||||
u8 action_created:1,
|
||||
ingress_bind_blocker:1,
|
||||
egress_bind_blocker:1;
|
||||
unsigned int counter_index;
|
||||
};
|
||||
|
@ -664,6 +665,7 @@ struct mlxsw_sp_acl_block {
|
|||
struct mlxsw_sp *mlxsw_sp;
|
||||
unsigned int rule_count;
|
||||
unsigned int disable_count;
|
||||
unsigned int ingress_blocker_rule_count;
|
||||
unsigned int egress_blocker_rule_count;
|
||||
unsigned int ingress_binding_count;
|
||||
unsigned int egress_binding_count;
|
||||
|
|
|
@ -256,6 +256,11 @@ int mlxsw_sp_acl_block_bind(struct mlxsw_sp *mlxsw_sp,
|
|||
if (WARN_ON(mlxsw_sp_acl_block_lookup(block, mlxsw_sp_port, ingress)))
|
||||
return -EEXIST;
|
||||
|
||||
if (ingress && block->ingress_blocker_rule_count) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Block cannot be bound to ingress because it contains unsupported rules");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (!ingress && block->egress_blocker_rule_count) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Block cannot be bound to egress because it contains unsupported rules");
|
||||
return -EOPNOTSUPP;
|
||||
|
@ -722,6 +727,7 @@ int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
|
|||
list_add_tail(&rule->list, &mlxsw_sp->acl->rules);
|
||||
mutex_unlock(&mlxsw_sp->acl->rules_lock);
|
||||
block->rule_count++;
|
||||
block->ingress_blocker_rule_count += rule->rulei->ingress_bind_blocker;
|
||||
block->egress_blocker_rule_count += rule->rulei->egress_bind_blocker;
|
||||
return 0;
|
||||
|
||||
|
@ -741,6 +747,7 @@ void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
|
|||
struct mlxsw_sp_acl_block *block = ruleset->ht_key.block;
|
||||
|
||||
block->egress_blocker_rule_count -= rule->rulei->egress_bind_blocker;
|
||||
block->ingress_blocker_rule_count -= rule->rulei->ingress_bind_blocker;
|
||||
ruleset->ht_key.block->rule_count--;
|
||||
mutex_lock(&mlxsw_sp->acl->rules_lock);
|
||||
list_del(&rule->list);
|
||||
|
|
|
@ -41,12 +41,29 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
|
|||
return err;
|
||||
}
|
||||
break;
|
||||
case FLOW_ACTION_DROP:
|
||||
case FLOW_ACTION_DROP: {
|
||||
bool ingress;
|
||||
|
||||
if (mlxsw_sp_acl_block_is_mixed_bound(block)) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Drop action is not supported when block is bound to ingress and egress");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
ingress = mlxsw_sp_acl_block_is_ingress_bound(block);
|
||||
err = mlxsw_sp_acl_rulei_act_drop(rulei);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Cannot append drop action");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Forbid block with this rulei to be bound
|
||||
* to ingress/egress in future. Ingress rule is
|
||||
* a blocker for egress and vice versa.
|
||||
*/
|
||||
if (ingress)
|
||||
rulei->egress_bind_blocker = 1;
|
||||
else
|
||||
rulei->ingress_bind_blocker = 1;
|
||||
}
|
||||
break;
|
||||
case FLOW_ACTION_TRAP:
|
||||
err = mlxsw_sp_acl_rulei_act_trap(rulei);
|
||||
|
|
Loading…
Reference in New Issue