From 9af7e2e87e6a11fb69309fc9ce4bf8432acbc4e3 Mon Sep 17 00:00:00 2001 From: Jack Xu Date: Wed, 27 Mar 2019 11:51:32 -0400 Subject: fix pcap_write function when use pcap cli to capture pcakets into two files rx01.pcap && rx02.pcap, the first time: 1)pcap rx trace on max 100 intfc any file rx01.pcap 2)......the process of capture data to buffer...... 3)pcap rx trace off the second time: 4)pcap rx trace on max 100 intfc any file rx02.pcap 5)......the process of capture data to buffer...... 6)pcap rx trace off the pcap_write function bug in this two lines pm->n_packets_captured = 0; if (pm->n_packets_captured >= pm->n_packets_to_capture) referring to calling pcap_close() will result in that the twice pcap cli both writes the packets into rx01.pcap, but nothing into rx02.pcap. Beside, the rx02.pcap file will not be created. solution: separate the pcap_close() out of pcap_write() Change-Id: Iedeb46f9cf0a4cb12449fd75a4014f95f3bb3fa8 Signed-off-by: Jack Xu --- src/vppinfra/pcap.c | 3 --- src/vppinfra/pcap_funcs.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/vppinfra') diff --git a/src/vppinfra/pcap.c b/src/vppinfra/pcap.c index 8f644e30f1d..0ca923e81cf 100644 --- a/src/vppinfra/pcap.c +++ b/src/vppinfra/pcap.c @@ -157,9 +157,6 @@ pcap_write (pcap_main_t * pm) pm->n_pcap_data_written = 0; } - if (pm->n_packets_captured >= pm->n_packets_to_capture) - pcap_close (pm); - done: if (error) { diff --git a/src/vppinfra/pcap_funcs.h b/src/vppinfra/pcap_funcs.h index 364f4be2333..a3a3072f955 100644 --- a/src/vppinfra/pcap_funcs.h +++ b/src/vppinfra/pcap_funcs.h @@ -22,6 +22,9 @@ clib_error_t *pcap_write (pcap_main_t * pm); /** Read data from file. */ clib_error_t *pcap_read (pcap_main_t * pm); +/** Close the file created by pcap_write function. */ +clib_error_t *pcap_close (pcap_main_t * pm); + /** * @brief Add packet * -- cgit 1.2.3-korg