You need something like: pfring_zc_pkt_buff **pkts = &buffers[id * burst_sz] num_pkts = pfring_zc_recv_pkt_burst(..., pkts, burst_sz, ...);
Alfredo > On 16 Jul 2015, at 21:29, Nick Allen <[email protected]> wrote: > > > I am trying to load balance incoming network packets across multiple > consumer threads. Each thread should grab a batch of packets at a time. If > I set the batch size (burst_sz) to 1, everything works. But if the batch > size is greater than 1, I get a seg fault. This makes me think that I am > doing something really stupid here. What am I missing? > > // step 1: each thread captures 'burst_sz' packets at a time > burst_sz = 32; > > // step 2: a packet buffer that serves all threads. each thread > // has its own space within the buffer. > pfring_zc_pkt_buff **buffers; > > // step 3: create the packet buffers for each thread > buff_count = num_threads * burst_sz; > buffers = calloc(buff_count, sizeof(pfring_zc_pkt_buff *)); > for (i = 0; i < buff_count; i++) { > buffers[i] = pfring_zc_get_packet_handle(zc); > > // step 4: each thread has an 'id' [0....n). > // each thread needs enough space to capture 'burst_sz' packets > // 'id * burst_sz' gives me the location of a thread's space within the buffer > pfring_zc_pkt_buff *pkts = buffers[id * burst_sz] > > // step 5: grab some packets from the wire > num_pkts = pfring_zc_recv_pkt_burst(..., &pkts, burst_sz, ...); > > Here is a snippet of what I get out of GDB. I don't have a copy of PF_RING > with symbols, so this may not be very useful. > > (gdb) bt full > #0 0x00000000004187fd in __pfring_zc_spsc_recv_pkt_burst () > ... > > Many Thanks! Hopefully I am just doing something stupid with buffer. > > > > -- > Nick Allen <[email protected] <mailto:[email protected]>> > _______________________________________________ > Ntop-misc mailing list > [email protected] > http://listgateway.unipi.it/mailman/listinfo/ntop-misc
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Ntop-misc mailing list [email protected] http://listgateway.unipi.it/mailman/listinfo/ntop-misc
