From: Jesse Peng <jesse@deansoft.com.tw>
To: Harald Welte <laforge@netfilter.org>,
netfilter <netfilter-devel@lists.netfilter.org>
Subject: Re: again!!! the 3rd time, why we need find_appopriate_src? rether than just check in_range?
Date: Mon, 08 Dec 2003 16:37:13 +0800 [thread overview]
Message-ID: <3FD43839.7080502@deansoft.com.tw> (raw)
In-Reply-To: 20031204115945.GE7680@obroa-skai.de.gnumonks.org
[-- Attachment #1: Type: text/plain, Size: 4132 bytes --]
First, very thanx for the reply, it just looks like a dry land finally
meet some sweet rain drops. But execuse me for the still bother, it
still remains some unclearing parts.
Harald Welte wrote:
>On Thu, Dec 04, 2003 at 12:42:14PM +0800, Jesse Peng wrote:
>
>
>>According to above, this circumstance only limited at POST_ROUTING hook,
>>then the question is as follow:
>>
>>1.Since ip_nat_fn is called both during PREROUTING and POSTROUTING hook,
>>then we've sure while a new packet passing PREROUTING, the ip_nat_fn
>>have called ip_nat_rule_find, then the ip_nat_rule_find graranting that
>>even no rule found the output tuple will be unique(through the
>>compensation by allocate_null_biding).
>>2.While during POSTROUTE, the input tuple: orig_tuple to
>>get_unique_tuple is right one the output tuple above mentioned, so it is
>>still unique!!
>>3.Then why can't we just check if the src of the orig_tuple "in range"
>>the mr. If it is, then all we need to do is to set the
>>*tuple=*orig_tuple, and return 1.
>>
>>
>
>so what about the cases where we have packets originated by the local
>machine? They will appear via ip_nat_local_fn() -> ip_nat_fn() ->
>ip_nat_rule_find() attached to LOCAL_OUT only if CONFIG_IP_NF_NAT_LOCAL
>is defined.
>
>If not, the packet is actually only seen at POST_ROUTING, and we still
>have to make sure the tuple is unique.
>
1.If the above is true, so the purpose of hash_by_src is only designed
for local generated packets on the condition with the
CONFIG_IP_NF_NAT_LOCAL not set? and even that, it will mean so far while
POSTROUTING the nat info not initialized yet, then how can it be
currently mapped in the hash_by_src hash? as according to the comment:
/* 1) If this srcip/proto/src-proto-part is currently mapped,
and that same mapping gives a unique tuple within the given
range, use that.
2.I really want to realize why hash_by_src, because it's very hard to
understand the way it prove the uniquity.
3.As you can notice, the partial source I pasted included a line
offered by Rusty for fix at NOV. 4, for the convenient, I paste here
again as below:
if (hooknum == NF_IP_POST_ROUTING) {
struct ip_conntrack_manip *manip;
manip = find_appropriate_src(orig_tuple, mr);
if (manip) {
/* Apply same source manipulation. */
*tuple = ((struct ip_conntrack_tuple)
{ *manip, orig_tuple->dst });
DEBUGP("get_unique_tuple: Found current src map\n");
if (!ip_nat_used_tuple(tuple, conntrack))
<------------------------------here it is
return 1;
}
and the comment offered by Rusty as below:
ChangeSet@1.497.3182.19 <mailto:ChangeSet@1.497.3182.19>, 2003-11-04 11:32:55-08:00, rusty@rustcorp.com.au <mailto:rusty@rustcorp.com.au>
[NETFILTER]: get_unique_tuple doesn't always return unique tuple.
get_unique_tuple doesn't check that the tuple is unique if it finds
a hash_by_src match.
Now I think maybe Rusty's concern is about smp racing,but since even
hash_by_src also need to face the race, then after some cost effecience
consider, should'nt the now code look like below?
if (hooknum == NF_IP_POST_ROUTING) {
/*replace the more cost find_appropriate_src* with simple
in_range*/
if ( in_range(orig_tuple, &orig_tuple->src, mr)) {
/* Apply same source manipulation. */
*tuple = *orig_tuple;
DEBUGP("get_unique_tuple: Found current src map\n");
/*We still have this below protection*/
if (!ip_nat_used_tuple(tuple, conntrack))
return 1;
}
>
>
>>Because this remaining disunderstanding fool me so long and almost
>>destroy my life!!
>>
>>
>
>it almost destroys yor life? Is your employer going to fire you if you
>don't understand netfilter code, or what ;) ?
>
>
hm..Not exactly that!, Just because some projects potentially risk some
on those complicated. So it's essential to have a good learning on it
unless I really dare someday being kicked off from my office ;) !
>
>
>>Your Sincerely
>>
>>
>
>
>
[-- Attachment #2: Type: text/html, Size: 6206 bytes --]
prev parent reply other threads:[~2003-12-08 8:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-04 4:42 again!!! the 3rd time, why we need find_appopriate_src? rether than just check in_range? Jesse Peng
2003-12-04 11:59 ` Harald Welte
2003-12-08 8:37 ` Jesse Peng [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=3FD43839.7080502@deansoft.com.tw \
--to=jesse@deansoft.com.tw \
--cc=laforge@netfilter.org \
--cc=netfilter-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.