filter intercepting downward headed packets

When my up filter receives a packet through rx_down() I usually simply
tx_down() the packet onto the next layer. In some cases though I want to
either discard the packet all together, or delay its transmission until some
later time.

If I want to discard the packet, should I call tx_done() on the packet, or
will simply returning from rx_down() cause io-net to notice that the
reference count indicates nobody is interested in the packet anymore,
allowing io-net to clean it up.

If I want to hang on to the packet for later transmission, do I need to
artificially increment the reference count of the packet before returning,
so that io-net won’t clean it up on me. Is this best done by calling
reg_tx_done() on the packet, and then later when I decide to send it, call
tx_down() and tx_done()?

Thanks,
Shaun

Shaun Jackman <sjackman@nospam.vortek.com> wrote:

When my up filter receives a packet through rx_down() I usually simply
tx_down() the packet onto the next layer. In some cases though I want to
either discard the packet all together, or delay its transmission until some
later time.

If I want to discard the packet, should I call tx_done() on the packet, or
will simply returning from rx_down() cause io-net to notice that the
reference count indicates nobody is interested in the packet anymore,
allowing io-net to clean it up.

My understanding is you should call “tx_done” yourself,
io-net won’t look at reference count until somebody called
tx_done.


If I want to hang on to the packet for later transmission, do I need to
artificially increment the reference count of the packet before returning,
so that io-net won’t clean it up on me. Is this best done by calling
reg_tx_done() on the packet, and then later when I decide to send it, call
tx_down() and tx_done()?

You don’t need to increment reference count but you sure have to
put it in a queue for later use.

-xtang

Shaun Jackman <sjackman@nospam.vortek.com> wrote:
: When my up filter receives a packet through rx_down() I usually simply
: tx_down() the packet onto the next layer. In some cases though I want to
: either discard the packet all together, or delay its transmission until some
: later time.

: If I want to discard the packet, should I call tx_done() on the packet, or
: will simply returning from rx_down() cause io-net to notice that the
: reference count indicates nobody is interested in the packet anymore,
: allowing io-net to clean it up.

You need to either pass it on, or call ion->tx_done().

: If I want to hang on to the packet for later transmission, do I need to
: artificially increment the reference count of the packet before returning,
: so that io-net won’t clean it up on me. Is this best done by calling
: reg_tx_done() on the packet, and then later when I decide to send it, call
: tx_down() and tx_done()?

The reference count is not looked at for packets headed down. You don’t
need to call reg_tx_done() unless you’ve modified the packet somehow
(eg added a buffer to front / end) and need to undo the operation. Basically,
just ion->tx_done() if you don’t pass it on.

-seanb