From 21b83e96d6076cda01ee80343840bc1166557150 Mon Sep 17 00:00:00 2001 From: Paul Vinciguerra Date: Mon, 24 Jun 2019 09:55:46 -0400 Subject: api: implement ipfix_flush -Migrate tests to api and cleanup: '# FIXME this should be an API call' in tests. Type: feature Change-Id: I715f9f8acc0f2af9c974ea221b2aea46692a6218 Signed-off-by: Paul Vinciguerra --- src/vnet/ipfix-export/flow_api.c | 34 ++++++++++++++++++++++++++++++++-- src/vnet/ipfix-export/ipfix_export.api | 7 ++++++- 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'src/vnet/ipfix-export') diff --git a/src/vnet/ipfix-export/flow_api.c b/src/vnet/ipfix-export/flow_api.c index e89f1a63ce6..959671d3751 100644 --- a/src/vnet/ipfix-export/flow_api.c +++ b/src/vnet/ipfix-export/flow_api.c @@ -51,13 +51,15 @@ _(IPFIX_EXPORTER_DUMP, ipfix_exporter_dump) \ _(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream) \ _(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump) \ _(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del) \ -_(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) +_(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) \ +_(IPFIX_FLUSH, ipfix_flush) static void vl_api_set_ipfix_exporter_t_handler (vl_api_set_ipfix_exporter_t * mp) { vlib_main_t *vm = vlib_get_main (); flow_report_main_t *frm = &flow_report_main; + vl_api_registration_t *reg; vl_api_set_ipfix_exporter_reply_t *rmp; ip4_address_t collector, src; u16 collector_port = UDP_DST_PORT_ipfix; @@ -68,6 +70,10 @@ vl_api_set_ipfix_exporter_t_handler (vl_api_set_ipfix_exporter_t * mp) u32 fib_index = ~0; int rv = 0; + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + memcpy (collector.data, mp->collector_address, sizeof (collector.data)); collector_port = ntohs (mp->collector_port); if (collector_port == (u16) ~ 0) @@ -155,7 +161,7 @@ vl_api_ipfix_exporter_dump_t_handler (vl_api_ipfix_exporter_dump_t * mp) reg = vl_api_client_index_to_registration (mp->client_index); if (!reg) - return;; + return; rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); @@ -233,6 +239,7 @@ static void (vl_api_ipfix_classify_table_add_del_t * mp) { vl_api_ipfix_classify_table_add_del_reply_t *rmp; + vl_api_registration_t *reg; flow_report_classify_main_t *fcm = &flow_report_classify_main; flow_report_main_t *frm = &flow_report_main; vnet_flow_report_add_del_args_t args; @@ -243,6 +250,10 @@ static void u8 transport_protocol; int rv = 0; + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + classify_table_index = ntohl (mp->table_id); ip_version = mp->ip_version; transport_protocol = mp->transport_protocol; @@ -343,6 +354,25 @@ static void send_ipfix_classify_table_details (i, reg, mp->context); } +static void +vl_api_ipfix_flush_t_handler (vl_api_ipfix_flush_t * mp) +{ + vl_api_ipfix_flush_reply_t *rmp; + vl_api_registration_t *reg; + vlib_main_t *vm = vlib_get_main (); + int rv = 0; + + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + + /* poke the flow reporting process */ + vlib_process_signal_event (vm, flow_report_process_node.index, + 1 /* type_opaque */ , 0 /* data */ ); + + REPLY_MACRO (VL_API_IPFIX_FLUSH_REPLY); +} + /* * flow_api_hookup * Add vpe's API message handlers to the table. diff --git a/src/vnet/ipfix-export/ipfix_export.api b/src/vnet/ipfix-export/ipfix_export.api index 9bd3790a430..8b13c3bd720 100644 --- a/src/vnet/ipfix-export/ipfix_export.api +++ b/src/vnet/ipfix-export/ipfix_export.api @@ -13,7 +13,7 @@ * limitations under the License. */ -option version = "1.0.0"; +option version = "1.0.1"; /** \brief Configure IPFIX exporter process request @param client_index - opaque cookie to identify the sender @@ -142,6 +142,11 @@ define ipfix_classify_table_details { u8 transport_protocol; }; +autoreply define ipfix_flush { + u32 client_index; + u32 context; +}; + /* * Local Variables: * eval: (c-set-style "gnu") -- cgit 1.2.3-korg