Commit 2889f515 authored by Julien Muchembled's avatar Julien Muchembled

Avoid fragmentation when using UDP

We'll have to revive UDP because we experienced congestion with TCP.
This should make UDP efficient in good environment.
MTU discovery is required however to enable UDP by default.
parent 756bda32
...@@ -23,11 +23,19 @@ def openvpn(iface, encrypt, *args, **kw): ...@@ -23,11 +23,19 @@ def openvpn(iface, encrypt, *args, **kw):
logging.debug('%r', args) logging.debug('%r', args)
return utils.Popen(args, **kw) return utils.Popen(args, **kw)
# tested in a LAN with a switch and wired/wireless interfaces (mtu 1500)
ovpn_link_mtu_dict = {'udp': 1490, 'udp6': 1450}
def server(iface, max_clients, dh_path, pipe_fd, port, proto, encrypt, *args, **kw): def server(iface, max_clients, dh_path, pipe_fd, port, proto, encrypt, *args, **kw):
client_script = '%s %s' % (ovpn_server, pipe_fd) client_script = '%s %s' % (ovpn_server, pipe_fd)
if pipe_fd is not None: if pipe_fd is not None:
args = ('--client-disconnect', client_script) + args args = ('--client-disconnect', client_script) + args
try:
args = ('--link-mtu', str(ovpn_link_mtu_dict[proto]),
# mtu-disc ignored for udp6 due to a bug in OpenVPN
'--mtu-disc', 'yes') + args
except KeyError:
proto += '-server'
return openvpn(iface, encrypt, return openvpn(iface, encrypt,
'--tls-server', '--tls-server',
'--mode', 'server', '--mode', 'server',
...@@ -35,14 +43,20 @@ def server(iface, max_clients, dh_path, pipe_fd, port, proto, encrypt, *args, ** ...@@ -35,14 +43,20 @@ def server(iface, max_clients, dh_path, pipe_fd, port, proto, encrypt, *args, **
'--dh', dh_path, '--dh', dh_path,
'--max-clients', str(max_clients), '--max-clients', str(max_clients),
'--port', str(port), '--port', str(port),
'--proto', proto + '-server' if proto in ('tcp', 'tcp6') else proto, '--proto', proto,
*args, **kw) *args, **kw)
def client(iface, address_list, encrypt, *args, **kw): def client(iface, address_list, encrypt, *args, **kw):
remote = ['--nobind', '--client'] remote = ['--nobind', '--client']
# XXX: We'd like to pass <connection> sections at command-line.
link_mtu = set()
for ip, port, proto in address_list: for ip, port, proto in address_list:
remote += '--remote', ip, port, proto remote += '--remote', ip, port, proto
link_mtu.add(ovpn_link_mtu_dict.get(proto))
link_mtu, = link_mtu
if link_mtu:
remote += '--link-mtu', str(link_mtu), '--mtu-disc', 'yes'
remote += args remote += args
return openvpn(iface, encrypt, *remote, **kw) return openvpn(iface, encrypt, *remote, **kw)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment