Networking Forums

Networking Forums > Computer Networking > Linux Networking > Userspace packet queuing with libipq: ip_conntrack does not defragment?

Reply
Thread Tools Display Modes

Userspace packet queuing with libipq: ip_conntrack does not defragment?

 
 
Daneel
Guest
Posts: n/a

 
      05-09-2007, 04:10 PM
Hi all,

I'm using libipq to pass certain packets to my userspace application
on Fedora 6 / Kernel 2.6.21.1 and ipTables 1.3.5.

I do:
modprobe iptable_filter
modprobe ip_queue
modprobe ip_conntrack
iptables -A INPUT -p tcp -j QUEUE

Works fine. However, since ip_conntrack is loaded I would expect that
the packets are defragmented before they are passed to my userspace
appliation (as indicated here for example:
http://lists.netfilter.org/pipermail...y/034006.html).
This does not seem the case, i.e., the maximum size of the packets
which I get (through ->data_len) is 1500 bits.

The len parameter of the ipq_read method is well over 1500, as is the
buffer size.

Any suggestions what I'm doing wrong?

Many thanks,
Michael

ps: I also tried to use "OUTPUT" in my rule since I read somewhere
that connection tracking only works in OUTPUT and PREROUTING: Same
result - maximum packet size is 1500, i.e., no defragmentation :-(

 
Reply With Quote
 
 
 
 
Daneel
Guest
Posts: n/a

 
      05-09-2007, 06:39 PM
Hi again,

I would like to use an example to clarify what I want to achieve:

Let's say I'm downloading a video from a website (over HTTP/TCP/IP).
What I see is that each picture of the video is send as a single TCP/
IP packet (?) - usually with a size of around 10 KB. This TCP/IP
packet is fragmented according to the MTU and therefore I see the
following fragments on the wire:
Fragment 1: <Ethernet header><IP header><TCP header>application data
Fragment 2: <Ethernet header><IP header>application data
Fragment 3: <Ethernet header><IP header>application data
....

On my router/firewall I would like to inspect the video picture as a
whole. In my current (windows) application I have to reassemble the
fragments manually into the original TCP/IP packet. I hoped that
netfilter would make my life easier by performing the reassembling for
me (and potentially also the recalculation of the checksum(s) if the
video picture is changed).

Is there support in netfilter for this kind of stuff?

Many thanks again for your help,
Michael

 
Reply With Quote
 
Pascal Hambourg
Guest
Posts: n/a

 
      05-09-2007, 06:56 PM
Hello,

I do not know about packet queuing and will reply only about connection
tracking and packet reassembly.

Daneel a écrit :
>
> I'm using libipq to pass certain packets to my userspace application
> on Fedora 6 / Kernel 2.6.21.1 and ipTables 1.3.5.
>
> I do:
> modprobe iptable_filter
> modprobe ip_queue
> modprobe ip_conntrack
> iptables -A INPUT -p tcp -j QUEUE
>
> Works fine. However, since ip_conntrack is loaded I would expect that
> the packets are defragmented before they are passed to my userspace
> appliation


Yes, but actually you do not need connection tracking for that.
Reassembly occurs between the input routing decision and the INPUT
chains even without the connection tracking. So the INPUT chains always
see complete datagrams.

> (as indicated here for example:
> http://lists.netfilter.org/pipermail...y/034006.html).


Err.. your URL is incomplete.

> This does not seem the case, i.e., the maximum size of the packets
> which I get (through ->data_len) is 1500 bits.


Did you send fragmented datagrams with a size > 1500 bytes ?

> ps: I also tried to use "OUTPUT" in my rule since I read somewhere
> that connection tracking only works in OUTPUT and PREROUTING: Same
> result - maximum packet size is 1500, i.e., no defragmentation :-(


Same question, did you send datagrams with a size > 1500 bytes ?

Notes :
1) Connection tracking does not *work* in OUTPUT and PREROUTING ; it
*takes places* there. Actually it is the packet classification, which is
one part of the connection tracking process, which occurs before the
PREROUTING and OUTPUT chains of the 'mangle' table (but after the
PREROUTING and OUTPUT chains of the 'raw' table). Fragment reassembly is
required for proper connection tracking operation, so it is performed
just before packet classification.

2) In recent 2.6 kernels at least, including 2.6.21, fragmentation of
locally generated packets occurs - if needed - only after the OUTPUT
chains, so these chains do not see fragmentation even without the
connection tracking.
 
Reply With Quote
 
Pascal Hambourg
Guest
Posts: n/a

 
      05-09-2007, 07:07 PM
Daneel a écrit :
>
> Let's say I'm downloading a video from a website (over HTTP/TCP/IP).
> What I see is that each picture of the video is send as a single TCP/
> IP packet (?) - usually with a size of around 10 KB. This TCP/IP
> packet is fragmented according to the MTU and therefore I see the
> following fragments on the wire:
> Fragment 1: <Ethernet header><IP header><TCP header>application data
> Fragment 2: <Ethernet header><IP header>application data
> Fragment 3: <Ethernet header><IP header>application data


This sounds highly unusual. Usually TCP connections limit the MSS
(maximum segment size) according to the MTU size in order to avoid IP
fragmentation.
 
Reply With Quote
 
Daneel
Guest
Posts: n/a

 
      05-09-2007, 07:21 PM
On May 9, 9:07 pm, Pascal Hambourg <boite-a-s...@plouf.fr.eu.org>
wrote:
> Daneel a écrit :
>
>
>
> > Let's say I'm downloading a video from a website (over HTTP/TCP/IP).
> > What I see is that each picture of the video is send as a single TCP/
> > IP packet (?) - usually with a size of around 10 KB. This TCP/IP
> > packet is fragmented according to the MTU and therefore I see the
> > following fragments on the wire:
> > Fragment 1: <Ethernet header><IP header><TCP header>application data
> > Fragment 2: <Ethernet header><IP header>application data
> > Fragment 3: <Ethernet header><IP header>application data

>
> This sounds highly unusual. Usually TCP connections limit the MSS
> (maximum segment size) according to the MTU size in order to avoid IP
> fragmentation.


So what you say is that I should (!) only see:
<Ethernet header><IP header><TCP header>application data
without any
<Ethernet header><IP header>application data
in-between for a TCP stream (given a proper TCP/IP stack)?

Thanks,
Michael

 
Reply With Quote
 
Pascal Hambourg
Guest
Posts: n/a

 
      05-10-2007, 08:15 AM
Daneel a écrit :
>>
>>>Let's say I'm downloading a video from a website (over HTTP/TCP/IP).
>>>What I see is that each picture of the video is send as a single TCP/
>>>IP packet (?) - usually with a size of around 10 KB. This TCP/IP
>>>packet is fragmented according to the MTU and therefore I see the
>>>following fragments on the wire:

[...]
>>This sounds highly unusual. Usually TCP connections limit the MSS
>>(maximum segment size) according to the MTU size in order to avoid IP
>>fragmentation.

>
> So what you say is that I should (!) only see:
> <Ethernet header><IP header><TCP header>application data
> without any
> <Ethernet header><IP header>application data
> in-between for a TCP stream (given a proper TCP/IP stack)?


Indeed this is what I would expect to see, unless the path MTU is lower
than the interface MTU and the hosts do not use path MTU discovery
(PMTUd), thus causing fragmentation on some router along the path.
However I would not expect to see TCP segments bigger than the interface
MTU. But I am not a TCP/IP specialist at all, so my view of what
actually exists may be limited. Someone with better knowledge and/or
experience may correct me if I'm wrong.

Could you please provide a capture of the beginning of a connection,
showing at least the SYN packets with the MSS option and one ~10kB
segment ? This will not help you, but I'm curious. ;-)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
queuing pkts using nf_queue_handler in bridge (PF_BRIDGE) mode notworking in 2.6 kernel Ratnaraj Linux Networking 1 02-18-2009 10:30 AM
Query in Linux queuing discipline implementation Shri Linux Networking 1 04-25-2008 05:18 PM
How to use netfilter userspace logging ? Ashish Shukla आशीष शà¥à¤•à¥à¤² Linux Networking 0 12-02-2007 07:27 PM
queuing up processes spawned by xinetd Mark Harrison Linux Networking 1 11-17-2004 12:05 AM
C: won't defragment =?Utf-8?B?Qm9iYnkyOA==?= Windows Networking 1 10-07-2004 03:07 AM



1 2 3 4 5 6 7 8 9 10 11