[bug report] RDMA/mlx5: Drop crypto flow steering API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Leon Romanovsky,

The patch de8bdb476908: "RDMA/mlx5: Drop crypto flow steering API"
from Apr 6, 2022, leads to the following Smatch static checker
warning:

	drivers/infiniband/hw/mlx5/fs.c:1126 _create_flow_rule()
	warn: duplicate check 'is_egress' (previous on line 1098)

drivers/infiniband/hw/mlx5/fs.c
    1030 static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
    1031                                                       struct mlx5_ib_flow_prio *ft_prio,
    1032                                                       const struct ib_flow_attr *flow_attr,
    1033                                                       struct mlx5_flow_destination *dst,
    1034                                                       u32 underlay_qpn,
    1035                                                       struct mlx5_ib_create_flow *ucmd)
    1036 {
    1037         struct mlx5_flow_table        *ft = ft_prio->flow_table;
    1038         struct mlx5_ib_flow_handler *handler;
    1039         struct mlx5_flow_act flow_act = {};
    1040         struct mlx5_flow_spec *spec;
    1041         struct mlx5_flow_destination dest_arr[2] = {};
    1042         struct mlx5_flow_destination *rule_dst = dest_arr;
    1043         const void *ib_flow = (const void *)flow_attr + sizeof(*flow_attr);
    1044         unsigned int spec_index;
    1045         u32 prev_type = 0;
    1046         int err = 0;
    1047         int dest_num = 0;
    1048         bool is_egress = flow_attr->flags & IB_FLOW_ATTR_FLAGS_EGRESS;
    1049 
    1050         if (!is_valid_attr(dev->mdev, flow_attr))
    1051                 return ERR_PTR(-EINVAL);
    1052 
    1053         if (dev->is_rep && is_egress)
    1054                 return ERR_PTR(-EINVAL);
    1055 
    1056         spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
    1057         handler = kzalloc(sizeof(*handler), GFP_KERNEL);
    1058         if (!handler || !spec) {
    1059                 err = -ENOMEM;
    1060                 goto free;
    1061         }
    1062 
    1063         INIT_LIST_HEAD(&handler->list);
    1064 
    1065         for (spec_index = 0; spec_index < flow_attr->num_of_specs; spec_index++) {
    1066                 err = parse_flow_attr(dev->mdev, spec,
    1067                                       ib_flow, flow_attr, &flow_act,
    1068                                       prev_type);
    1069                 if (err < 0)
    1070                         goto free;
    1071 
    1072                 prev_type = ((union ib_flow_spec *)ib_flow)->type;
    1073                 ib_flow += ((union ib_flow_spec *)ib_flow)->size;
    1074         }
    1075 
    1076         if (dst && !(flow_act.action & MLX5_FLOW_CONTEXT_ACTION_DROP)) {
    1077                 memcpy(&dest_arr[0], dst, sizeof(*dst));
    1078                 dest_num++;
    1079         }
    1080 
    1081         if (!flow_is_multicast_only(flow_attr))
    1082                 set_underlay_qp(dev, spec, underlay_qpn);
    1083 
    1084         if (dev->is_rep && flow_attr->type != IB_FLOW_ATTR_SNIFFER) {
    1085                 struct mlx5_eswitch_rep *rep;
    1086 
    1087                 rep = dev->port[flow_attr->port - 1].rep;
    1088                 if (!rep) {
    1089                         err = -EINVAL;
    1090                         goto free;
    1091                 }
    1092 
    1093                 mlx5_ib_set_rule_source_port(dev, spec, rep);
    1094         }
    1095 
    1096         spec->match_criteria_enable = get_match_criteria_enable(spec->match_criteria);
    1097 
    1098         if (is_egress) {
    1099                 err = -EINVAL;
    1100                 goto free;

The patch changed this check so we always return -EINVAL.


    1101         }
    1102 
    1103         if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
    1104                 struct mlx5_ib_mcounters *mcounters;
    1105 
    1106                 err = mlx5_ib_flow_counters_set_data(flow_act.counters, ucmd);
    1107                 if (err)
    1108                         goto free;
    1109 
    1110                 mcounters = to_mcounters(flow_act.counters);
    1111                 handler->ibcounters = flow_act.counters;
    1112                 dest_arr[dest_num].type =
    1113                         MLX5_FLOW_DESTINATION_TYPE_COUNTER;
    1114                 dest_arr[dest_num].counter_id =
    1115                         mlx5_fc_id(mcounters->hw_cntrs_hndl);
    1116                 dest_num++;
    1117         }
    1118 
    1119         if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_DROP) {
    1120                 if (!dest_num)
    1121                         rule_dst = NULL;
    1122         } else {
    1123                 if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP)
    1124                         flow_act.action |=
    1125                                 MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO;
--> 1126                 if (is_egress)
                             ^^^^^^^^^
No need to check

    1127                         flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_ALLOW;
    1128                 else if (dest_num)
    1129                         flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
    1130         }
    1131 
    1132         if ((spec->flow_context.flags & FLOW_CONTEXT_HAS_TAG)  &&
    1133             (flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT ||
    1134              flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT)) {
    1135                 mlx5_ib_warn(dev, "Flow tag %u and attribute type %x isn't allowed in leftovers\n",
    1136                              spec->flow_context.flow_tag, flow_attr->type);
    1137                 err = -EINVAL;
    1138                 goto free;
    1139         }
    1140         handler->rule = mlx5_add_flow_rules(ft, spec,
    1141                                             &flow_act,
    1142                                             rule_dst, dest_num);
    1143 
    1144         if (IS_ERR(handler->rule)) {
    1145                 err = PTR_ERR(handler->rule);
    1146                 goto free;
    1147         }
    1148 
    1149         ft_prio->refcount++;
    1150         handler->prio = ft_prio;
    1151         handler->dev = dev;
    1152 
    1153         ft_prio->flow_table = ft;
    1154 free:
    1155         if (err && handler) {
    1156                 mlx5_ib_counters_clear_description(handler->ibcounters);
    1157                 kfree(handler);
    1158         }
    1159         kvfree(spec);
    1160         return err ? ERR_PTR(err) : handler;
    1161 }

regards,
dan carpenter



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux