summaryrefslogtreecommitdiffstats
path: root/src/vnet/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/unix')
-rw-r--r--src/vnet/unix/pcap.h28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/vnet/unix/pcap.h b/src/vnet/unix/pcap.h
index 7d55db37979..1ab1531cfa3 100644
--- a/src/vnet/unix/pcap.h
+++ b/src/vnet/unix/pcap.h
@@ -211,23 +211,21 @@ pcap_add_buffer (pcap_main_t * pm,
f64 time_now = vlib_time_now (vm);
void *d;
- d = pcap_add_packet (pm, time_now, n_left, n);
- while (1)
+ if (PREDICT_TRUE (pm->n_packets_captured < pm->n_packets_to_capture))
{
- u32 copy_length = clib_min ((u32) n_left, b->current_length);
- clib_memcpy (d, b->data + b->current_data, copy_length);
- n_left -= b->current_length;
- if (n_left <= 0)
- break;
- d += b->current_length;
- ASSERT (b->flags & VLIB_BUFFER_NEXT_PRESENT);
- b = vlib_get_buffer (vm, b->next_buffer);
+ d = pcap_add_packet (pm, time_now, n_left, n);
+ while (1)
+ {
+ u32 copy_length = clib_min ((u32) n_left, b->current_length);
+ clib_memcpy (d, b->data + b->current_data, copy_length);
+ n_left -= b->current_length;
+ if (n_left <= 0)
+ break;
+ d += b->current_length;
+ ASSERT (b->flags & VLIB_BUFFER_NEXT_PRESENT);
+ b = vlib_get_buffer (vm, b->next_buffer);
+ }
}
-
- /** Flush output vector. */
- if (vec_len (pm->pcap_data) >= 64 * 1024
- || pm->n_packets_captured >= pm->n_packets_to_capture)
- pcap_write (pm);
}
#endif /* included_vnet_pcap_h */