History

mlxsw: core_acl_flex_actions: Return error for conflicting actions

Spectrum switch ACL action set is built in groups of three actions which may point to additional actions. A group holds a single record which can be set as goto record for pointing at a following group or can be set to mark the termination of the lookup. This is perfectly adequate for handling a series of actions to be executed on a packet. While the SW model allows configuration of conflicting actions where it is clear that some actions will never execute, the mlxsw driver must block such configurations as it creates a conflict over the single terminate/goto record value. For a conflicting actions configuration such as: # tc filter add dev swp49 parent ffff: \ protocol ip pref 10 \ flower skip_sw dst_ip 192.168.101.1 \ action goto chain 100 \ action mirred egress mirror dev swp4 Where it is clear that the last action will never execute, the mlxsw driver was issuing a warning instead of returning an error. Therefore replace that warning with an error for this specific case.

Nir Dotan committed 8 years ago

Commit 3757b251 parent afb41bb1 file · +21 −21Browse files

Unified · Split

drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c+21−21
@@ -626,8 +626,8 @@ static char *mlxsw_afa_block_append_action(struct mlxsw_afa_block *block, · 625 unmodified lines
626626 char *oneact;
627627 char *actions;
628628
629− if (WARN_ON(block->finished))
630− return NULL;
629+ if (block->finished)
630+ return ERR_PTR(-EINVAL);
631631 if (block->cur_act_index + action_size >
632632 block->afa->max_acts_per_set) {
633633 struct mlxsw_afa_set *set;
@@ -637,7 +637,7 @@ static char *mlxsw_afa_block_append_action(struct mlxsw_afa_block *block, · 3 unmodified lines
637637 */
638638 set = mlxsw_afa_set_create(false);
639639 if (!set)
640− return NULL;
640+ return ERR_PTR(-ENOBUFS);
641641 set->prev = block->cur_set;
642642 block->cur_act_index = 0;
643643 block->cur_set->next = set;
@@ -724,8 +724,8 @@ int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block, · 80 unmodified lines
724724 MLXSW_AFA_VLAN_CODE,
725725 MLXSW_AFA_VLAN_SIZE);
726726
727− if (!act)
728− return -ENOBUFS;
727+ if (IS_ERR(act))
728+ return PTR_ERR(act);
729729 mlxsw_afa_vlan_pack(act, MLXSW_AFA_VLAN_VLAN_TAG_CMD_NOP,
730730 MLXSW_AFA_VLAN_CMD_SET_OUTER, vid,
731731 MLXSW_AFA_VLAN_CMD_SET_OUTER, pcp,
@@ -806,8 +806,8 @@ int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block) · 74 unmodified lines
806806 MLXSW_AFA_TRAPDISC_CODE,
807807 MLXSW_AFA_TRAPDISC_SIZE);
808808
809− if (!act)
810− return -ENOBUFS;
809+ if (IS_ERR(act))
810+ return PTR_ERR(act);
811811 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP,
812812 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD, 0);
813813 return 0;
@@ -820,8 +820,8 @@ int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id) · 6 unmodified lines
820820 MLXSW_AFA_TRAPDISC_CODE,
821821 MLXSW_AFA_TRAPDISC_SIZE);
822822
823− if (!act)
824− return -ENOBUFS;
823+ if (IS_ERR(act))
824+ return PTR_ERR(act);
825825 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP,
826826 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD,
827827 trap_id);
@@ -836,8 +836,8 @@ int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block, · 8 unmodified lines
836836 MLXSW_AFA_TRAPDISC_CODE,
837837 MLXSW_AFA_TRAPDISC_SIZE);
838838
839− if (!act)
840− return -ENOBUFS;
839+ if (IS_ERR(act))
840+ return PTR_ERR(act);
841841 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP,
842842 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD,
843843 trap_id);
@@ -908,8 +908,8 @@ mlxsw_afa_block_append_allocated_mirror(struct mlxsw_afa_block *block, · 64 unmodified lines
908908 char *act = mlxsw_afa_block_append_action(block,
909909 MLXSW_AFA_TRAPDISC_CODE,
910910 MLXSW_AFA_TRAPDISC_SIZE);
911− if (!act)
912− return -ENOBUFS;
911+ if (IS_ERR(act))
912+ return PTR_ERR(act);
913913 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP,
914914 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD, 0);
915915 mlxsw_afa_trapdisc_mirror_pack(act, true, mirror_agent);
@@ -996,8 +996,8 @@ int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block, · 80 unmodified lines
996996
997997 act = mlxsw_afa_block_append_action(block, MLXSW_AFA_FORWARD_CODE,
998998 MLXSW_AFA_FORWARD_SIZE);
999− if (!act) {
1000− err = -ENOBUFS;
999+ if (IS_ERR(act)) {
1000+ err = PTR_ERR(act);
10011001 goto err_append_action;
10021002 }
10031003 mlxsw_afa_forward_pack(act, MLXSW_AFA_FORWARD_TYPE_PBS,
@@ -1052,8 +1052,8 @@ int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block, · 48 unmodified lines
10521052 {
10531053 char *act = mlxsw_afa_block_append_action(block, MLXSW_AFA_POLCNT_CODE,
10541054 MLXSW_AFA_POLCNT_SIZE);
1055− if (!act)
1056− return -ENOBUFS;
1055+ if (IS_ERR(act))
1056+ return PTR_ERR(act);
10571057 mlxsw_afa_polcnt_pack(act, MLXSW_AFA_POLCNT_COUNTER_SET_TYPE_PACKETS_BYTES,
10581058 counter_index);
10591059 return 0;
@@ -1123,8 +1123,8 @@ int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid) · 63 unmodified lines
11231123 char *act = mlxsw_afa_block_append_action(block,
11241124 MLXSW_AFA_VIRFWD_CODE,
11251125 MLXSW_AFA_VIRFWD_SIZE);
1126− if (!act)
1127− return -ENOBUFS;
1126+ if (IS_ERR(act))
1127+ return PTR_ERR(act);
11281128 mlxsw_afa_virfwd_pack(act, MLXSW_AFA_VIRFWD_FID_CMD_SET, fid);
11291129 return 0;
11301130 }
@@ -1193,8 +1193,8 @@ int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block, · 62 unmodified lines
11931193 char *act = mlxsw_afa_block_append_action(block,
11941194 MLXSW_AFA_MCROUTER_CODE,
11951195 MLXSW_AFA_MCROUTER_SIZE);
1196− if (!act)
1197− return -ENOBUFS;
1196+ if (IS_ERR(act))
1197+ return PTR_ERR(act);
11981198 mlxsw_afa_mcrouter_pack(act, MLXSW_AFA_MCROUTER_RPF_ACTION_TRAP,
11991199 expected_irif, min_mtu, rmid_valid, kvdl_index);
12001200 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t