Skip to content
Merged
Changes from 1 commit
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
14 changes: 13 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,6 +327,13 @@ 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
*/

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

while (((packet = pcap_next(pcap, &header)) != NULL) && (i < packet_number)) {
struct onvm_pkt_meta *pmeta;
struct onvm_ft_ipv4_5tuple key;
Expand All @@ -334,6 +342,10 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) {
if (pkt == NULL)
break;

/* Length of the packet cannot exceed preallocated storage size */
if (header.caplen > max_elt_size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 341: pkt = rte_pktmbuf_alloc(pktmbuf_pool); But you continue here without freeing that packet. Perhaps move this continue statement before the allocation occurs?

continue;

pkt->pkt_len = header.caplen;
pkt->data_len = header.caplen;

Expand All @@ -355,7 +367,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