summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-12-09 15:51:44 +0100
committerPaul Vinciguerra <pvinci@vinciconsulting.com>2019-12-10 04:08:58 +0000
commit3013e69884ce99aa27049947408286e16905f302 (patch)
tree38b2dd6e8c9e20843a3b213bd4d9ff0400d59ac4
parent39d69112fcec114fde34955ceb41555221d3ba11 (diff)
flowprobe: use explicit types in api
Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I4f1cccca7de0c07cee472bde80cd6b0ef60046bd
-rw-r--r--src/plugins/flowprobe/flowprobe.api28
-rw-r--r--src/plugins/flowprobe/flowprobe.c12
-rw-r--r--src/plugins/flowprobe/flowprobe_test.c12
-rw-r--r--src/plugins/flowprobe/test/test_flowprobe.py17
4 files changed, 44 insertions, 25 deletions
diff --git a/src/plugins/flowprobe/flowprobe.api b/src/plugins/flowprobe/flowprobe.api
index 830e4420e4e..8e8b90fc4e3 100644
--- a/src/plugins/flowprobe/flowprobe.api
+++ b/src/plugins/flowprobe/flowprobe.api
@@ -7,11 +7,27 @@
option version = "1.0.0";
+import "vnet/interface_types.api";
+
+enum flowprobe_which_flags : u8
+{
+ FLOWPROBE_WHICH_FLAG_IP4 = 0x1,
+ FLOWPROBE_WHICH_FLAG_L2 = 0x2,
+ FLOWPROBE_WHICH_FLAG_IP6 = 0x4,
+};
+
+enum flowprobe_record_flags : u8
+{
+ FLOWPROBE_RECORD_FLAG_L2 = 0x1,
+ FLOWPROBE_RECORD_FLAG_L3 = 0x2,
+ FLOWPROBE_RECORD_FLAG_L4 = 0x4,
+};
+
/** \brief Enable / disable per-packet IPFIX recording on an interface
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param is_add - add address if non-zero, else delete
- @param is_ipv6 - if non-zero the address is ipv6, else ipv4
+ @param which - flags indicating forwarding path
@param sw_if_index - index of the interface
*/
autoreply manual_print define flowprobe_tx_interface_add_del
@@ -23,11 +39,11 @@ autoreply manual_print define flowprobe_tx_interface_add_del
u32 context;
/* Enable / disable the feature */
- u8 is_add;
- u8 which; /* 0 = ipv4, 1 = l2, 2 = ipv6 */
+ bool is_add;
+ vl_api_flowprobe_which_flags_t which;
/* Interface handle */
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
option vat_help = "<intfc> [disable]";
};
@@ -35,9 +51,7 @@ autoreply define flowprobe_params
{
u32 client_index;
u32 context;
- u8 record_l2;
- u8 record_l3;
- u8 record_l4;
+ vl_api_flowprobe_record_flags_t record_flags;
u32 active_timer; /* ~0 is off, 0 is default */
u32 passive_timer; /* ~0 is off, 0 is default */
option vat_help = "record <[l2] [l3] [l4]> [active <timer> passive <timer>]";
diff --git a/src/plugins/flowprobe/flowprobe.c b/src/plugins/flowprobe/flowprobe.c
index 0b070219abd..93d380110a1 100644
--- a/src/plugins/flowprobe/flowprobe.c
+++ b/src/plugins/flowprobe/flowprobe.c
@@ -632,13 +632,6 @@ void vl_api_flowprobe_tx_interface_add_del_t_handler
VALIDATE_SW_IF_INDEX (mp);
- if (mp->which != FLOW_VARIANT_IP4 && mp->which != FLOW_VARIANT_L2
- && mp->which != FLOW_VARIANT_IP6)
- {
- rv = VNET_API_ERROR_UNIMPLEMENTED;
- goto out;
- }
-
if (fm->record == 0)
{
clib_warning ("Please specify flowprobe params record first...");
@@ -730,7 +723,10 @@ vl_api_flowprobe_params_t_handler (vl_api_flowprobe_params_t * mp)
int rv = 0;
rv = flowprobe_params
- (fm, mp->record_l2, mp->record_l3, mp->record_l4,
+ (fm,
+ mp->record_flags & FLOWPROBE_RECORD_FLAG_L2,
+ mp->record_flags & FLOWPROBE_RECORD_FLAG_L3,
+ mp->record_flags & FLOWPROBE_RECORD_FLAG_L4,
clib_net_to_host_u32 (mp->active_timer),
clib_net_to_host_u32 (mp->passive_timer));
diff --git a/src/plugins/flowprobe/flowprobe_test.c b/src/plugins/flowprobe/flowprobe_test.c
index 245707d417d..a694e45ae9b 100644
--- a/src/plugins/flowprobe/flowprobe_test.c
+++ b/src/plugins/flowprobe/flowprobe_test.c
@@ -96,11 +96,11 @@ static int
api_flowprobe_params (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- u8 record_l2 = 0, record_l3 = 0, record_l4 = 0;
u32 active_timer = ~0;
u32 passive_timer = ~0;
vl_api_flowprobe_params_t *mp;
int ret;
+ u8 record_flags = 0;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
@@ -112,11 +112,11 @@ api_flowprobe_params (vat_main_t * vam)
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "l2"))
- record_l2 = 1;
+ record_flags |= FLOWPROBE_RECORD_FLAG_L2;
else if (unformat (i, "l3"))
- record_l3 = 1;
+ record_flags |= FLOWPROBE_RECORD_FLAG_L3;
else if (unformat (i, "l4"))
- record_l4 = 1;
+ record_flags |= FLOWPROBE_RECORD_FLAG_L4;
else
break;
}
@@ -132,9 +132,7 @@ api_flowprobe_params (vat_main_t * vam)
/* Construct the API message */
M (FLOWPROBE_PARAMS, mp);
- mp->record_l2 = record_l2;
- mp->record_l3 = record_l3;
- mp->record_l4 = record_l4;
+ mp->record_flags = record_flags;
mp->active_timer = ntohl (active_timer);
mp->passive_timer = ntohl (passive_timer);
diff --git a/src/plugins/flowprobe/test/test_flowprobe.py b/src/plugins/flowprobe/test/test_flowprobe.py
index 70b3acbd723..092e8d3951d 100644
--- a/src/plugins/flowprobe/test/test_flowprobe.py
+++ b/src/plugins/flowprobe/test/test_flowprobe.py
@@ -20,6 +20,7 @@ from ipfix import IPFIX, Set, Template, Data, IPFIXDecoder
from vpp_ip_route import VppIpRoute, VppRoutePath
from vpp_papi.macaddress import mac_ntop
from socket import inet_ntop
+from vpp_papi import VppEnum
class VppCFLOW(VppObject):
@@ -42,10 +43,20 @@ class VppCFLOW(VppObject):
def add_vpp_config(self):
self.enable_exporter()
+ l2_flag = 0
+ l3_flag = 0
+ l4_flag = 0
+ if 'l2' in self._collect.lower():
+ l2_flag = (VppEnum.vl_api_flowprobe_record_flags_t.
+ FLOWPROBE_RECORD_FLAG_L2)
+ if 'l3' in self._collect.lower():
+ l3_flag = (VppEnum.vl_api_flowprobe_record_flags_t.
+ FLOWPROBE_RECORD_FLAG_L3)
+ if 'l4' in self._collect.lower():
+ l4_flag = (VppEnum.vl_api_flowprobe_record_flags_t.
+ FLOWPROBE_RECORD_FLAG_L4)
self._test.vapi.flowprobe_params(
- record_l2=1 if 'l2' in self._collect.lower() else 0,
- record_l3=1 if 'l3' in self._collect.lower() else 0,
- record_l4=1 if 'l4' in self._collect.lower() else 0,
+ record_flags=(l2_flag | l3_flag | l4_flag),
active_timer=self._active, passive_timer=self._passive)
self.enable_flowprobe_feature()
self._test.vapi.cli("ipfix flush")