aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/ipfix-export/flow_api.c34
-rw-r--r--src/vnet/ipfix-export/ipfix_export.api7
-rw-r--r--test/test_flowprobe.py52
-rw-r--r--test/test_nat.py22
4 files changed, 75 insertions, 40 deletions
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")
diff --git a/test/test_flowprobe.py b/test/test_flowprobe.py
index 544d3beb328..9ffe84b8c2c 100644
--- a/test/test_flowprobe.py
+++ b/test/test_flowprobe.py
@@ -494,7 +494,7 @@ class Datapath(MethodHolder):
ipfix.add_vpp_config()
# template packet should arrive immediately
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
ipfix.verify_templates(timeout=3, count=1)
self.collector.get_capture(1)
@@ -518,7 +518,7 @@ class Datapath(MethodHolder):
capture = self.send_packets()
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{2: 'packets', 256: 8})
@@ -544,7 +544,7 @@ class Datapath(MethodHolder):
capture = self.send_packets()
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{2: 'packets', 4: 17,
@@ -572,7 +572,7 @@ class Datapath(MethodHolder):
capture = self.send_packets()
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{2: 'packets', 7: 'sport', 11: 'dport'})
@@ -592,7 +592,7 @@ class Datapath(MethodHolder):
ipfix.add_vpp_config()
# template packet should arrive immediately
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
ipfix.verify_templates(timeout=3, count=1)
self.collector.get_capture(1)
@@ -617,7 +617,7 @@ class Datapath(MethodHolder):
capture = self.send_packets(src_if=self.pg3, dst_if=self.pg4)
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{2: 'packets', 256: 8})
@@ -645,7 +645,7 @@ class Datapath(MethodHolder):
capture = self.send_packets(src_if=self.pg3, dst_if=self.pg4)
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{1: 'octets', 2: 'packets',
@@ -674,7 +674,7 @@ class Datapath(MethodHolder):
capture = self.send_packets(src_if=self.pg3, dst_if=self.pg4)
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{2: 'packets', 7: 'sport', 11: 'dport'})
@@ -719,7 +719,7 @@ class Datapath(MethodHolder):
capture = self.send_packets(src_if=self.pg5, dst_if=self.pg6)
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{2: 'packets', 256: 56710},
@@ -749,7 +749,7 @@ class Datapath(MethodHolder):
capture = self.send_packets(src_if=self.pg5, dst_if=self.pg6)
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{2: 'packets',
@@ -780,7 +780,7 @@ class Datapath(MethodHolder):
capture = self.send_packets(src_if=self.pg5, dst_if=self.pg6)
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[0])
self.verify_cflow_data_detail(ipfix_decoder, capture, cflow,
{2: 'packets', 7: 'sport', 11: 'dport'},
@@ -809,7 +809,7 @@ class Datapath(MethodHolder):
capture = self.send_packets()
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflow = self.wait_for_cflow_packet(self.collector, templates[1])
self.verify_cflow_data_notimer(ipfix_decoder, capture, [cflow])
self.collector.get_capture(4)
@@ -828,7 +828,7 @@ class Datapath(MethodHolder):
ipfix_decoder = IPFIXDecoder()
# template packet should arrive immediately
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
templates = ipfix.verify_templates(ipfix_decoder)
self.create_stream(packets=6)
@@ -836,7 +836,7 @@ class Datapath(MethodHolder):
# make sure the one packet we expect actually showed up
cflows = []
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
cflows.append(self.wait_for_cflow_packet(self.collector,
templates[1]))
cflows.append(self.wait_for_cflow_packet(self.collector,
@@ -877,7 +877,7 @@ class DisableIPFIX(MethodHolder):
self.send_packets()
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1])
self.collector.get_capture(4)
@@ -888,7 +888,7 @@ class DisableIPFIX(MethodHolder):
self.send_packets()
# make sure no one packet arrived in 1 minute
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1],
expected=False)
self.collector.get_capture(0)
@@ -927,19 +927,19 @@ class ReenableIPFIX(MethodHolder):
self.send_packets()
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1])
self.collector.get_capture(4)
# disable IPFIX
ipfix.disable_exporter()
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.pg_enable_capture([self.collector])
self.send_packets()
# make sure no one packet arrived in active timer span
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1],
expected=False)
self.collector.get_capture(0)
@@ -994,7 +994,7 @@ class DisableFP(MethodHolder):
self.send_packets()
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1])
self.collector.get_capture(4)
@@ -1005,7 +1005,7 @@ class DisableFP(MethodHolder):
self.send_packets()
# make sure no one packet arrived in active timer span
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1],
expected=False)
self.collector.get_capture(0)
@@ -1038,14 +1038,14 @@ class ReenableFP(MethodHolder):
ipfix_decoder = IPFIXDecoder()
# template packet should arrive immediately
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
templates = ipfix.verify_templates(ipfix_decoder, timeout=3)
self.create_stream()
self.send_packets()
# make sure the one packet we expect actually showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1], 5)
self.collector.get_capture(4)
@@ -1056,21 +1056,21 @@ class ReenableFP(MethodHolder):
self.send_packets()
# make sure no one packet arrived in active timer span
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1], 5,
expected=False)
self.collector.get_capture(0)
# enable FPP feature
ipfix.enable_flowprobe_feature()
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
templates = ipfix.verify_templates(ipfix_decoder, timeout=3)
self.send_packets()
# make sure the next packets (templates and data) we expect actually
# showed up
- self.vapi.cli("ipfix flush")
+ self.vapi.ipfix_flush()
self.wait_for_cflow_packet(self.collector, templates[1], 5)
self.collector.get_capture(4)
diff --git a/test/test_nat.py b/test/test_nat.py
index 9ee82da5e2b..ccc9be7b5c5 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -2818,7 +2818,7 @@ class TestNAT44(MethodHolder):
capture = self.pg1.get_capture(len(pkts))
self.verify_capture_out(capture)
self.nat44_add_address(self.nat_addr, is_add=0)
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
capture = self.pg3.get_capture(9)
ipfix = IPFIXDecoder()
# first load template
@@ -2863,7 +2863,7 @@ class TestNAT44(MethodHolder):
self.pg_start()
self.pg1.assert_nothing_captured()
sleep(1)
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.cli("ipfix flush")
capture = self.pg3.get_capture(9)
ipfix = IPFIXDecoder()
# first load template
@@ -2926,7 +2926,7 @@ class TestNAT44(MethodHolder):
self.pg_start()
self.pg1.assert_nothing_captured()
sleep(1)
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
capture = self.pg3.get_capture(9)
ipfix = IPFIXDecoder()
# first load template
@@ -3851,7 +3851,7 @@ class TestNAT44(MethodHolder):
self.pg_start()
self.pg1.assert_nothing_captured()
sleep(1)
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
capture = self.pg3.get_capture(9)
ipfix = IPFIXDecoder()
# first load template
@@ -6776,7 +6776,7 @@ class TestNAT44EndpointDependent(MethodHolder):
capture = self.pg1.assert_nothing_captured()
# verify IPFIX logging
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
sleep(1)
capture = self.pg2.get_capture(10)
ipfix = IPFIXDecoder()
@@ -7556,7 +7556,7 @@ class TestDeterministicNAT(MethodHolder):
self.assertEqual(1000, dms[0].ses_num)
# verify IPFIX logging
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
sleep(1)
capture = self.pg2.get_capture(2)
ipfix = IPFIXDecoder()
@@ -8792,7 +8792,7 @@ class TestNAT64(MethodHolder):
self.pg_start()
self.pg1.assert_nothing_captured()
sleep(1)
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
capture = self.pg3.get_capture(9)
ipfix = IPFIXDecoder()
# first load template
@@ -8820,7 +8820,7 @@ class TestNAT64(MethodHolder):
self.pg_start()
self.pg1.assert_nothing_captured()
sleep(1)
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
capture = self.pg3.get_capture(1)
# verify events in data set
for p in capture:
@@ -8865,7 +8865,7 @@ class TestNAT64(MethodHolder):
self.pg_start()
self.pg1.assert_nothing_captured()
sleep(1)
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
capture = self.pg3.get_capture(9)
ipfix = IPFIXDecoder()
# first load template
@@ -8919,7 +8919,7 @@ class TestNAT64(MethodHolder):
self.pg_start()
p = self.pg1.get_capture(1)
self.tcp_port_out = p[0][TCP].sport
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
capture = self.pg3.get_capture(10)
ipfix = IPFIXDecoder()
# first load template
@@ -8954,7 +8954,7 @@ class TestNAT64(MethodHolder):
end_addr=self.nat_addr,
vrf_id=0xFFFFFFFF,
is_add=0)
- self.vapi.cli("ipfix flush") # FIXME this should be an API call
+ self.vapi.ipfix_flush()
capture = self.pg3.get_capture(2)
# verify events in data set
for p in capture: