libipq + packet mangling + MTU
Hi!
I am currently working on a new target for netfilter which modifies packages and, as a side effect, may enlarge packets by some bytes. I have currently a working prototype in userspace using libipq. It already works quite fine, but suffers by one problem:
If the MTU of a device ist e.g. 1500 bytes, a packet may be enlarged to 1520 bytes. (just an example) the kernel drops such large packages, since they are larger than the MTU.
I read on some mails regarding a project calles SPS
(http://ds9a.nl/sps/) that the same thing would not occur in kernel space (as a real netfilter module), since the kernel would automatically fragment the packets correctly. Thus a packet of 1500 bytes would result in a packet of 1500 bytes and another of 20+ip-header-length. However, this will slow down the things massively.
Is there any sane way to get this fixed correctly?
I would like to see a second MTU-value attached to each network device which specifies a higher limit than the normal MTU. Packets which are larger than this second MTU get dropped, packets which are larger than the normal MTU but smaller than that special MTU are accepted. So that I would be able to set the normal mtu to 1480 and the effective MTU to 1500 and be happy this way. Is there anything like this available in the Linux kernel currently?
Can anyone suggest me a better fix for this problem?
Maybe there is a simple sysctl variable that may modify the packet size the kernel splits its TCP stream with?
Any suggestions?
Thanks,
Lennart
Signature · 3 lines
name { Lennart Poettering } mail { [email protected] }
icq { 11060553 } www { http://www.poettering.de/lennart/ }
loc { hamburg, germany } pgp { 0x1A015CC4 } hack { .phi. }-----BEGIN PGP SIGNED MESSAGE-----
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Lennart" == Lennart Poettering <[email protected]> writes:
Lennart> packet of 1500 bytes would result in a packet of 1500 bytes and Lennart> another of 20+ip-header-length. However, this will slow down the Lennart> things massively.
Lennart> Is there any sane way to get this fixed correctly?
Sane? No :-)
Seriously, see RFC2003 as well as the DF and PMTU sections of RFC2401
for some thoughts. Are you adding a new IP header? Or is something else happening?
You need to send an ICMP fragment needed to the sender of the packet.
Lennart> I would like to see a second MTU-value attached to each network Lennart> device which specifies a higher limit than the normal Lennart> MTU. Packets which are larger than this second MTU get dropped, Lennart> packets which are larger than the normal MTU but smaller than Lennart> that special MTU are accepted. So that I would be able to set Lennart> the normal mtu to 1480 and the effective MTU to 1500 and be Lennart> happy this way. Is there anything like this available in the Lennart> Linux kernel currently?
Yes, you can specify the MTU as part of a route, and as part of the
neighbour cache. The later gets created automatically, so might take some code to do what you want.
Lennart> Maybe there is a simple sysctl variable that may modify the Lennart> packet size the kernel splits its TCP stream with?
If you are strictly dealing with locally generated packets, then it should
be easier. A virtual interface is one way to deal with this, but is has other less desireable effects as well.
] ON HUMILITY: to err is human. To moo, bovine. | firewalls [ ] Michael Richardson, Sandelman Software Works, Ottawa, ON |net architect[ ] [email protected] http://www.sandelman.ottawa.on.ca/ |device driver[
] panic("Just another Debian GNU/Linux using, kernel hacking, security guy"); [ -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Finger me for keys
iQCVAwUBPZ3Uv4qHRg3pndX9AQH4jwQAqgbPxzjsEQUhuX+HRgX3x9gD9Pgsva6k cu3rUigm9o2jWv1M9U4BR3O5a3SZjyx70dJbVx5YFjrfKDOYxCevP44qK7rpFzy0 3NBzr0mlGccty5ji3YJzJYyqm48DqtC0zbYb1nVwcWik/zHABXVLmkmecZEzYSB5 IY9T82FPojA=
=DL34
-----END PGP SIGNATURE-----
Quoted 5 lines · Michael Richardson
Sane? No :-)
Seriously, see RFC2003 as well as the DF and PMTU sections of RFC2401
for some thoughts. Are you adding a new IP header? Or is something else happening?
No, the IP header is not increased/decreased in size. Mainly, the payload is modified.
Quoted 2 lines
You need to send an ICMP fragment needed to the sender of the packet.
I did not know of "fragment needed" ICMP messages. That might be an idea.
Quoted 9 lines
Lennart> I would like to see a second MTU-value attached to each network Lennart> device which specifies a higher limit than the normal Lennart> MTU. Packets which are larger than this second MTU get dropped, Lennart> packets which are larger than the normal MTU but smaller than Lennart> that special MTU are accepted. So that I would be able to set Lennart> the normal mtu to 1480 and the effective MTU to 1500 and be Lennart> happy this way. Is there anything like this available in the Lennart> Linux kernel currently?
Quoted 3 lines
Yes, you can specify the MTU as part of a route, and as part of the
neighbour cache. The later gets created automatically, so might take some code to do what you want.
I did not know of this feature either!
ip route change 10.0.0.0/8 dev eth0 mtu 1400
seems to do the job for me, is that right?
This seems to be the ideal solution! Thanks!
Quoted 7 lines
Lennart> Maybe there is a simple sysctl variable that may modify the Lennart> packet size the kernel splits its TCP stream with?
If you are strictly dealing with locally generated packets, then it should
be easier. A virtual interface is one way to deal with this, but is has other less desireable effects as well.
I already thought of another, more pragmatic solution: The large packages are mostly TCP. Thus it is enough to get TCP right. And this is easy to do: the TCPMSS target is a simple solution to limit segment size. It works quite fine. UDP packages will get fragmented and slowed down. However: it won't break things, since no packets are lost.
Thank you very much for your help!
lp
Signature · 3 lines
name { Lennart Poettering } mail { [email protected] }
icq { 11060553 } www { http://www.poettering.de/lennart/ }
loc { hamburg, germany } pgp { 0x1A015CC4 } hack { .phi. }