Hi Ivan
yes slaves should be aware of the interface index or name (in this case you 
should use pfring_get_device_ifindex)

Alfredo 

On Aug 6, 2013, at 9:13 AM, Ivan Nardi <[email protected]> wrote:

> Hi Alfredo
> I tried your suggestions and they work fine!
> I have another question.
> Is it possible to know master interfaces indexes (i.e. indexes of dna0 and 
> dna1, for example) from a "slave" handle?
> In the pfdnacluster_multithread and pfdnabounce examples, these indexes are 
> saved from the master thread into global variables and so the slaves threads 
> are able to read them.
> In our test-case, master and slaves are different processes: how are the 
> slaves able to know the indexes to use in the pfring_set_pkt_buff_ifindex() 
> calls? Must they have a reference to interface names and use something like 
> if_nametoindex()?
> 
> Thanks for your support!
> 
> Ivan
> 
> 
> On 5 August 2013 13:58, Alfredo Cardigliano <[email protected]> wrote:
> 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
> 
> 
> _______________________________________________
> 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