gbp: Fix coverity warnings

Change-Id: Iea64d246008b298edeeae338d781b79362f42046
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
This commit is contained in:
Mohsin Kazmi
2019-01-07 19:54:20 +01:00
committed by Neale Ranns
parent e3034cdc74
commit 5f4eb24287
4 changed files with 19 additions and 9 deletions

View File

@ -645,10 +645,10 @@ vl_api_gbp_recirc_add_del_t_handler (vl_api_gbp_recirc_add_del_t * mp)
goto bad_sw_if_index; goto bad_sw_if_index;
if (mp->is_add) if (mp->is_add)
gbp_recirc_add (sw_if_index, rv = gbp_recirc_add (sw_if_index,
ntohs (mp->recirc.epg_id), mp->recirc.is_ext); ntohs (mp->recirc.epg_id), mp->recirc.is_ext);
else else
gbp_recirc_delete (sw_if_index); rv = gbp_recirc_delete (sw_if_index);
BAD_SW_IF_INDEX_LABEL; BAD_SW_IF_INDEX_LABEL;
@ -700,17 +700,20 @@ static void
vl_api_gbp_ext_itf_add_del_t_handler (vl_api_gbp_ext_itf_add_del_t * mp) vl_api_gbp_ext_itf_add_del_t_handler (vl_api_gbp_ext_itf_add_del_t * mp)
{ {
vl_api_gbp_ext_itf_add_del_reply_t *rmp; vl_api_gbp_ext_itf_add_del_reply_t *rmp;
u32 sw_if_index; u32 sw_if_index = ~0;
vl_api_gbp_ext_itf_t *ext_itf;
int rv = 0; int rv = 0;
sw_if_index = ntohl (mp->ext_itf.sw_if_index); ext_itf = &mp->ext_itf;
if (ext_itf)
sw_if_index = ntohl (ext_itf->sw_if_index);
if (!vnet_sw_if_index_is_api_valid (sw_if_index)) if (!vnet_sw_if_index_is_api_valid (sw_if_index))
goto bad_sw_if_index; goto bad_sw_if_index;
if (mp->is_add) if (mp->is_add)
rv = gbp_ext_itf_add (sw_if_index, rv = gbp_ext_itf_add (sw_if_index,
ntohl (mp->ext_itf.bd_id), ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id));
ntohl (mp->ext_itf.rd_id));
else else
rv = gbp_ext_itf_delete (sw_if_index); rv = gbp_ext_itf_delete (sw_if_index);

View File

@ -113,6 +113,9 @@ gbp_ext_itf_delete (u32 sw_if_index)
gbp_ext_itf_t *gx; gbp_ext_itf_t *gx;
index_t gxi; index_t gxi;
if (vec_len (gbp_ext_itf_db) <= sw_if_index)
return (VNET_API_ERROR_INVALID_SW_IF_INDEX);
gxi = gbp_ext_itf_db[sw_if_index]; gxi = gbp_ext_itf_db[sw_if_index];
if (INDEX_INVALID != gxi) if (INDEX_INVALID != gxi)

View File

@ -171,12 +171,14 @@ gbp_recirc_add (u32 sw_if_index, epg_id_t epg_id, u8 is_ext)
return (0); return (0);
} }
void int
gbp_recirc_delete (u32 sw_if_index) gbp_recirc_delete (u32 sw_if_index)
{ {
gbp_recirc_t *gr; gbp_recirc_t *gr;
index_t gri; index_t gri;
if (vec_len (gbp_recirc_db) <= sw_if_index)
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
gri = gbp_recirc_db[sw_if_index]; gri = gbp_recirc_db[sw_if_index];
if (INDEX_INVALID != gri) if (INDEX_INVALID != gri)
@ -214,7 +216,9 @@ gbp_recirc_delete (u32 sw_if_index)
gbp_endpoint_group_unlock (gr->gr_epgi); gbp_endpoint_group_unlock (gr->gr_epgi);
gbp_recirc_db[sw_if_index] = INDEX_INVALID; gbp_recirc_db[sw_if_index] = INDEX_INVALID;
pool_put (gbp_recirc_pool, gr); pool_put (gbp_recirc_pool, gr);
return (0);
} }
return VNET_API_ERROR_NO_SUCH_ENTRY;
} }
void void

View File

@ -60,7 +60,7 @@ typedef struct gpb_recirc_t_
} gbp_recirc_t; } gbp_recirc_t;
extern int gbp_recirc_add (u32 sw_if_index, epg_id_t epg_id, u8 is_ext); extern int gbp_recirc_add (u32 sw_if_index, epg_id_t epg_id, u8 is_ext);
extern void gbp_recirc_delete (u32 sw_if_index); extern int gbp_recirc_delete (u32 sw_if_index);
typedef walk_rc_t (*gbp_recirc_cb_t) (gbp_recirc_t * gbpe, void *ctx); typedef walk_rc_t (*gbp_recirc_cb_t) (gbp_recirc_t * gbpe, void *ctx);
extern void gbp_recirc_walk (gbp_recirc_cb_t bgpe, void *ctx); extern void gbp_recirc_walk (gbp_recirc_cb_t bgpe, void *ctx);