From 6f5ddf3461906bbc88f679882744afc74a81cae1 Mon Sep 17 00:00:00 2001 From: Alexander Chernavin Date: Fri, 6 May 2022 11:35:59 +0000 Subject: flowprobe: add support for reporting on inbound packets Type: feature Currently, the plugin supports only IPFIX flow record generation for outbound packets. With this change: - add a new API message for enabling the feature on an interface that accepts direction (rx, tx, both); - update existing debug command for feature enabling to accept direction; - update existing debug command for showing currently enabled feature on interfaces to display direction; - update templates to include a direction field; - generate flow records on the specified direction and data path; - report direction in flow data; - update tests to use the new API; - add tests for inbound flows. Change-Id: I121fd904b38408641036ebeea848df7a4e5e0b30 Signed-off-by: Alexander Chernavin --- src/plugins/flowprobe/flowprobe_test.c | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'src/plugins/flowprobe/flowprobe_test.c') diff --git a/src/plugins/flowprobe/flowprobe_test.c b/src/plugins/flowprobe/flowprobe_test.c index a694e45ae9b..ae2a3edf64a 100644 --- a/src/plugins/flowprobe/flowprobe_test.c +++ b/src/plugins/flowprobe/flowprobe_test.c @@ -92,6 +92,63 @@ api_flowprobe_tx_interface_add_del (vat_main_t * vam) return ret; } +static int +api_flowprobe_interface_add_del (vat_main_t *vam) +{ + unformat_input_t *i = vam->input; + int enable_disable = 1; + u8 which = FLOWPROBE_WHICH_IP4; + u8 direction = FLOWPROBE_DIRECTION_TX; + u32 sw_if_index = ~0; + vl_api_flowprobe_interface_add_del_t *mp; + int ret; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "disable")) + enable_disable = 0; + else if (unformat (i, "ip4")) + which = FLOWPROBE_WHICH_IP4; + else if (unformat (i, "ip6")) + which = FLOWPROBE_WHICH_IP6; + else if (unformat (i, "l2")) + which = FLOWPROBE_WHICH_L2; + else if (unformat (i, "rx")) + direction = FLOWPROBE_DIRECTION_RX; + else if (unformat (i, "tx")) + direction = FLOWPROBE_DIRECTION_TX; + else if (unformat (i, "both")) + direction = FLOWPROBE_DIRECTION_BOTH; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("Missing interface name / explicit sw_if_index number\n"); + return -99; + } + + /* Construct the API message */ + M (FLOWPROBE_INTERFACE_ADD_DEL, mp); + mp->sw_if_index = ntohl (sw_if_index); + mp->is_add = enable_disable; + mp->which = which; + mp->direction = direction; + + /* Send it... */ + S (mp); + + /* Wait for a reply... */ + W (ret); + return ret; +} + static int api_flowprobe_params (vat_main_t * vam) { -- cgit 1.2.3-korg