How callback functions work
masterA callback is any one-argument callable invoked with a Packet object.
Key Lifecycle Rules:
- Payload Persistence: If you need to access the packet payload after the callback function has returned, you must call
Packet.retain()within the callback. Otherwise,get_payload()will raise an exception. - Queue Management: You can hold onto
Packetobjects and resolve them later, but they continue to count against themax_lenlimit of the queue until a verdict (accept(),drop(), orrepeat()) is issued. - Performance: The kernel stores enqueued packets in a linked list. Keeping a large number of packets outstanding can adversely impact system performance.