Skip to content

Commit

Permalink
net/ice/base: add profile validation on switch filter
Browse files Browse the repository at this point in the history
[ upstream commit a62f095 ]

Profile type was determined without validation when getting
switch field vector bitmap. It caused error when associating
profile id with given recipe if no lookup elements were given.
Add profile validation to check if the profile is existing
before getting bitmap.

Fixes: 5574422 ("net/ice/base: associate recipes by profile type")

Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
  • Loading branch information
Yuying2intel authored and bluca committed Feb 17, 2022
1 parent da0833e commit dc92390
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/net/ice/base/ice_flex_pipe.c
Expand Up @@ -1597,8 +1597,12 @@ static enum ice_prof_type
ice_get_sw_prof_type(struct ice_hw *hw, struct ice_fv *fv)
{
u16 i;
bool valid_prof = false;

for (i = 0; i < hw->blk[ICE_BLK_SW].es.fvw; i++) {
if (fv->ew[i].off != ICE_NAN_OFFSET)
valid_prof = true;

/* UDP tunnel will have UDP_OF protocol ID and VNI offset */
if (fv->ew[i].prot_id == (u8)ICE_PROT_UDP_OF &&
fv->ew[i].off == ICE_VNI_OFFSET)
Expand All @@ -1613,7 +1617,7 @@ ice_get_sw_prof_type(struct ice_hw *hw, struct ice_fv *fv)
return ICE_PROF_TUN_PPPOE;
}

return ICE_PROF_NON_TUN;
return valid_prof ? ICE_PROF_NON_TUN : ICE_PROF_INVALID;
}

/**
Expand All @@ -1630,11 +1634,6 @@ ice_get_sw_fv_bitmap(struct ice_hw *hw, enum ice_prof_type req_profs,
struct ice_seg *ice_seg;
struct ice_fv *fv;

if (req_profs == ICE_PROF_ALL) {
ice_bitmap_set(bm, 0, ICE_MAX_NUM_PROFILES);
return;
}

ice_memset(&state, 0, sizeof(state), ICE_NONDMA_MEM);
ice_zero_bitmap(bm, ICE_MAX_NUM_PROFILES);
ice_seg = hw->seg;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ice/base/ice_flex_type.h
Expand Up @@ -779,6 +779,7 @@ struct ice_chs_chg {
#define ICE_FLOW_PTYPE_MAX ICE_XLT1_CNT

enum ice_prof_type {
ICE_PROF_INVALID = 0x0,
ICE_PROF_NON_TUN = 0x1,
ICE_PROF_TUN_UDP = 0x2,
ICE_PROF_TUN_GRE = 0x4,
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ice/base/ice_protocol_type.h
Expand Up @@ -164,6 +164,7 @@ enum ice_prot_id {

#define ICE_VNI_OFFSET 12 /* offset of VNI from ICE_PROT_UDP_OF */

#define ICE_NAN_OFFSET 511
#define ICE_MAC_OFOS_HW 1
#define ICE_MAC_IL_HW 4
#define ICE_ETYPE_OL_HW 9
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ice/base/ice_switch.c
Expand Up @@ -7022,6 +7022,7 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo,
bool ice_is_prof_rule(enum ice_sw_tunnel_type type)
{
switch (type) {
case ICE_SW_TUN_AND_NON_TUN:
case ICE_SW_TUN_PROFID_IPV6_ESP:
case ICE_SW_TUN_PROFID_IPV6_AH:
case ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3:
Expand Down

0 comments on commit dc92390

Please sign in to comment.