mlxsw: spectrum_flower: Disallow usage of vlan_id key on egress
authorNir Dotan <nird@mellanox.com>
Thu, 9 Aug 2018 08:59:07 +0000 (11:59 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Aug 2018 17:36:10 +0000 (10:36 -0700)
As recent spectrum FW imposes a limitation on using vlan_id key for
egress ACL, disallow the usage of that key accordingly and return a
proper extack message.

Signed-off-by: Nir Dotan <nird@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c

index 13eca1a..0e02cfe 100644 (file)
@@ -538,6 +538,7 @@ int mlxsw_sp_acl_block_unbind(struct mlxsw_sp *mlxsw_sp,
                              struct mlxsw_sp_acl_block *block,
                              struct mlxsw_sp_port *mlxsw_sp_port,
                              bool ingress);
+bool mlxsw_sp_acl_block_is_egress_bound(struct mlxsw_sp_acl_block *block);
 struct mlxsw_sp_acl_ruleset *
 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp,
                            struct mlxsw_sp_acl_block *block, u32 chain_index,
index 6a38763..87f7433 100644 (file)
@@ -158,6 +158,17 @@ bool mlxsw_sp_acl_block_disabled(struct mlxsw_sp_acl_block *block)
        return block->disable_count;
 }
 
+bool mlxsw_sp_acl_block_is_egress_bound(struct mlxsw_sp_acl_block *block)
+{
+       struct mlxsw_sp_acl_block_binding *binding;
+
+       list_for_each_entry(binding, &block->binding_list, list) {
+               if (!binding->ingress)
+                       return true;
+       }
+       return false;
+}
+
 static bool
 mlxsw_sp_acl_ruleset_is_singular(const struct mlxsw_sp_acl_ruleset *ruleset)
 {
index 8213cb7..8f3e006 100644 (file)
@@ -386,6 +386,11 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,
                        skb_flow_dissector_target(f->dissector,
                                                  FLOW_DISSECTOR_KEY_VLAN,
                                                  f->mask);
+
+               if (mlxsw_sp_acl_block_is_egress_bound(block)) {
+                       NL_SET_ERR_MSG_MOD(f->common.extack, "vlan_id key is not supported on egress");
+                       return -EOPNOTSUPP;
+               }
                if (mask->vlan_id != 0)
                        mlxsw_sp_acl_rulei_keymask_u32(rulei,
                                                       MLXSW_AFK_ELEMENT_VID,