Changing packet data
Hello,
I'm trying to develop match which is able to change packet data according to perl regular expression, s/.../.../. Finding match is very easy. But I'm stuck in replacing it. One thing that bothers me it's how to resize packet (replacement can be shorter or taller than match) in match() function. I'm only beginner in <skbuff.h> functions, which should I use? And whether this is possible to do it in match (not in TARGET).
Signature · 4 lines
Piotr 'QuakeR' Gasidło, BOFH @ pandora.barbara.eu.org ############## sending lusers to /dev/null since 1998 ##### Waiting for tomorrow, for a little ray of light ### Waiting for tomorrow just to see your smile again
Quoted 5 lines · On Sat, 17 Apr 2004, Piotr [iso-8859-2] Gasid³o wrote:
I'm trying to develop match which is able to change packet data according to perl regular expression, s/.../.../. Finding match is very easy. But I'm stuck in replacing it. One thing that bothers me it's how to resize packet (replacement can be shorter or taller than match) in
match()function.
Unless you are doing this in the context of NAT you can only resize UDP (and other datagram protocols), not TCP. For TCP you need to have the sequence numbers adjusted for all future of the connection if you modify the size of the payload and this function is only available in iptables/netfilter if NAT is enabled.
In NAT this type of manipulation is done in the form of a NAT helper. There the framework is already fully in place for doing this kind of things.
Maybe it works using the same framework elsewhere in iptables. See the FTP NAT helper for some samples and give it a try. Do not forget locking.
Regards
Henrik
RE: Changing packet data {Virus Scanned}
Henrik,
Sounds interesting, do you think the function exported
Quoted 1 line
From
ip_NAT_helper.cip_nat_mangle_tcp_packetcan be directly used
To achieve this?
Thanks
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Henrik Nordstrom
Sent: Sunday, April 18, 2004 4:59 AM
To: Piotr Gasidło
Cc: [email protected]
Subject: Re: Changing packet data {Virus Scanned}
Quoted 5 lines · On Sat, 17 Apr 2004, Piotr [iso-8859-2] Gasid³o wrote:
I'm trying to develop match which is able to change packet data according to perl regular expression, s/.../.../. Finding match is very easy. But I'm stuck in replacing it. One thing that bothers me it's how to resize packet (replacement can be shorter or taller than match) in
match()function.
Unless you are doing this in the context of NAT you can only resize UDP (and other datagram protocols), not TCP. For TCP you need to have the sequence numbers adjusted for all future of the connection if you modify the size of the payload and this function is only available in iptables/netfilter if NAT is enabled.
In NAT this type of manipulation is done in the form of a NAT helper. There the framework is already fully in place for doing this kind of things.
Maybe it works using the same framework elsewhere in iptables. See the FTP NAT helper for some samples and give it a try. Do not forget locking.
Regards
Henrik
RE: Changing packet data {Virus Scanned}
Quoted 3 lines · Qiang
Sounds interesting, do you think the function exported From
ip_NAT_helper.cip_nat_mangle_tcp_packetcan be directly used To achieve this?
Maybe, and is why I mentioned it.
It is not intended to be used outside of NAT helpers, but maybe it works if done carefully. And again, don't forget the proper locking.
Regards
Henrik
RE: Changing packet data {Virus Scanned}
In reply to Piotr GasidłoPiotr,
I found it is do-able in MATCH if you are not enlarging the packet, if resizing it to larger packet, you probably have to swap it to a new SKB buffer, which is not do-able from MATCH, can only be done via TARGET
Q
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Piotr Gasidlo
Sent: Saturday, April 17, 2004 8:33 AM
To: [email protected]
Subject: Changing packet data {Virus Scanned}
Hello,
I'm trying to develop match which is able to change packet data according to perl regular expression, s/.../.../. Finding match is very easy. But I'm stuck in replacing it. One thing that bothers me it's how to resize packet (replacement can be shorter or taller than match) in match() function. I'm only beginner in <skbuff.h> functions, which should I use? And whether this is possible to do it in match (not in TARGET).
Signature · 4 lines
Piotr 'QuakeR' Gasidło, BOFH @ pandora.barbara.eu.org ############## sending lusers to /dev/null since 1998 ##### Waiting for tomorrow, for a little ray of light ### Waiting for tomorrow just to see your smile again
Enlarge packet size in target & fragmentation {Virus Scanned}
If I enlarge a skb in a target at prerouting (after conntrack), when the modified packet exceeds the size of MTU, the packet is lost, but it is fine when packet size is smaller, any ideas? Conntrack should have taken care of the fragmentation?
Q