Code Review
/
vpp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
review
|
tree
raw
|
patch
|
inline
| side by side (parent:
39d6911
)
flowprobe: use explicit types in api
83/23883/2
author
Ole Troan
<ot@cisco.com>
Mon, 9 Dec 2019 14:51:44 +0000
(15:51 +0100)
committer
Paul Vinciguerra
<pvinci@vinciconsulting.com>
Tue, 10 Dec 2019 04:08:58 +0000
(
04:08
+0000)
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I4f1cccca7de0c07cee472bde80cd6b0ef60046bd
src/plugins/flowprobe/flowprobe.api
patch
|
blob
|
history
src/plugins/flowprobe/flowprobe.c
patch
|
blob
|
history
src/plugins/flowprobe/flowprobe_test.c
patch
|
blob
|
history
src/plugins/flowprobe/test/test_flowprobe.py
patch
|
blob
|
history
diff --git
a/src/plugins/flowprobe/flowprobe.api
b/src/plugins/flowprobe/flowprobe.api
index
830e442
..
8e8b90f
100644
(file)
--- a/
src/plugins/flowprobe/flowprobe.api
+++ b/
src/plugins/flowprobe/flowprobe.api
@@
-7,11
+7,27
@@
option version = "1.0.0";
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
/** \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
@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 */
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 */
/* Interface handle */
-
u32
sw_if_index;
+
vl_api_interface_index_t
sw_if_index;
option vat_help = "<intfc> [disable]";
};
option vat_help = "<intfc> [disable]";
};
@@
-35,9
+51,7
@@
autoreply define flowprobe_params
{
u32 client_index;
u32 context;
{
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>]";
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
0b07021
..
93d3801
100644
(file)
--- 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);
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...");
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
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));
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
245707d
..
a694e45
100644
(file)
--- 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;
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;
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)
{
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"))
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"))
else if (unformat (i, "l3"))
- record_
l3 = 1
;
+ record_
flags |= FLOWPROBE_RECORD_FLAG_L3
;
else if (unformat (i, "l4"))
else if (unformat (i, "l4"))
- record_
l4 = 1
;
+ record_
flags |= FLOWPROBE_RECORD_FLAG_L4
;
else
break;
}
else
break;
}
@@
-132,9
+132,7
@@
api_flowprobe_params (vat_main_t * vam)
/* Construct the API message */
M (FLOWPROBE_PARAMS, mp);
/* 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);
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
70b3acb
..
092e8d3
100644
(file)
--- 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_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):
class VppCFLOW(VppObject):
@@
-42,10
+43,20
@@
class VppCFLOW(VppObject):
def add_vpp_config(self):
self.enable_exporter()
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(
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")
active_timer=self._active, passive_timer=self._passive)
self.enable_flowprobe_feature()
self._test.vapi.cli("ipfix flush")