[Click] Help with Click HashMap

Eddie Kohler kohler at cs.ucla.edu
Tue Apr 4 11:24:57 EDT 2006


Swati,

Here is a problem

> Inline Packet * PktHandler::smaction (Packet *p_in)
> {
>  _pkt_map.insert(_pktid, p);
>   .....................
>   return p;
> }

When you push() a packet onwards, return a packet from pull(), or  
return a packet from simple_action(), at that moment YOU LOSE CONTROL  
OF THAT PACKET.  The downstream elements may destroy that packet or  
modify it in arbitrary ways.  If you want to keep a copy of the  
packet as well, you must clone() it, and keep one clone while  
forwarding on the other.

   _pkt_map.insert(_pktid, p->clone());
    ....
   return p;

Either that or return 0.


Eddie



>
> void PktHandler::callback(uint32_t pktid_, int token_)
> {
>     WritablePacket *p =  _pkt_map.find(pktid_);
>     //here I am not able to read the packet p.
>     .....................
> }
>
> regards,
> Swati
>
>
>
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click



More information about the click mailing list