From: "Bora �ahin" <borasahin@netone.com.tr>
To: netfilter@lists.netfilter.org
Subject: Re[2]: Could someone tell me the rules of port translation in SNAT ?
Date: Sun, 11 Jan 2004 15:38:25 +0200 [thread overview]
Message-ID: <306391720.20040111153825@netone.com.tr> (raw)
In-Reply-To: <BAY10-F966xG0eYfJcy0003d929@hotmail.com>
Hi ding,
Thursday, January 8, 2004, 3:55:56 AM, you wrote:
dd> I'm reading some source code for more details, bu i stopped at
dd> return NF_HOOK(PF_INET, NF_IP_POST_ROUTING, skb, NULL,
dd> dev,ip_finish_output2);
dd> in ip_output.c::ip_finish_output()
dd> cause i don't know what part of code does POST_ROUTING work and SNAT
dd> implementation.
I think you are wrong place both in the point of list and code. NF_HOOK is macro which is defined in
include/linux/netfilter.h like this:
#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) \
(list_empty(&nf_hooks[(pf)][(hook)]) \
? (okfn)(skb) \
: nf_hook_slow((pf), (hook), (skb), (indev), (outdev), (okfn)))
Simply, It calls all registered functions in NF_IP_POST_ROUTING per protocol, in this case IPv4, and
then gives control to ip_finish_output2(). So If you are interested in SNAT, you should take a look
at net/ipv4/netfilter/ip_nat_standalone.c:
/* After packet filtering, change source */
static struct nf_hook_ops ip_nat_out_ops
= { { NULL, NULL }, ip_nat_out, PF_INET, NF_IP_POST_ROUTING, NF_IP_PRI_NAT_SRC};
...
nf_register_hook(&ip_nat_out_ops);
...
then above in the same file:
static unsigned int ip_nat_out()
{
...
return ip_nat_fn(hooknum, pskb, in, out, okfn);
}
That is, you should track down this path...
--
Bora Sahin
borasahin.port5.com
prev parent reply other threads:[~2004-01-11 13:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-08 1:55 Could someone tell me the rules of port translation in SNAT ? ding dang
2004-01-11 13:38 ` Bora �ahin [this message]
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=306391720.20040111153825@netone.com.tr \
--to=borasahin@netone.com.tr \
--cc=netfilter@lists.netfilter.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