Skip to content

Commit 501f14e

Browse files
mark-blochjgunthorpe
authored andcommitted
RDMA/mlx5: Don't overwrite action if already set
We support only a single action type per flow rule, in case the user passes the same type of flow actions fail the flow creation. Signed-off-by: Mark Bloch <markb@mellanox.com> Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 2ea2620 commit 501f14e

File tree

1 file changed

+10
-0
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+10
-0
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,6 +2467,9 @@ int parse_flow_flow_action(struct mlx5_ib_flow_action *maction,
24672467

24682468
switch (maction->ib_action.type) {
24692469
case IB_FLOW_ACTION_ESP:
2470+
if (action->action & (MLX5_FLOW_CONTEXT_ACTION_ENCRYPT |
2471+
MLX5_FLOW_CONTEXT_ACTION_DECRYPT))
2472+
return -EINVAL;
24702473
/* Currently only AES_GCM keymat is supported by the driver */
24712474
action->esp_id = (uintptr_t)maction->esp_aes_gcm.ctx;
24722475
action->action |= is_egress ?
@@ -2476,17 +2479,24 @@ int parse_flow_flow_action(struct mlx5_ib_flow_action *maction,
24762479
case IB_FLOW_ACTION_UNSPECIFIED:
24772480
if (maction->flow_action_raw.sub_type ==
24782481
MLX5_IB_FLOW_ACTION_MODIFY_HEADER) {
2482+
if (action->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
2483+
return -EINVAL;
24792484
action->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
24802485
action->modify_id = maction->flow_action_raw.action_id;
24812486
return 0;
24822487
}
24832488
if (maction->flow_action_raw.sub_type ==
24842489
MLX5_IB_FLOW_ACTION_DECAP) {
2490+
if (action->action & MLX5_FLOW_CONTEXT_ACTION_DECAP)
2491+
return -EINVAL;
24852492
action->action |= MLX5_FLOW_CONTEXT_ACTION_DECAP;
24862493
return 0;
24872494
}
24882495
if (maction->flow_action_raw.sub_type ==
24892496
MLX5_IB_FLOW_ACTION_PACKET_REFORMAT) {
2497+
if (action->action &
2498+
MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT)
2499+
return -EINVAL;
24902500
action->action |=
24912501
MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
24922502
action->reformat_id =

0 commit comments

Comments
 (0)