X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fclassify%2Fclassify_api.c;h=08defd4ecdd3a1b8f7f16d4ce264d44effa92b12;hb=b7b929931a07fbb27b43d5cd105f366c3e29807e;hp=2cf79f3875d09f72796437a50b9e42900aee22c0;hpb=815d7d5637fbffd20bf81c74fd59dac8e4fe4d94;p=vpp.git diff --git a/src/vnet/classify/classify_api.c b/src/vnet/classify/classify_api.c index 2cf79f3875d..08defd4ecdd 100644 --- a/src/vnet/classify/classify_api.c +++ b/src/vnet/classify/classify_api.c @@ -72,7 +72,8 @@ _(match_n_vectors) \ _(next_table_index) \ _(miss_next_index) \ _(current_data_flag) \ -_(current_data_offset) +_(current_data_offset) \ +_(mask_len) static void vl_api_classify_add_del_table_t_handler (vl_api_classify_add_del_table_t * mp) @@ -90,6 +91,12 @@ static void vl_api_classify_add_del_table_t_handler foreach_classify_add_del_table_field; #undef _ + if (mask_len != match_n_vectors * sizeof (u32x4)) + { + rv = VNET_API_ERROR_INVALID_VALUE; + goto out; + } + /* The underlying API fails silently, on purpose, so check here */ if (mp->is_add == 0) /* delete */ { @@ -138,9 +145,10 @@ static void vl_api_classify_add_del_session_t_handler vnet_classify_main_t *cm = &vnet_classify_main; vl_api_classify_add_del_session_reply_t *rmp; int rv; - u32 table_index, hit_next_index, opaque_index, metadata; + u32 table_index, hit_next_index, opaque_index, metadata, match_len; i32 advance; u8 action; + vnet_classify_table_t *t; table_index = ntohl (mp->table_index); hit_next_index = ntohl (mp->hit_next_index); @@ -148,11 +156,27 @@ static void vl_api_classify_add_del_session_t_handler advance = ntohl (mp->advance); action = mp->action; metadata = ntohl (mp->metadata); + match_len = ntohl (mp->match_len); + + if (pool_is_free_index (cm->tables, table_index)) + { + rv = VNET_API_ERROR_NO_SUCH_TABLE; + goto out; + } + + t = pool_elt_at_index (cm->tables, table_index); + + if (match_len != (t->skip_n_vectors + t->match_n_vectors) * sizeof (u32x4)) + { + rv = VNET_API_ERROR_INVALID_VALUE; + goto out; + } rv = vnet_classify_add_del_session (cm, table_index, mp->match, hit_next_index, opaque_index, advance, action, metadata, mp->is_add); +out: REPLY_MACRO (VL_API_CLASSIFY_ADD_DEL_SESSION_REPLY); } @@ -189,7 +213,7 @@ send_policer_classify_details (u32 sw_if_index, vl_api_policer_classify_details_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_POLICER_CLASSIFY_DETAILS); mp->context = context; mp->sw_if_index = htonl (sw_if_index); @@ -371,7 +395,7 @@ send_classify_session_details (vl_api_registration_t * reg, vl_api_classify_session_details_t *rmp; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_SESSION_DETAILS); rmp->context = context; rmp->table_id = ntohl (table_id); @@ -465,7 +489,7 @@ send_flow_classify_details (u32 sw_if_index, vl_api_flow_classify_details_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_FLOW_CLASSIFY_DETAILS); mp->context = context; mp->sw_if_index = htonl (sw_if_index);