summaryrefslogtreecommitdiffstats
path: root/src/vnet/interface_cli.c
diff options
context:
space:
mode:
authorJack Xu <jack.c.xu@ericsson.com>2019-03-27 11:51:32 -0400
committerDamjan Marion <dmarion@me.com>2019-08-20 11:07:49 +0000
commit9af7e2e87e6a11fb69309fc9ce4bf8432acbc4e3 (patch)
tree7eb29962a17227351ed68f6f9a09a1b27e155977 /src/vnet/interface_cli.c
parent053204ab039d34a990ff0e14c32ce3b294fcce0e (diff)
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 <jack.c.xu@ericsson.com>
Diffstat (limited to 'src/vnet/interface_cli.c')
-rw-r--r--src/vnet/interface_cli.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index 437854476b4..8db26391573 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -1743,6 +1743,8 @@ pcap_trace_command_internal (vlib_main_t * vm,
vm->pcap[rx_tx].pcap_main.n_packets_to_capture =
vm->pcap[rx_tx].pcap_main.n_packets_captured;
error = pcap_write (&vm->pcap[rx_tx].pcap_main);
+ if (vm->pcap[rx_tx].pcap_main.file_descriptor >= 0)
+ pcap_close (&vm->pcap[rx_tx].pcap_main);
if (error)
clib_error_report (error);
else