Does netfilter fragments packect exceeding MTU
Hi
i'm trying to find out what i've said on topic. I've taken a look at this
mail:
http://lists.netfilter.org/pipermail/netfilter/2000-August/004878.html
So i think that if you pass a packet to POSTROUTING taht exceeds MTU, netfilter will try to send it anyway right? Because you have to fragment before, 'cos netfilter doesn't expect a packet exceeding MTU right? But that fragmentation how could be done? I've seen in the above mail some C-code building a fragmentation module for doing this, but it's not included in the official kernel tree?
Another question: in this mail i've not understood if fragmentation is done by such module or by a /proc entry; the mail it's quite old, so what's the situation actually?
thanks for any RTFM or help :)
Regards
Signature · 10 lines
Debian Powered GNU/Linux User #373118 Bedogni Luca - Blog | http://blog.lucabedogni.it Site | http://www.lucabedogni.it Debianizzati - www.debianizzati.org | Founder Member -- Token Ring, n.: a local area network architecture, perhaps a future replacement for SNA. Not to be confused with the Tolkien Ring, although the purposes are similar: "One Ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them, in a LAN with more nodes where the stations lie."
Hello,
Quoted 2 lines · Luca Bedogni
So i think that if you pass a packet to POSTROUTING taht exceeds MTU, netfilter will try to send it anyway right? Because you have to fragment before, 'cos netfilter doesn't expect a packet exceeding MTU right? But that fragmentation how could be done?
Netfilter does not send packets : it just drops them, mangles them or lets them through.
Disclaimer : I observed the following in the 2.4.18 kernel and cannot assert whether it is still true for 2.6 kernels with ip_conntrack or nf_conntrack or even for recent 2.4 kernels.
If needed (packet size > output path MTU), the IP stacks fragments :
- locally generated packets before the NF_IP_LOCAL_OUT Netfilter hook (where the iptables OUTPUT chains are located) ;
- forwarded packets after the NF_IP_FORWARD Netfilter hook (where the iptables FORWARD chains are located).
BUT, when the ip_conntrack module is loaded (or built-in), which is needed for connection tracking and stateful NAT operation, it can perform an extra fragmentation in the NF_IP_POST_ROUTING Netfilter hook after the POSTROUTING iptables chains. The reason is ip_conntrack needs to reassemble packets first in the NF_IP_LOCAL_OUT Netfilter hook before the OUTPUT iptables chains.
You can see all this (and more) in the following diagram :
http://www.plouf.fr.eu.org/bazar/netfilter/schema_netfilter.txt
So, if you generate a packet of the maximum size for an interface, use advanced routing to reroute it to another interface with a smaller MTU and ip_conntrack is not present, the packet will not be fragmented. It will just be forwarded to the network device driver "as is".
Quoted 10 lines · Pascal Hambourg
Hello,
Quoted 4 lines · Luca Bedogni
So i think that if you pass a packet to POSTROUTING taht exceeds MTU, netfilter will try to send it anyway right? Because you have to fragment before, 'cos netfilter doesn't expect a packet exceeding MTU right? But that fragmentation how could be done?
Netfilter does not send packets : it just drops them, mangles them or lets them through.
Yes I know that, sorry for my misspelling.
Quoted 17 lines
Disclaimer : I observed the following in the 2.4.18 kernel and cannot assert whether it is still true for 2.6 kernels with
ip_conntrackornf_conntrackor even for recent 2.4 kernels.If needed (packet size > output path MTU), the IP stacks fragments :
- locally generated packets before theNF_IP_LOCAL_OUTNetfilter hook (where the iptables OUTPUT chains are located) ;
- forwarded packets after theNF_IP_FORWARDNetfilter hook (where the iptables FORWARD chains are located).BUT, when the
ip_conntrackmodule is loaded (or built-in), which is needed for connection tracking and stateful NAT operation, it can perform an extra fragmentation in theNF_IP_POST_ROUTINGNetfilter hook after the POSTROUTING iptables chains. The reason isip_conntrackneeds to reassemble packets first in theNF_IP_LOCAL_OUTNetfilter hook before the OUTPUT iptables chains.
Quoted 7 lines
You can see all this (and more) in the following diagram :
http://www.plouf.fr.eu.org/bazar/netfilter/schema_netfilter.txtSo, if you generate a packet of the maximum size for an interface, use advanced routing to reroute it to another interface with a smaller MTU and
ip_conntrackis not present, the packet will not be fragmented. It will just be forwarded to the network device driver "as is".
So in fact netfilter, if ip_conntrack is loaded, fragments packet if they exceeds MTU for such interface, and do this after POSTROUTING.
I know we're speaking about kernel 2.4.18, but i think it would be interesting discover what's going on in 2.6.x kernel, if that has changed or not. I'll try do find this out, thank you for your infos :)
Regards
Signature · 6 lines
Debian Powered GNU/Linux User #373118 Bedogni Luca - Blog | http://blog.lucabedogni.it Site | http://www.lucabedogni.it Debianizzati - www.debianizzati.org | Founder Member -- Book: A non-volatile information storage medium.