* change ip address in the hook
@ 2004-03-28 21:57 lmn
2004-03-30 5:13 ` Emmanuel Guiton
0 siblings, 1 reply; 4+ messages in thread
From: lmn @ 2004-03-28 21:57 UTC (permalink / raw)
To: netfilter-devel
Hi,
For example, I want to change the ip address of a packet in the LOCAL_OUT hook and let it send out, but I didn't see the packet on the wire. (Route for the modified ip addresses existed.) Similar things happen for the PRE_ROUTING hook. This is like doing the NAT manually.
If I use iptables command to add a rule doing the similar function, I can see the packet was sent out. So what is the difference inside these two approaches?
Thanks,
LMN
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: change ip address in the hook
2004-03-28 21:57 change ip address in the hook lmn
@ 2004-03-30 5:13 ` Emmanuel Guiton
2004-03-31 0:08 ` lmn
0 siblings, 1 reply; 4+ messages in thread
From: Emmanuel Guiton @ 2004-03-30 5:13 UTC (permalink / raw)
To: lmn; +Cc: netfilter-devel
Hi!
Can you be a bit more precise in what you do when you "change the ip
address of a packet in the LOCAL_OUT hook and let it send out"? What are
all the operations you do? Which address (source / destination) do you
change? Do you calculate a new IP checksum after having changed the IP
address?
Emmanuel
lmn@mail.xprtsol.com wrote:
>Hi,
>
>For example, I want to change the ip address of a packet in the LOCAL_OUT hook and let it send out, but I didn't see the packet on the wire. (Route for the modified ip addresses existed.) Similar things happen for the PRE_ROUTING hook. This is like doing the NAT manually.
>
>If I use iptables command to add a rule doing the similar function, I can see the packet was sent out. So what is the difference inside these two approaches?
>
>Thanks,
>
>LMN
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: change ip address in the hook
2004-03-30 5:13 ` Emmanuel Guiton
@ 2004-03-31 0:08 ` lmn
2004-03-31 5:16 ` Emmanuel Guiton
0 siblings, 1 reply; 4+ messages in thread
From: lmn @ 2004-03-31 0:08 UTC (permalink / raw)
To: Emmanuel Guiton; +Cc: netfilter-devel
Hello,
Thanks so much. I just found out the reason may be that I didn't do IP checksum after I changed the source IP in the LOCAL_OUT hook. Is the ip_fast_csum() good to use here? Also I want to change the destination IP of an incoming packet in PRE_ROUTING hook, do I need to calculate the checksum at this point again?
I read the ipt_MIRROR.c and didn't see IP checksum there. Maybe it just exchanges source IP with destination IP, and the checksum algorithm will get the same result.
Regards,
LMN
On Tue, Mar 30, 2004 at 08:13:53AM +0300, Emmanuel Guiton wrote:
>
> Hi!
>
> Can you be a bit more precise in what you do when you "change the ip
> address of a packet in the LOCAL_OUT hook and let it send out"? What are
> all the operations you do? Which address (source / destination) do you
> change? Do you calculate a new IP checksum after having changed the IP
> address?
>
> Emmanuel
>
>
> lmn@mail.xprtsol.com wrote:
>
> >Hi,
> >
> >For example, I want to change the ip address of a packet in the LOCAL_OUT
> >hook and let it send out, but I didn't see the packet on the wire. (Route
> >for the modified ip addresses existed.) Similar things happen for the
> >PRE_ROUTING hook. This is like doing the NAT manually.
> >
> >If I use iptables command to add a rule doing the similar function, I can
> >see the packet was sent out. So what is the difference inside these two
> >approaches?
> >
> >Thanks,
> >
> >LMN
> >
> >
> >
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: change ip address in the hook
2004-03-31 0:08 ` lmn
@ 2004-03-31 5:16 ` Emmanuel Guiton
0 siblings, 0 replies; 4+ messages in thread
From: Emmanuel Guiton @ 2004-03-31 5:16 UTC (permalink / raw)
To: lmn; +Cc: netfilter-devel
Hi!
I think you can use ip_fast_csum() (I use it for similar purpose),
however a faster function may exist.
Each time you change an IP field the checksum has to be calculated
again. The IP checksum covers every field in the IP header, including
the ones that will surely change (like TTL).
I looked briefly at the ipt_MIRROR.c target and I guess it does not need
to calculate a new checksum as it does not change. The IP addresses are
just inverted, so it is still the same data which is covered by the
checksum.
Emanuel
lmn@mail.xprtsol.com wrote:
>Hello,
>
>Thanks so much. I just found out the reason may be that I didn't do IP checksum after I changed the source IP in the LOCAL_OUT hook. Is the ip_fast_csum() good to use here? Also I want to change the destination IP of an incoming packet in PRE_ROUTING hook, do I need to calculate the checksum at this point again?
>
>I read the ipt_MIRROR.c and didn't see IP checksum there. Maybe it just exchanges source IP with destination IP, and the checksum algorithm will get the same result.
>
>Regards,
>
>LMN
>
>On Tue, Mar 30, 2004 at 08:13:53AM +0300, Emmanuel Guiton wrote:
>
>
>>Hi!
>>
>>Can you be a bit more precise in what you do when you "change the ip
>>address of a packet in the LOCAL_OUT hook and let it send out"? What are
>>all the operations you do? Which address (source / destination) do you
>>change? Do you calculate a new IP checksum after having changed the IP
>>address?
>>
>> Emmanuel
>>
>>
>>lmn@mail.xprtsol.com wrote:
>>
>>
>>
>>>Hi,
>>>
>>>For example, I want to change the ip address of a packet in the LOCAL_OUT
>>>hook and let it send out, but I didn't see the packet on the wire. (Route
>>>for the modified ip addresses existed.) Similar things happen for the
>>>PRE_ROUTING hook. This is like doing the NAT manually.
>>>
>>>If I use iptables command to add a rule doing the similar function, I can
>>>see the packet was sent out. So what is the difference inside these two
>>>approaches?
>>>
>>>Thanks,
>>>
>>>LMN
>>>
>>>
>>>
>>>
>>>
>>
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-03-31 5:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-28 21:57 change ip address in the hook lmn
2004-03-30 5:13 ` Emmanuel Guiton
2004-03-31 0:08 ` lmn
2004-03-31 5:16 ` Emmanuel Guiton
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.