[Click] Question about cooperating elementclasses

Philip Prindeville philipp_subx at redfish-solutions.com
Sat Feb 12 14:22:57 EST 2011


I wanted to make a change to ARPTable which would give it the ability to invoke a hook back to ARPQuerier when it deletes queued up packages, but wasn't sure if there's a clean way to do this.

In C, I'd just set a pointer to a callback function, but this isn't C.

So what's the best way to do it?  Keep in mind that the ARPTable might have been

Also, it's the case that the same ARPTable instance might be shared amongst several ARPQuerier instances (because we're in a multi-core environment with several threads running on the same NIC).

Oh, one other question about ARPTable vs. ARPQuerier interactions...  if I have that same situation where I'm running multithreaded, and a response packet gets delivered to one ARPQuerier, thereby updating the ARPTable... will the queued up packets in each instance of the ARPQueriers get updated and unblock the packets?

Or are the queued packets actually held by the ARPTable (and therefore in a single place)?

Looking at how ARPQuerier::handle_ip() and ARPQuerier::handle_response() interact, it looks like the packets are all held by the ARPTable, and when the queue gets drained, all drained by the same instance... so any affinity of individual packets to threads is lost.

Packet *cached_packet;
arpt->insert(ipa, ena,&cached_packet);

while (cached_packet) {
     Packet *next = cached_packet->next();
     handle_ip(cached_packet, true);
     cached_packet = next;
}


Correct?

Thanks.

-Philip



More information about the click mailing list