diff options
author | Andrew Yourtchenko <ayourtch@gmail.com> | 2019-08-15 12:26:17 +0000 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2019-08-16 19:54:39 +0000 |
commit | c02924ec6ebe0aa8e4903c6ca2cc0bf6c36da8cb (patch) | |
tree | 250105b8cbd9759ddffbdd08c65b51c5b2383946 /src | |
parent | 5cd987dda679fe50b9cd7a834bb9162db39ade78 (diff) |
acl: fix stats-segment counters validation on acl update
The stats-segment validation/clear logic for acl counters was wrong,
fix it. Also add the code to the unittests to cover that case,
add a vat command to enable/disable counters, clean up
the unnecessary endian conversion and remove the stray clib_warning()
Change-Id: I421297a92e4aeb885c468c72a97cec25981df615
Type: fix
Ticket: VPP-1744
Fixes: f995c7122ba0d024b17bc3232e8edd18d5e25088
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
(cherry picked from commit 4c945dacb9ff9da731301feb26b1edb4ac00e8bd)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/acl/acl.c | 15 | ||||
-rw-r--r-- | src/plugins/acl/acl_test.c | 39 |
2 files changed, 46 insertions, 8 deletions
diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c index 24dd53bd749..6b120563c9b 100644 --- a/src/plugins/acl/acl.c +++ b/src/plugins/acl/acl.c @@ -391,14 +391,19 @@ validate_and_reset_acl_counters (acl_main_t * am, u32 acl_index) /* filled in once only */ am->combined_acl_counters[i].stat_segment_name = (void *) format (0, "/acl/%d/matches%c", i, 0); - clib_warning ("add stats segment: %s", - am->combined_acl_counters[i].stat_segment_name); - i32 rule_count = vec_len (am->acls[acl_index].rules); + i32 rule_count = vec_len (am->acls[i].rules); /* Validate one extra so we always have at least one counter for an ACL */ vlib_validate_combined_counter (&am->combined_acl_counters[i], rule_count); - vlib_zero_combined_counter (&am->combined_acl_counters[i], rule_count); + vlib_clear_combined_counters (&am->combined_acl_counters[i]); } + + /* (re)validate for the actual ACL that is getting added/updated */ + i32 rule_count = vec_len (am->acls[acl_index].rules); + /* Validate one extra so we always have at least one counter for an ACL */ + vlib_validate_combined_counter (&am->combined_acl_counters[acl_index], + rule_count); + vlib_clear_combined_counters (&am->combined_acl_counters[acl_index]); acl_plugin_counter_unlock (am); } @@ -1945,7 +1950,7 @@ static void vl_api_acl_stats_intf_counters_enable_reply_t *rmp; int rv; - rv = acl_stats_intf_counters_enable_disable (am, ntohl (mp->enable)); + rv = acl_stats_intf_counters_enable_disable (am, mp->enable); REPLY_MACRO (VL_API_ACL_DEL_REPLY); } diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 9185cc12329..ec951ad7057 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -68,7 +68,8 @@ _(acl_interface_add_del_reply) \ _(macip_acl_interface_add_del_reply) \ _(acl_interface_set_acl_list_reply) \ _(acl_interface_set_etype_whitelist_reply) \ -_(macip_acl_del_reply) +_(macip_acl_del_reply) \ +_(acl_stats_intf_counters_enable_reply) #define foreach_reply_retval_aclindex_handler \ _(acl_add_replace_reply) \ @@ -310,7 +311,8 @@ _(MACIP_ACL_INTERFACE_ADD_DEL_REPLY, macip_acl_interface_add_del_reply) \ _(MACIP_ACL_INTERFACE_GET_REPLY, macip_acl_interface_get_reply) \ _(ACL_PLUGIN_CONTROL_PING_REPLY, acl_plugin_control_ping_reply) \ _(ACL_PLUGIN_GET_VERSION_REPLY, acl_plugin_get_version_reply) \ -_(ACL_PLUGIN_GET_CONN_TABLE_MAX_ENTRIES_REPLY,acl_plugin_get_conn_table_max_entries_reply) +_(ACL_PLUGIN_GET_CONN_TABLE_MAX_ENTRIES_REPLY,acl_plugin_get_conn_table_max_entries_reply) \ +_(ACL_STATS_INTF_COUNTERS_ENABLE_REPLY, acl_stats_intf_counters_enable_reply) static int api_acl_plugin_get_version (vat_main_t * vam) { @@ -574,6 +576,36 @@ static int api_acl_plugin_get_conn_table_max_entries (vat_main_t * vam) return ret; } +static int api_acl_stats_intf_counters_enable (vat_main_t * vam) +{ + acl_test_main_t * sm = &acl_test_main; + unformat_input_t * i = vam->input; + vl_api_acl_stats_intf_counters_enable_t * mp; + u32 msg_size = sizeof(*mp); + int ret; + + vam->result_ready = 0; + mp = vl_msg_api_alloc_as_if_client(msg_size); + memset (mp, 0, msg_size); + mp->_vl_msg_id = ntohs (VL_API_ACL_STATS_INTF_COUNTERS_ENABLE + sm->msg_id_base); + mp->client_index = vam->my_client_index; + mp->enable = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { + if (unformat (i, "disable")) + mp->enable = 0; + else + break; + } + + /* send it... */ + S(mp); + + /* Wait for a reply... */ + W (ret); + return ret; +} + /* * Read the series of ACL entries from file in the following format: @@ -1485,7 +1517,8 @@ _(macip_acl_del, "<acl-idx>")\ _(macip_acl_dump, "[<acl-idx>]") \ _(macip_acl_interface_add_del, "<intfc> | sw_if_index <if-idx> [add|del] acl <acl-idx>") \ _(macip_acl_interface_get, "") \ -_(acl_plugin_get_conn_table_max_entries, "") +_(acl_plugin_get_conn_table_max_entries, "") \ +_(acl_stats_intf_counters_enable, "[disable]") static |