No, you can't use the same pfring "slave" handle in different threads at the 
same time.

Alfredo

On Aug 5, 2013, at 1:55 PM, Ivan Nardi <[email protected]> wrote:

> Hi Alfredo,
> 
> Thanks for your fast replay!
> I'll have a look at it, thanks!
> 
> Another question: are these functions "thread safe", i.e. can I send my pkts 
> from another thread respect the thread reading from the cluster?
> Best Regards
> 
> Ivan
> 
> 
> On 5 August 2013 13:09, Alfredo Cardigliano <[email protected]> wrote:
> Hi Ivan
> you should reserve per-slave buffers (see the 3rd parameter of 
> dna_cluster_low_level_settings()) for allocation via pfring_alloc_pkt_buff().
> Your code should look like this:
> 
> tmp_pkt_handle = pfring_alloc_pkt_buff(ring[slave_id])
> 
> while (1) {
>     pfring_recv_pkt_buff(pd, pkt_handle, ...);
>     /* analyze pkt */
>     pfring_set_pkt_buff_ifindex(ring[slave_id], pkt_handle, out_index);
>     pfring_send_pkt_buff(ring[slave_id], pkt_handle,...);
> 
>     if (condition) {
>         buffer = pfring_get_pkt_buff_data(ring[slave_id], tmp_pkt_handle);
>         create_new_pkt(buffer);
>         pfring_set_pkt_buff_ifindex(ring[slave_id], tmp_pkt_handle, 
> out_index);
>         pfring_send_pkt_buff(ring[slave_id], tmp_pkt_handle,...);
>     }
> }
> 
> Best Regards
> Alfredo
> 
> On Aug 5, 2013, at 12:56 PM, Ivan Nardi <[email protected]> wrote:
> 
>> Hi guys.
>> 
>> We are using libzero with dna-cluster to analyze and forwarding|bouncing 
>> packets.
>> We would like to send through the cluster some packets created by ourselves 
>> too, other than the captured ones.
>> Something like that (in pseudo-code):
>> 
>> while (1) {
>>     pfring_recv_pkt_buff(pd, pkt_handle, ...);
>>     /* analyze pkt */
>>     pfring_set_pkt_buff_ifindex(pd, pkt_handle, out_index);
>>     pfring_send_pkt_buff(pd, pkt_handle,...);
>> 
>>     if (condition) {
>>         data = create_new_pkt(...);
>>         send_data_through_cluster(pd, data, out_index2)
>>     }
>> }
>> 
>> Which is the best way to do it?
>> Can we use the standard function pfring_send_ifindex() even with cluster? Is 
>> there a better way?
>> Thanks in advance!
>> 
>> Ivan
>> _______________________________________________
>> Ntop-dev mailing list
>> [email protected]
>> http://listgateway.unipi.it/mailman/listinfo/ntop-dev
> 
> 
> _______________________________________________
> Ntop-dev mailing list
> [email protected]
> http://listgateway.unipi.it/mailman/listinfo/ntop-dev
> 
> 
> _______________________________________________
> Ntop-dev mailing list
> [email protected]
> http://listgateway.unipi.it/mailman/listinfo/ntop-dev

_______________________________________________
Ntop-dev mailing list
[email protected]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

Reply via email to