diff options
Diffstat (limited to 'src/vnet/classify/classify_api.c')
-rw-r--r-- | src/vnet/classify/classify_api.c | 137 |
1 files changed, 92 insertions, 45 deletions
diff --git a/src/vnet/classify/classify_api.c b/src/vnet/classify/classify_api.c index 39f7b98007d..fc57b006d37 100644 --- a/src/vnet/classify/classify_api.c +++ b/src/vnet/classify/classify_api.c @@ -91,7 +91,8 @@ static void vl_api_classify_pcap_lookup_table_t_handler out: rmp = vl_msg_api_alloc (sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_PCAP_LOOKUP_TABLE_REPLY); + rmp->_vl_msg_id = + ntohs (REPLY_MSG_ID_BASE + VL_API_CLASSIFY_PCAP_LOOKUP_TABLE_REPLY); rmp->context = mp->context; rmp->retval = ntohl (rv); rmp->table_index = htonl (table_index); @@ -114,9 +115,8 @@ static void vl_api_classify_pcap_set_table_t_handler u32 table_index = ntohl (mp->table_index); u32 sw_if_index = ntohl (mp->sw_if_index); - if (sw_if_index == ~0 - || sw_if_index >= vec_len (cm->classify_table_index_by_sw_if_index) - || (table_index != ~0 && pool_is_free_index (cm->tables, table_index))) + if (sw_if_index == ~0 || + (table_index != ~0 && pool_is_free_index (cm->tables, table_index))) { rv = VNET_API_ERROR_INVALID_VALUE; goto out; @@ -132,7 +132,8 @@ static void vl_api_classify_pcap_set_table_t_handler out: rmp = vl_msg_api_alloc (sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_PCAP_SET_TABLE_REPLY); + rmp->_vl_msg_id = + ntohs (REPLY_MSG_ID_BASE + VL_API_CLASSIFY_PCAP_SET_TABLE_REPLY); rmp->context = mp->context; rmp->retval = ntohl (rv); rmp->table_index = htonl (table_index); @@ -181,7 +182,8 @@ static void vl_api_classify_pcap_get_tables_t_handler out: count = vec_len (tables); rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp) + count * sizeof (u32)); - rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_PCAP_GET_TABLES_REPLY); + rmp->_vl_msg_id = + ntohs (REPLY_MSG_ID_BASE + VL_API_CLASSIFY_PCAP_GET_TABLES_REPLY); rmp->context = mp->context; rmp->retval = ntohl (rv); rmp->count = htonl (count); @@ -233,7 +235,8 @@ static void vl_api_classify_trace_lookup_table_t_handler out: rmp = vl_msg_api_alloc (sizeof (*rmp)); - rmp->_vl_msg_id = ntohs ((VL_API_CLASSIFY_TRACE_LOOKUP_TABLE_REPLY)); + rmp->_vl_msg_id = + ntohs ((REPLY_MSG_ID_BASE + VL_API_CLASSIFY_TRACE_LOOKUP_TABLE_REPLY)); rmp->context = mp->context; rmp->retval = ntohl (rv); rmp->table_index = htonl (table_index); @@ -270,7 +273,8 @@ static void vl_api_classify_trace_set_table_t_handler out: rmp = vl_msg_api_alloc (sizeof (*rmp)); - rmp->_vl_msg_id = ntohs ((VL_API_CLASSIFY_TRACE_SET_TABLE_REPLY)); + rmp->_vl_msg_id = + ntohs ((REPLY_MSG_ID_BASE + VL_API_CLASSIFY_TRACE_SET_TABLE_REPLY)); rmp->context = mp->context; rmp->retval = ntohl (rv); rmp->table_index = htonl (table_index); @@ -311,7 +315,8 @@ static void vl_api_classify_trace_get_tables_t_handler out: count = vec_len (tables); rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp) + count * sizeof (u32)); - rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TRACE_GET_TABLES_REPLY); + rmp->_vl_msg_id = + ntohs (REPLY_MSG_ID_BASE + VL_API_CLASSIFY_TRACE_GET_TABLES_REPLY); rmp->context = mp->context; rmp->retval = ntohl (rv); rmp->count = htonl (count); @@ -374,7 +379,6 @@ static void vl_api_classify_add_del_table_t_handler current_data_flag, current_data_offset, mp->is_add, mp->del_chain); out: - /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_CLASSIFY_ADD_DEL_TABLE_REPLY, ({ if (rv == 0 && mp->is_add) @@ -391,7 +395,6 @@ out: rmp->new_table_index = ~0; } })); - /* *INDENT-ON* */ } static void vl_api_classify_add_del_session_t_handler @@ -469,7 +472,7 @@ send_policer_classify_details (u32 sw_if_index, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_POLICER_CLASSIFY_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_POLICER_CLASSIFY_DETAILS); mp->context = context; mp->sw_if_index = htonl (sw_if_index); mp->table_index = htonl (table_index); @@ -528,17 +531,16 @@ vl_api_classify_table_ids_t_handler (vl_api_classify_table_ids_t * mp) u32 *table_ids = 0; u32 count; - /* *INDENT-OFF* */ pool_foreach (t, cm->tables) { vec_add1 (table_ids, ntohl(t - cm->tables)); } - /* *INDENT-ON* */ count = vec_len (table_ids); vl_api_classify_table_ids_reply_t *rmp; rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp) + count * sizeof (u32)); - rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_IDS_REPLY); + rmp->_vl_msg_id = + ntohs (REPLY_MSG_ID_BASE + VL_API_CLASSIFY_TABLE_IDS_REPLY); rmp->context = mp->context; rmp->count = ntohl (count); clib_memcpy (rmp->ids, table_ids, count * sizeof (u32)); @@ -589,7 +591,6 @@ static void BAD_SW_IF_INDEX_LABEL; - /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_CLASSIFY_TABLE_BY_INTERFACE_REPLY, ({ rmp->sw_if_index = ntohl(sw_if_index); @@ -597,7 +598,6 @@ static void rmp->ip4_table_id = ntohl(acl[IN_OUT_ACL_TABLE_IP4]); rmp->ip6_table_id = ntohl(acl[IN_OUT_ACL_TABLE_IP6]); })); - /* *INDENT-ON* */ vec_free (acl); } @@ -616,34 +616,35 @@ vl_api_classify_table_info_t_handler (vl_api_classify_table_info_t * mp) u32 table_id = ntohl (mp->table_id); vnet_classify_table_t *t; - /* *INDENT-OFF* */ - pool_foreach (t, cm->tables) + pool_foreach (t, cm->tables) { - if (table_id == t - cm->tables) - { - rmp = vl_msg_api_alloc_as_if_client - (sizeof (*rmp) + t->match_n_vectors * sizeof (u32x4)); - rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_INFO_REPLY); - rmp->context = mp->context; - rmp->table_id = ntohl(table_id); - rmp->nbuckets = ntohl(t->nbuckets); - rmp->match_n_vectors = ntohl(t->match_n_vectors); - rmp->skip_n_vectors = ntohl(t->skip_n_vectors); - rmp->active_sessions = ntohl(t->active_elements); - rmp->next_table_index = ntohl(t->next_table_index); - rmp->miss_next_index = ntohl(t->miss_next_index); - rmp->mask_length = ntohl(t->match_n_vectors * sizeof (u32x4)); - clib_memcpy(rmp->mask, t->mask, t->match_n_vectors * sizeof(u32x4)); - rmp->retval = 0; - break; - } - } - /* *INDENT-ON* */ + if (table_id == t - cm->tables) + { + rmp = vl_msg_api_alloc_as_if_client ( + sizeof (*rmp) + t->match_n_vectors * sizeof (u32x4)); + rmp->_vl_msg_id = + ntohs (REPLY_MSG_ID_BASE + VL_API_CLASSIFY_TABLE_INFO_REPLY); + rmp->context = mp->context; + rmp->table_id = ntohl (table_id); + rmp->nbuckets = ntohl (t->nbuckets); + rmp->match_n_vectors = ntohl (t->match_n_vectors); + rmp->skip_n_vectors = ntohl (t->skip_n_vectors); + rmp->active_sessions = ntohl (t->active_elements); + rmp->next_table_index = ntohl (t->next_table_index); + rmp->miss_next_index = ntohl (t->miss_next_index); + rmp->mask_length = ntohl (t->match_n_vectors * sizeof (u32x4)); + clib_memcpy (rmp->mask, t->mask, + t->match_n_vectors * sizeof (u32x4)); + rmp->retval = 0; + break; + } + } if (rmp == 0) { rmp = vl_msg_api_alloc (sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_INFO_REPLY); + rmp->_vl_msg_id = + ntohs (REPLY_MSG_ID_BASE + VL_API_CLASSIFY_TABLE_INFO_REPLY); rmp->context = mp->context; rmp->retval = ntohl (VNET_API_ERROR_CLASSIFY_TABLE_NOT_FOUND); } @@ -659,9 +660,10 @@ send_classify_session_details (vl_api_registration_t * reg, { vl_api_classify_session_details_t *rmp; - rmp = vl_msg_api_alloc (sizeof (*rmp)); + rmp = vl_msg_api_alloc (sizeof (*rmp) + match_length); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_SESSION_DETAILS); + rmp->_vl_msg_id = + ntohs (REPLY_MSG_ID_BASE + VL_API_CLASSIFY_SESSION_DETAILS); rmp->context = context; rmp->table_id = ntohl (table_id); rmp->hit_next_index = ntohl (e->next_index); @@ -686,7 +688,6 @@ vl_api_classify_session_dump_t_handler (vl_api_classify_session_dump_t * mp) if (!reg) return; - /* *INDENT-OFF* */ pool_foreach (t, cm->tables) { if (table_id == t - cm->tables) @@ -720,7 +721,6 @@ vl_api_classify_session_dump_t_handler (vl_api_classify_session_dump_t * mp) break; } } - /* *INDENT-ON* */ } static void @@ -755,7 +755,7 @@ send_flow_classify_details (u32 sw_if_index, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_FLOW_CLASSIFY_DETAILS); + mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_FLOW_CLASSIFY_DETAILS); mp->context = context; mp->sw_if_index = htonl (sw_if_index); mp->table_index = htonl (table_index); @@ -887,6 +887,43 @@ static void vl_api_input_acl_set_interface_t_handler REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY); } +static void +vl_api_punt_acl_add_del_t_handler (vl_api_punt_acl_add_del_t *mp) +{ + vlib_main_t *vm = vlib_get_main (); + vl_api_punt_acl_add_del_reply_t *rmp; + int rv; + + rv = vnet_set_in_out_acl_intfc ( + vm, 0 /* sw_if_index */, ~0 /* ip4_table_index */, + ~0 /* ip6_table_index */, ~0 /* l2_table_index */, + ntohl (mp->ip4_table_index), ntohl (mp->ip6_table_index), mp->is_add, + 0 /* is_output */); + + REPLY_MACRO (VL_API_PUNT_ACL_ADD_DEL_REPLY); +} + +static void +vl_api_punt_acl_get_t_handler (vl_api_punt_acl_get_t *mp) +{ + vl_api_punt_acl_get_reply_t *rmp; + int rv = 0; + + const in_out_acl_main_t *am = &in_out_acl_main; + + u32 *const *tables = + am->classify_table_index_by_sw_if_index[IN_OUT_ACL_INPUT_TABLE_GROUP]; + const u32 *ip4_table = tables[IN_OUT_ACL_TABLE_IP4_PUNT]; + const u32 *ip6_table = tables[IN_OUT_ACL_TABLE_IP6_PUNT]; + const u32 ip4_table_index = vec_len (ip4_table) ? ip4_table[0] : ~0; + const u32 ip6_table_index = vec_len (ip6_table) ? ip6_table[0] : ~0; + + REPLY_MACRO2 (VL_API_PUNT_ACL_GET_REPLY, ({ + rmp->ip4_table_index = ntohl (ip4_table_index); + rmp->ip6_table_index = ntohl (ip6_table_index); + })); +} + static void vl_api_output_acl_set_interface_t_handler (vl_api_output_acl_set_interface_t * mp) { @@ -915,6 +952,16 @@ static void vl_api_output_acl_set_interface_t_handler static clib_error_t * classify_api_hookup (vlib_main_t * vm) { + api_main_t *am = vlibapi_get_main (); + + /* + * Trace space for classifier mask+match + */ + vl_api_increase_msg_trace_size (am, VL_API_CLASSIFY_ADD_DEL_TABLE, + 5 * sizeof (u32x4)); + vl_api_increase_msg_trace_size (am, VL_API_CLASSIFY_ADD_DEL_SESSION, + 5 * sizeof (u32x4)); + /* * Set up the (msg_name, crc, message-id) table */ |