Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion examples/speed_tester/speed_tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) {
const u_char *packet;
struct pcap_pkthdr header;
char errbuf[PCAP_ERRBUF_SIZE];
uint32_t max_elt_size;

if (pcap_filename != NULL) {
printf("Replaying %s pcap file\n", pcap_filename);
Expand All @@ -326,10 +327,24 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) {

i = 0;

/*
* max_elt_size is the maximum preallocated memory size permitted for each packet,
* adjusted for the memory offset of the rte_mbuf struct and header/tail lengths
*/

max_elt_size = pktmbuf_pool->elt_size - sizeof(struct rte_mbuf) - pktmbuf_pool->header_size - pktmbuf_pool->trailer_size;

while (((packet = pcap_next(pcap, &header)) != NULL) && (i < packet_number)) {
struct onvm_pkt_meta *pmeta;
struct onvm_ft_ipv4_5tuple key;

/* Length of the packet cannot exceed preallocated storage size */
if (header.caplen > max_elt_size) {
nf_local_ctx->nf->stats.tx_drop++;
nf_local_ctx->nf->stats.act_drop++;
continue;
}

pkt = rte_pktmbuf_alloc(pktmbuf_pool);
if (pkt == NULL)
break;
Expand All @@ -355,7 +370,7 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) {
onvm_nflib_return_pkt_bulk(nf_local_ctx->nf, pkts, pkts_generated);
} else {
#endif
/* use default number of initial packets if -c has not been used */
/* Use default number of initial packets if -c has not been used */
packet_number = (use_custom_pkt_count ? packet_number : DEFAULT_PKT_NUM);
struct rte_mbuf *pkts[packet_number];

Expand Down