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.
Unified · Split
| @@ -626,8 +626,8 @@ static char *mlxsw_afa_block_append_action(struct mlxsw_afa_block *block, · 625 unmodified lines | ||
| 626 | 626 | char *oneact; |
| 627 | 627 | char *actions; |
| 628 | 628 | |
| 629 | − if (WARN_ON(block->finished)) | |
| 630 | − return NULL; | |
| 629 | + if (block->finished) | |
| 630 | + return ERR_PTR(-EINVAL); | |
| 631 | 631 | if (block->cur_act_index + action_size > |
| 632 | 632 | block->afa->max_acts_per_set) { |
| 633 | 633 | struct mlxsw_afa_set *set; |
| @@ -637,7 +637,7 @@ static char *mlxsw_afa_block_append_action(struct mlxsw_afa_block *block, · 3 unmodified lines | ||
| 637 | 637 | */ |
| 638 | 638 | set = mlxsw_afa_set_create(false); |
| 639 | 639 | if (!set) |
| 640 | − return NULL; | |
| 640 | + return ERR_PTR(-ENOBUFS); | |
| 641 | 641 | set->prev = block->cur_set; |
| 642 | 642 | block->cur_act_index = 0; |
| 643 | 643 | block->cur_set->next = set; |
| @@ -724,8 +724,8 @@ int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block, · 80 unmodified lines | ||
| 724 | 724 | MLXSW_AFA_VLAN_CODE, |
| 725 | 725 | MLXSW_AFA_VLAN_SIZE); |
| 726 | 726 | |
| 727 | − if (!act) | |
| 728 | − return -ENOBUFS; | |
| 727 | + if (IS_ERR(act)) | |
| 728 | + return PTR_ERR(act); | |
| 729 | 729 | mlxsw_afa_vlan_pack(act, MLXSW_AFA_VLAN_VLAN_TAG_CMD_NOP, |
| 730 | 730 | MLXSW_AFA_VLAN_CMD_SET_OUTER, vid, |
| 731 | 731 | 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 | ||
| 806 | 806 | MLXSW_AFA_TRAPDISC_CODE, |
| 807 | 807 | MLXSW_AFA_TRAPDISC_SIZE); |
| 808 | 808 | |
| 809 | − if (!act) | |
| 810 | − return -ENOBUFS; | |
| 809 | + if (IS_ERR(act)) | |
| 810 | + return PTR_ERR(act); | |
| 811 | 811 | mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP, |
| 812 | 812 | MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD, 0); |
| 813 | 813 | return 0; |
| @@ -820,8 +820,8 @@ int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id) · 6 unmodified lines | ||
| 820 | 820 | MLXSW_AFA_TRAPDISC_CODE, |
| 821 | 821 | MLXSW_AFA_TRAPDISC_SIZE); |
| 822 | 822 | |
| 823 | − if (!act) | |
| 824 | − return -ENOBUFS; | |
| 823 | + if (IS_ERR(act)) | |
| 824 | + return PTR_ERR(act); | |
| 825 | 825 | mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP, |
| 826 | 826 | MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD, |
| 827 | 827 | trap_id); |
| @@ -836,8 +836,8 @@ int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block, · 8 unmodified lines | ||
| 836 | 836 | MLXSW_AFA_TRAPDISC_CODE, |
| 837 | 837 | MLXSW_AFA_TRAPDISC_SIZE); |
| 838 | 838 | |
| 839 | − if (!act) | |
| 840 | − return -ENOBUFS; | |
| 839 | + if (IS_ERR(act)) | |
| 840 | + return PTR_ERR(act); | |
| 841 | 841 | mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP, |
| 842 | 842 | MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD, |
| 843 | 843 | trap_id); |
| @@ -908,8 +908,8 @@ mlxsw_afa_block_append_allocated_mirror(struct mlxsw_afa_block *block, · 64 unmodified lines | ||
| 908 | 908 | char *act = mlxsw_afa_block_append_action(block, |
| 909 | 909 | MLXSW_AFA_TRAPDISC_CODE, |
| 910 | 910 | MLXSW_AFA_TRAPDISC_SIZE); |
| 911 | − if (!act) | |
| 912 | − return -ENOBUFS; | |
| 911 | + if (IS_ERR(act)) | |
| 912 | + return PTR_ERR(act); | |
| 913 | 913 | mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP, |
| 914 | 914 | MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD, 0); |
| 915 | 915 | 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 | ||
| 996 | 996 | |
| 997 | 997 | act = mlxsw_afa_block_append_action(block, MLXSW_AFA_FORWARD_CODE, |
| 998 | 998 | MLXSW_AFA_FORWARD_SIZE); |
| 999 | − if (!act) { | |
| 1000 | − err = -ENOBUFS; | |
| 999 | + if (IS_ERR(act)) { | |
| 1000 | + err = PTR_ERR(act); | |
| 1001 | 1001 | goto err_append_action; |
| 1002 | 1002 | } |
| 1003 | 1003 | 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 | ||
| 1052 | 1052 | { |
| 1053 | 1053 | char *act = mlxsw_afa_block_append_action(block, MLXSW_AFA_POLCNT_CODE, |
| 1054 | 1054 | MLXSW_AFA_POLCNT_SIZE); |
| 1055 | − if (!act) | |
| 1056 | − return -ENOBUFS; | |
| 1055 | + if (IS_ERR(act)) | |
| 1056 | + return PTR_ERR(act); | |
| 1057 | 1057 | mlxsw_afa_polcnt_pack(act, MLXSW_AFA_POLCNT_COUNTER_SET_TYPE_PACKETS_BYTES, |
| 1058 | 1058 | counter_index); |
| 1059 | 1059 | return 0; |
| @@ -1123,8 +1123,8 @@ int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid) · 63 unmodified lines | ||
| 1123 | 1123 | char *act = mlxsw_afa_block_append_action(block, |
| 1124 | 1124 | MLXSW_AFA_VIRFWD_CODE, |
| 1125 | 1125 | MLXSW_AFA_VIRFWD_SIZE); |
| 1126 | − if (!act) | |
| 1127 | − return -ENOBUFS; | |
| 1126 | + if (IS_ERR(act)) | |
| 1127 | + return PTR_ERR(act); | |
| 1128 | 1128 | mlxsw_afa_virfwd_pack(act, MLXSW_AFA_VIRFWD_FID_CMD_SET, fid); |
| 1129 | 1129 | return 0; |
| 1130 | 1130 | } |
| @@ -1193,8 +1193,8 @@ int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block, · 62 unmodified lines | ||
| 1193 | 1193 | char *act = mlxsw_afa_block_append_action(block, |
| 1194 | 1194 | MLXSW_AFA_MCROUTER_CODE, |
| 1195 | 1195 | MLXSW_AFA_MCROUTER_SIZE); |
| 1196 | − if (!act) | |
| 1197 | − return -ENOBUFS; | |
| 1196 | + if (IS_ERR(act)) | |
| 1197 | + return PTR_ERR(act); | |
| 1198 | 1198 | mlxsw_afa_mcrouter_pack(act, MLXSW_AFA_MCROUTER_RPF_ACTION_TRAP, |
| 1199 | 1199 | expected_irif, min_mtu, rmid_valid, kvdl_index); |
| 1200 | 1200 | return 0; |