netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Subhadeep Ghosh <subhadeep.ghosh@uniken.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter@vger.kernel.org
Subject: Re: Reg: Replacing sk_buff in a NetFilter hook
Date: Fri, 16 Apr 2010 16:31:10 +0530	[thread overview]
Message-ID: <t2w3a8740fd1004160401j3d39896bk70e20165fc721981@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.2.01.1004161245440.11880@obet.zrqbmnf.qr>

Hello Jan,

Thank you for your reply. Yes, I am aware of what NF_DROP and
NF_STOLEN mean. My question was, is it possible for me to replace the
original sk_buff with the new sk_buff which I created, in the sk_buff
processing queue?

For example in the earlier NetFilter hook implementations, the
signature of a hook function was,

unsigned int nf_hookfn(unsigned int hooknum,
                                  struct sk_buff** skb,
                                  const struct net_device* in,
                                  const struct net_device* out,
                                  int (*okfn)(struct sk_buff*));

While in the current implementations, it has been changed to,

unsigned int nf_hookfn(unsigned int hooknum,
                                  struct sk_buff* skb,
                                  const struct net_device* in,
                                  const struct net_device* out,
                                  int (*okfn)(struct sk_buff*));

The only difference between the two implementations is sk_buff** has
been changed to sk_buff*. So, in the earlier versions if *skb was
assigned with the address of the newly created sk_buff and marked the
original sk_buff as NF_STOLEN and then did a kfree_skb on it, then it
would work. However, in the current implementations a hook developer
is not allowed to change the sk_buff pointer which NetFilter sends to
the hook functions. And that is what I wanted to do.

Thank you and regards,
Subhadeep Ghosh.

On Fri, Apr 16, 2010 at 4:18 PM, Jan Engelhardt <jengelh@medozas.de> wrote:
>
> On Friday 2010-04-16 12:37, Subhadeep Ghosh wrote:
>>
>>The first and the second steps are no-brainers. However, I don't know
>>if I need to drop the original packet or mark it as stolen. And I
>>definitely don't know how to resolve the fourth point. It would be
>>great if anyone could point me in the right direction.
>
> NF_DROP will cause netfilter to free it when the hooks are
> done; with NF_STOLEN, you have ownership of the skb and
> need to free it yourself.
>

  reply	other threads:[~2010-04-16 11:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16 10:37 Reg: Replacing sk_buff in a NetFilter hook Subhadeep Ghosh
2010-04-16 10:48 ` Jan Engelhardt
2010-04-16 11:01   ` Subhadeep Ghosh [this message]
2010-04-16 12:12     ` Jan Engelhardt
2010-04-16 12:55       ` Subhadeep Ghosh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=t2w3a8740fd1004160401j3d39896bk70e20165fc721981@mail.gmail.com \
    --to=subhadeep.ghosh@uniken.com \
    --cc=jengelh@medozas.de \
    --cc=netfilter@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).