MTU
Russ,
Have you tried the tracepath utility to attempt to measure the Path MTU?
Are the routers in the path properly forwarding ICMP code 3 (destination unreachable), and ICMP code 4 (fragmentation needed but don't-fragment bit set)?
Most MTU problems are caused by routers and firewalls which do not handle these ICMP codes correctly, causing path MTU discovery to break.
The symptoms of this problem are as you show below... Running an app over the
tunnel works fine initially until the first large packet is sent, then the
app hangs.
Right now OpenVPN relies on Path MTU Discovery (a service provided by the kernel) to get the MTU right, so in the short run the best thing you can do is to try to get Path MTU working.
You could also try to lower --udp-mtu by trial and error until you find something that works (essentially a manual approach to MTU discovery).
If you are running tunnels over tunnels, the lower-level (more nested) tunnels will need lower --udp-mtu settings.
Longer-term, I hope to put some intelligence in OpenVPN to do this automatically.
James
Quoted 20 lines · R P Herrold
Quoted 6 lines · James Yonan
Recently I've been taking a new look at MTU issues. It seems that some people are having problems lately that are related to MTU or PMTU discovery.
I was trying to think up some ways to make OpenVPN's handling of MTU a bit less opaque, more automatic, and also give more manual control to those who know what they're doing.
If it is any help, I can replicate the error on demand. Coing frm my host 'couch', through two openvpn legs, once of which is running encryption, the other not, I get:
[[email protected]... ORC]# scp ftp.victim.lan:/etc/ORC/* . [email protected]...'s password:
Permission denied, please try again. [email protected]...'s password:
ORCsetPXE 0% | |
0 --:-- ETAKilled by signal 2.
Quoted 8 lines
**** it is locked up and hung here.
[[email protected]... ORC]# ssh ftp.victim.lan
[email protected]...'s password:
Last login: Sat Feb 22 15:21:51 2003 from router.victim.lan [[email protected]... root]# cd/etc/ORC
[[email protected]... ORC]# scp * couch.basement.lan:/etc/ORC
The authenticity of host 'couch.basement.lan (10.16.33.101)' can't be
established.
Quoted 24 lines
RSA1 key fingerprint is 38:d4:69:9e:cb:96:81:68:d2:2b:6b:6f:b9:33:c2:39. Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'couch.basement.lan,10.16.33.101' (RSA1) to the list of known hosts.
[email protected]...'s password:ORCsetPXE 100% |*****************************| 3032 00:00 ORCsetPXE~ 100% |*****************************| 2955 00:00 installCDrc 100% |*****************************| 234 00:00 installCDrc-80 100% |*****************************| 227 00:00 installCDrc-8094 100% |*****************************| 234 00:00 installCDrc-LTSP 100% |*****************************| 188 00:00 installCDrc-template 100% |*****************************| 565 00:00[[email protected]... ORC]#
[[email protected]... ORC]# dmesg
Linux version 2.4.18-17.8.0 ([email protected]...) (gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)) #1 Tue Oct 8 13:51:08 EDT 2002**** it is locked up and hung here.
going to another host in that same remote subnet, but behind the router I also get:
Quoted 7 lines
(from 10.16.33.101 - host: couch )
bash-2.05b$ ssh ftp.victim.lan
[email protected]...'s password:
[[email protected]... herrold]$ dmesg
Linux version 2.4.18-17.8.0 ([email protected]...)
(gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)) #1 Tue Oct 8 13:51:08
EDT 2002
Quoted 18 lines
**** it is locked up and hung here.
lots of these on ftp.victim.lan:
ISO 9660 Extensions:
RRIP_1991A
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
ICMP: 10.16.33.101: fragmentation needed and DF set.
Quoted 8 lines
but no 'noise; attributable to the tun device or openvpn in the router:
eth0: Promiscuous mode enabled.
device eth0 entered promiscuous mode
Universal TUN/TAP device driver 1.5 (C)1999-2002 Maxim Krasnyansky
divert: not allocatingdivert_blkfor non-ethernet devicetun0ip_conntrack
(2047 buckets, 16376 max)
Quoted 1 line
TCP: Treason uncloaked! Peer 10.1.2.30:515/692 shrinks window
2141696489:2141697513. Repaired.
Quoted 1 line
TCP: Treason uncloaked! Peer 10.1.2.30:515/692 shrinks window
2141696489:2141697513. Repaired.
Quoted 1 line
TCP: Treason uncloaked! Peer 10.1.2.30:515/692 shrinks window
2141696489:2141697513. Repaired.
Quoted 1 line
TCP: Treason uncloaked! Peer 10.1.2.30:515/692 shrinks window
2141696489:2141697513. Repaired.
Quoted 1 line
TCP: Treason uncloaked! Peer 10.1.2.30:515/692 shrinks window
2141696489:2141697513. Repaired.
Quoted 1 line
TCP: Treason uncloaked! Peer 10.1.2.30:515/692 shrinks window
2141696489:2141697513. Repaired.
Quoted 1 line
TCP: Treason uncloaked! Peer 10.1.2.30:515/692 shrinks window
2141696489:2141697513. Repaired.
Quoted 24 lines
divert: no
divert_blkto free, tun0 not ethernet
divert: not allocatingdivert_blkfor non-ethernet device tun0 [[email protected]... herrold]$... 10.1.2.30 is a printservice device, not relebant
here, I think=================
General layout
10.16.33.101 --- clear tunnel to hub --
hub in the internet-- encrypted tunnel to hub -- 10.0.1.xThe subnet 'victim.lan' is doubly masg'd -- behind two iptables based NATting. This may be affecting things.
0.0.0.0 --- public-10.1.2.x --- 10.1.2.y-10.250.0.x ---
internet | dmz | victim.lan
NAT 1 NAT 2-- Russ Herrold
Quoted 7 lines · James Yonan
Russ,
Have you tried the tracepath utility to attempt to measure the Path MTU?
Are the routers in the path properly forwarding ICMP code 3 (destination unreachable), and ICMP code 4 (fragmentation needed but don't-fragment bit set)?
Quoted 6 lines
Most MTU problems are caused by routers and firewalls which do not handle these ICMP codes correctly, causing path MTU discovery to break.
The symptoms of this problem are as you show below... Running an app over the
tunnel works fine initially until the first large packet is sent, then the
app hangs.
I have a different theory here.
I am experiencing what I believe to be MTU problems, which have made me switch from RSA-auth to shared-key, just because the RSA auth stuff seems to trigger it also.
My theory is that part of the problem lies in how the Linux kernel handles udp. I already got it into the README-file that openbsd firewall scrub rules will "kill" openvpn the same way it will kill Linux-nfs, but somehow other routers along the route probably do similar things.
One of the problems is that Linux sometimes (this is more a vague feeling and guesswork than the next part) sends fragments in reverse, meaning that the second half of the packet will be sent before the first part of a split packet. This is why, for instance, you can't netboot Sun boxes from Linux tftp-servers. The prom-code (bios sort of) in Sun machines can't reassemble fragged packets, at least not packets that arrive in reverse. This might make routers and firewalls along the way to behave badly, especially with the next part in mind:
The second part is that linux will tag all UDP (or at least all UDP from OpenVPN and NFS) as "Dont fragment". This is sort of ok. The problem is, they do get fragmented anyway. I can't prove that it isn't related to the transport in between me and the peers I have set up, but I find it likely that someone is fragmenting them anyway, perhaps even by the sending linux box itself. Since there is a *BSD box in between in my case, it will regard any fragmented UDP (or ip) packet with DF set as a bug, it silently and without mercy kills them. It may also mean that if the second half of a fragment comes first, with the DF flag on, it's even more suspicious.
As far as I can guess, this probably goes for lots of ISP's and other hardware involved in the transport of ip packets between me and my peers.
For some reason, I seem to get the feeling that RSA negotiation doesn't follow the udp-mtu (or tun-mtu-derived udp-mtu) settings, and send too large packets, and them getting fragmented leads to me having to revert back to precalced secrets.
It also means that I get the same error as you've described in the last mails. I have a remote-backup-over-rsync that is protected by both OpenVPN and ssh inside of that. It goes some 256k and then dies. It dies reliably every time, and almost always on the same byte, some 240506 bytes into the RSYNC-stream. (whatever, the number isn't important). If I forego the openvpn and ssh straight into the machine, the rsync doesn't die.
So there definately exist some sort of issue with MTU's, which I can't seem to solve correctly. The question is, does the SSL-stuff really check the mtu's, and can you make the linux kernel not put DF's on UDP packets? (since they are ip packets, they can be fragmented and reassembled like any other packets I guess)
"man 7 udp" on RedHat says:
UDP fragments a packet when its total length exceeds the
interface MTU (Maximum Transmission Unit). A more network friendly alternative is to use path MTU discovery as described in the IP_PMTU_DISCOVER section of ip(7).
Quoted 7 lines · Jan Johansson
Quoted 6 lines · James Yonan
Russ,
Have you tried the tracepath utility to attempt to measure the Path MTU?
Are the routers in the path properly forwarding ICMP code 3 (destination unreachable), and ICMP code 4 (fragmentation needed but don't-fragment bit
set)?
Quoted 4 lines
Quoted 4 lines
Most MTU problems are caused by routers and firewalls which do not handle these ICMP codes correctly, causing path MTU discovery to break.
Quoted 8 lines
Quoted 3 lines
The symptoms of this problem are as you show below... Running an app over the
tunnel works fine initially until the first large packet is sent, then the
app hangs.I have a different theory here.
I am experiencing what I believe to be MTU problems, which have made me switch from RSA-auth to shared-key, just because the RSA auth stuff seems to trigger it also.
That's interesting, though it makes sense that if OpenVPN thinks the MTU is higher than it really is, that this would occur. That's because the SSL/TLS handshake involves some relatively large exchanges (several K octets) that are fragmented by OpenVPN to the udp-mtu packet size. In this case, if OpenVPN thinks that the udp-mtu is 1300 then it will attempt to send packets of exactly 1300 octets in size, until it reaches the last fragment which will probably be smaller. So essentially, OpenVPN's current method of fragmenting SSL/TLS handshakes guarantees that it will push the MTU parameter it's given to the limit (udp_mtu in this case).
Quoted 14 lines
My theory is that part of the problem lies in how the Linux kernel handles udp. I already got it into the README-file that openbsd firewall scrub rules will "kill" openvpn the same way it will kill Linux-nfs, but somehow other routers along the route probably do similar things.
One of the problems is that Linux sometimes (this is more a vague feeling and guesswork than the next part) sends fragments in reverse, meaning that the second half of the packet will be sent before the first part of a split packet. This is why, for instance, you can't netboot Sun boxes from Linux tftp-servers. The prom-code (bios sort of) in Sun machines can't reassemble fragged packets, at least not packets that arrive in reverse. This might make routers and firewalls along the way to behave badly, especially with the next part in mind:
Quoted 10 lines
The second part is that linux will tag all UDP (or at least all UDP from OpenVPN and NFS) as "Dont fragment". This is sort of ok. The problem is, they do get fragmented anyway. I can't prove that it isn't related to the transport in between me and the peers I have set up, but I find it likely that someone is fragmenting them anyway, perhaps even by the sending linux box itself. Since there is a *BSD box in between in my case, it will regard any fragmented UDP (or ip) packet with DF set as a bug, it silently and without mercy kills them. It may also mean that if the second half of a fragment comes first, with the DF flag on, it's even more suspicious.
Well actually what you are observing here is RFC 1191 ("Path MTU Discovery") in action (or inaction as the case may be :)
http://www.faqs.org/rfcs/rfc1191.html
This process causes the DF bit to always be set on outgoing packets, but assumes that other routers and firewalls in the path will play nice and return an "ICMP need fragmentation but DF set message" if the packet is too big.
For linux at least, Path MTU discovery can be turned off for a given UDP socket, causing all packets to be sent with DF cleared and no attempt by the kernel to offer fragmentation or defragmentation services.
I already have a feature in the CVS under branch MTU_EXPERIMENTAL which gives command line control over the Path MTU discovery settings on the UDP socket.
Quoted 7 lines
As far as I can guess, this probably goes for lots of ISP's and other hardware involved in the transport of ip packets between me and my peers.
For some reason, I seem to get the feeling that RSA negotiation doesn't follow the udp-mtu (or tun-mtu-derived udp-mtu) settings, and send too large packets, and them getting fragmented leads to me having to revert back to precalced secrets.
I will check this, but I doubt that SSL/TLS could go over the udp-mtu (I would expect lots of errors and/or assertion crashes in OpenVPN if this was the case). It seems more likely to me that the udp-mtu might be too large.
Quoted 7 lines
It also means that I get the same error as you've described in the last mails. I have a remote-backup-over-rsync that is protected by both OpenVPN and ssh inside of that. It goes some 256k and then dies. It dies reliably every time, and almost always on the same byte, some 240506 bytes into the RSYNC-stream. (whatever, the number isn't important). If I forego the openvpn and ssh straight into the machine, the rsync doesn't die.
I am considering adding a fragmenting feature to OpenVPN where it would fragment packets using the very efficient RFC 815 algorithm in the event that it received a packet on the TUN/TAP device that was bigger than the udp_mtu could accomodate. In essence, this feature would do fragmentation explicitly rather than depending on the OS to do the fragmentation correctly.
See http://www.faqs.org/rfcs/rfc815.html for more info.
Matthias Andree suggested that OpenVPN might generate its own "Fragmentation needed but DF set" ICMP messages and return them to the TUN/TAP device in this case.
Adding to this, OpenVPN could set the udp_mtu dynamically, based on its history of successfully transmitting packets of a range of sizes to its peer.
These changes, when taken as a whole, would take OpenVPN down the path of becoming more like an intelligent router, and move away from the model of relying on the OS to manage the transport protocol.
Quoted 13 lines
So there definately exist some sort of issue with MTU's, which I can't seem to solve correctly. The question is, does the SSL-stuff really check the mtu's, and can you make the linux kernel not put DF's on UDP packets? (since they are ip packets, they can be fragmented and reassembled like any other packets I guess)
"man 7 udp" on RedHat says:
UDP fragments a packet when its total length exceeds the
interface MTU (Maximum Transmission Unit). A more network friendly alternative is to use path MTU discovery as described in theIP_PMTU_DISCOVERsection of ip(7).
Quoted 4 lines
From this text, I can't figure out why Linux puts DF on the packets, which tcpdump clearly shows it does.
man 7 ip, udp, socket and friends have never shown me a way to stop DF, also none of them mention why Linux puts it there in the first place.
This code will stop Path MTU Discovery and the setting of the DF bit on a particular UDP socket:
int mtu_type = IP_PMTUDISC_DONT;setsockopt(udp_socket, SOL_IP, IP_MTU_DISCOVER, &mtu_type, sizeof (mtu_type)));
I know it works on linux, but I'm not sure about other OSes.
James