Problems with add_route_ipv6()
Hi guys,
I'm using the latest openvpn from GIT on OpenSUSE 11.4 and am experiencing a problem with IPv6 payload setup. It works but openvpn seems to be somewhat confused when setting up the v6 route.
Here is the start-up sequence, that works fine:
16:27:27 OpenVPN 2.x-master x86_64-suse-linux-gnu [SSL (OpenSSL)] [LZO2] [EPOLL] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110522-1 (2.2.0)] built on Nov 23 2011
16:27:27 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
16:27:27 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
16:27:27 Socket Buffers: R=[126976->131072] S=[126976->131072]
16:27:27 UDPv4 link local: [undef]
16:27:27 UDPv4 link remote: [AF_INET]118.90.12.34:1194
16:27:27 TLS: Initial packet from [AF_INET]118.90.12.34:1194, sid=9cf3b1b8 b861db1e
Wed Nov 23 16:27:31 2011 VERIFY OK: depth=1, /C=CZ/L=Prague/O=Logix.cz/CN=Logix.cz_Root_CA/[email protected]...
Wed Nov 23 16:27:31 2011 VERIFY OK: depth=0, /C=NZ/L=Auckland/O=Logix/CN=xyz.logix.net.nz/[email protected]...
16:27:35 WARNING: 'proto' is used inconsistently, local='proto UDPv4', remote='proto UDPv6'
16:27:35 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
16:27:35 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
16:27:35 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
16:27:35 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
16:27:35 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
16:27:35 [xyz.logix.net.nz] Peer Connection Initiated with [AF_INET]118.90.12.34:1194
16:27:37 SENT CONTROL [xyz.logix.net.nz]: 'PUSH_REQUEST' (status=1)
16:27:37 PUSH: Received control message: 'PUSH_REPLY,ifconfig-ipv6 2001:e20:abcd:403::1:0 2001:e20:abcd:403::1,route 172.31.172.0 255.255.255.0,route-ipv6 2001:e20:abcd:400::/56,tun-ipv6,route 172.31.173.129,topology net30,ifconfig 172.31.173.134 172.31.173.133' 16:27:37 OPTIONS IMPORT: --ifconfig/up options modified
16:27:37 OPTIONS IMPORT: route options modified
16:27:37 ROUTE_GATEWAY 192.168.50.254/255.255.255.0 IFACE=wlan0 HWADDR=08:11:96:04:50:cc
16:27:37 ROUTE6: default_gateway=UNDEF
16:27:37 TUN/TAP device tunHome opened
16:27:37 TUN/TAP TX queue length set to 100
16:27:37 do_ifconfig, tt->ipv6=1, tt->did_ifconfig_ipv6_setup=1
16:27:37 /bin/ip link set dev tunHome up mtu 1500
16:27:37 /bin/ip addr add dev tunHome local 172.31.173.134 peer 172.31.173.133
16:27:37 /bin/ip -6 addr add 2001:e20:abcd:403::1:0/64 dev tunHome
16:27:37 /bin/ip route add 172.31.172.0/24 via 172.31.173.133
16:27:37 /bin/ip route add 172.31.173.129/32 via 172.31.173.133
16:27:37 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:27:37 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
16:27:37 Initialization Sequence Completed
However every 2 minutes OpenVPN for some reason triggers a restart and then it tries to call add_route_ipv6() more then once. In fact it calls it 2x on the first restrat, 3x on the 2nd restart, etc. Here you go after a couple of minutes:
16:42:16 [xyz.logix.net.nz] Inactivity timeout (--ping-restart), restarting
16:42:16 /bin/ip route del 172.31.173.129/32
16:42:16 /bin/ip route del 172.31.172.0/24
16:42:16 delete_route_ipv6(2001:e20:abcd:400::/56)
16:42:16 /bin/ip -6 route del 2001:e20:abcd:400::/56 dev tunHome
16:42:16 Closing TUN/TAP interface
16:42:16 /bin/ip addr del dev tunHome local 172.31.173.134 peer 172.31.173.133
16:42:16 SIGUSR1[soft,ping-restart] received, process restarting
16:42:16 Restart pause, 2 second(s)
16:42:18 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
16:42:18 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
16:42:18 Socket Buffers: R=[126976->131072] S=[126976->131072]
16:42:18 UDPv4 link local: [undef]
16:42:18 UDPv4 link remote: [AF_INET]118.90.12.34:1194
16:42:18 TLS: Initial packet from [AF_INET]118.90.12.34:1194, sid=1db8d9ff 496ac330
16:42:18 VERIFY OK: depth=1, /C=CZ/L=Prague/O=Logix.cz/CN=Logix.cz_Root_CA/[email protected]...
16:42:18 VERIFY OK: depth=0, /C=NZ/L=Auckland/O=Logix/CN=xyz.logix.net.nz/[email protected]...
16:42:19 WARNING: 'proto' is used inconsistently, local='proto UDPv4', remote='proto UDPv6'
16:42:19 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
16:42:19 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
16:42:19 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
16:42:19 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
16:42:19 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
16:42:19 [xyz.logix.net.nz] Peer Connection Initiated with [AF_INET]118.90.12.34:1194
16:42:21 SENT CONTROL [xyz.logix.net.nz]: 'PUSH_REQUEST' (status=1)
16:42:21 PUSH: Received control message: 'PUSH_REPLY,ifconfig-ipv6 2001:e20:abcd:403::1:0 2001:e20:abcd:403::1,route 172.31.172.0 255.255.255.0,route-ipv6 2001:e20:abcd:400::/56,tun-ipv6,route 172.31.173.129,topology net30,ifconfig 172.31.173.134 172.31.173.133' 16:42:21 OPTIONS IMPORT: --ifconfig/up options modified
16:42:21 OPTIONS IMPORT: route options modified
16:42:21 ROUTE_GATEWAY 192.168.50.254/255.255.255.0 IFACE=wlan0 HWADDR=08:11:96:04:50:cc
16:42:21 ROUTE6: default_gateway=UNDEF
16:42:21 TUN/TAP device tunHome opened
16:42:21 TUN/TAP TX queue length set to 100
16:42:21 do_ifconfig, tt->ipv6=1, tt->did_ifconfig_ipv6_setup=1
16:42:21 /bin/ip link set dev tunHome up mtu 1500
16:42:21 /bin/ip addr add dev tunHome local 172.31.173.134 peer 172.31.173.133
16:42:21 /bin/ip -6 addr add 2001:e20:abcd:403::1:0/64 dev tunHome
16:42:21 /bin/ip route add 172.31.172.0/24 via 172.31.173.133
16:42:21 /bin/ip route add 172.31.173.129/32 via 172.31.173.133
16:42:21 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:42:21 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
16:42:21 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:42:21 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
RTNETLINK answers: File exists
16:42:21 ERROR: Linux route -6/-A inet6 add command failed: external program exited with error status: 2
16:42:21 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:42:21 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
RTNETLINK answers: File exists
16:42:21 ERROR: Linux route -6/-A inet6 add command failed: external program exited with error status: 2
16:42:21 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:42:21 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
RTNETLINK answers: File exists
16:42:21 ERROR: Linux route -6/-A inet6 add command failed: external program exited with error status: 2
16:42:21 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:42:21 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
RTNETLINK answers: File exists
16:42:21 ERROR: Linux route -6/-A inet6 add command failed: external program exited with error status: 2
16:42:21 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:42:21 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
RTNETLINK answers: File exists
16:42:21 ERROR: Linux route -6/-A inet6 add command failed: external program exited with error status: 2
16:42:21 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:42:21 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
RTNETLINK answers: File exists
16:42:21 ERROR: Linux route -6/-A inet6 add command failed: external program exited with error status: 2
16:42:21 add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0) dev tunHome
16:42:21 /bin/ip -6 route add 2001:e20:abcd:400::/56 dev tunHome
RTNETLINK answers: File exists
16:42:21 ERROR: Linux route -6/-A inet6 add command failed: external program exited with error status: 2
16:42:21 Initialization Sequence Completed
After a couple hrs the list of failed retries becomes pretty long..
This is the remote config:
-------
lport 1194
proto udp6
dev tunTrUDP
key ...
float
server 172.31.173.128 255.255.255.128
server-ipv6 2001:e20:abcd:403::/64
push "route 172.31.172.0 255.255.255.0"
push "route-ipv6 2001:e20:abcd:400::/56"
------
And finally this is the local config:
------
remote xyz.logix.net.nz 1194
dev tunHome
tun-ipv6
key ...
------
Is there anything wrong with my setup or is it an OpenVPN bug?
Thanks!
Michal
Hi,
Quoted 3 lines · Michal Ludvig
I'm using the latest openvpn from GIT on OpenSUSE 11.4 and am experiencing a problem with IPv6 payload setup. It works but openvpn seems to be somewhat confused when setting up the v6 route.
There's two interesting things in here...
Quoted 6 lines
However every 2 minutes OpenVPN for some reason triggers a restart and then it tries to call
add_route_ipv6()more then once. In fact it calls it 2x on the first restrat, 3x on the 2nd restart, etc. Here you go after a couple of minutes:16:42:16 [xyz.logix.net.nz] Inactivity timeout (--ping-restart), restarting
... first, the restart, due to --ping timeout. This normally shouldn't happen in the first place - but it's not "the bug", it's just the trigger.
Quoted 7 lines
16:42:21
add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0)dev tunHome
16:42:21/bin/ip-6 route add 2001:e20:abcd:400::/56 dev tunHome 16:42:21add_route_ipv6(2001:e20:abcd:400::/56 -> 2001:e20:abcd:403::1 metric 0)dev tunHome
16:42:21/bin/ip-6 route add 2001:e20:abcd:400::/56 dev tunHome RTNETLINK answers: File exists
... and *that* is quite obviously a bug. It seems as if the pushed route list isn't properly flushed upon disconnect, and then the routes are just added again on top of it.
I'll go and investigate. Thanks for bringing this up.
Quoted 1 line
Is there anything wrong with my setup or is it an OpenVPN bug?
The "ping restart" could be missing --ping* options on the server, but that's just triggering the real bug - so it's good that you found it, and we can fix it in time for 2.3.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi,
sorry for this to take so long, but other stuff got in my way.
Quoted 3 lines · Michal Ludvig
I'm using the latest openvpn from GIT on OpenSUSE 11.4 and am experiencing a problem with IPv6 payload setup. It works but openvpn seems to be somewhat confused when setting up the v6 route.
It took me a bit, but I can now reproduce this, with today's git snapshot (no change in the ipv6 code since May, so it's not unexpected for this to still be there).
[..]
Quoted 1 line
However every 2 minutes OpenVPN for some reason triggers a restart
This is caused by --ping-restart being set to the default (2 minutes) on your end, but no corresponding --ping being set on the server side (--ping is asymmetric, it needs to be enabled on the *other* side to make --ping-restart not, uh, restart unduly).
Quoted 5 lines
and
then it tries to calladd_route_ipv6()more then once. In fact it calls it 2x on the first restrat, 3x on the 2nd restart, etc. Here you go after a couple of minutes:
Quoted 10 lines
16:42:16 [xyz.logix.net.nz] Inactivity timeout (--ping-restart), restarting 16:42:16
/bin/iproute del 172.31.173.129/32
16:42:16/bin/iproute del 172.31.172.0/24
16:42:16delete_route_ipv6(2001:e20:abcd:400::/56)
16:42:16/bin/ip-6 route del 2001:e20:abcd:400::/56 dev tunHome 16:42:16 Closing TUN/TAP interface
16:42:16/bin/ipaddr del dev tunHome local 172.31.173.134 peer 172.31.173.133
16:42:16 SIGUSR1[soft,ping-restart] received, process restarting 16:42:16 Restart pause, 2 second(s)
... one of the possible workarounds here would be to use --persist-tun, which makes it "not close and reopen the tun device", so no extra route adding is happening.
Now, this is still a bug - and without --persist-tun, I can reproduce it perfectly:
Fri Dec 30 20:10:19 2011 us=642033 /sbin/ip -6 route add 2001:608:4:a000::/56 dev tun0
Fri Dec 30 20:10:19 2011 us=644224 /sbin/ip -6 route add 2001:608:4:a000::/56 dev tun0
RTNETLINK answers: File exists
Fri Dec 30 20:10:19 2011 us=646183 ERROR: Linux route -6/-A inet6 add command failed: external program exited with error status: 2 Fri Dec 30 20:10:19 2011 us=646334 /sbin/ip -6 route add 2001:608:4:a000::/56 dev tun0
RTNETLINK answers: File exists
Quoted 1 line
Is there anything wrong with my setup or is it an OpenVPN bug?
Bug. For workarounds, see above :-) and a patch will follow as soon as I have cornered the bug (or have understood why this is not happening for IPv4).
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi,
Quoted 4 lines · Gert Doering
Quoted 3 lines · Michal Ludvig
I'm using the latest openvpn from GIT on OpenSUSE 11.4 and am experiencing a problem with IPv6 payload setup. It works but openvpn seems to be somewhat confused when setting up the v6 route.
[..]
Quoted 3 lines
Bug. For workarounds, see above :-) and a patch will follow as soon as I have cornered the bug (or have understood why this is not happening for IPv4).
"lazy coder error". OpenVPN in p2mp client mode saves certain(!) options before pulling options from the server (pre_pull_save() etc. in options.c) and this only happened for IPv4 - because, when adding IPv6 support, I just overlooked this code path.
So on reconnection, the IPv4 "route_option_list" was reset, and the corresponding IPv6 "route_ipv6_option_list" wasn't - and thus, all the IPv6 routes were added to whatever was pushed by the server previously, leading to duplicate routes.
A patch is attached. I have tested this here for various cases, and with the patch, the problem is gone (as expected) and I haven't seen any adverse cases.
Michal, if you could test that this fixes the problem for you, it would be great.
David, this patch is pretty much straightforward duplication of the corresponding IPv4 code path. It needs helpers in route.c, thus the patch is somewhat bigger than expected... but it should be "fairly easy" to review.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...From 1a8e83b89a828cfc80a229309e30d8b3b6c59928 Mon Sep 17 00:00:00 2001
From: Gert Doering <[email protected]...>
Date: Fri, 30 Dec 2011 21:08:49 +0100
Subject: [PATCH] Fix build-up of duplicate IPv6 routes on reconnect.
options.c: extend pre_pull_save() and pre_pull_restore() to
save/restore options->routes_ipv6 as well
options.h: add routes_ipv6 to "struct options_pre_pull" route.h, route.c: add clone_route_ipv6_option_list() and
copy_route_ipv6_option_list() helper functions
--- options.c | 13 +++++++++++++ options.h | 3 +++ route.c | 19 +++++++++++++++++++ route.h | 3 +++ 4 files changed, 38 insertions(+), 0 deletions(-)
options.c +13 -0
@@ -2778,6 +2778,11 @@ pre_pull_save (struct options *o) o->pre_pull->routes =clone_route_option_list (o->routes, &o->gc); o->pre_pull->routes_defined = true; } +if (o->routes_ipv6) + { + o->pre_pull->routes_ipv6 =clone_route_ipv6_option_list (o->routes_ipv6, &o->gc); + o->pre_pull->routes_ipv6_defined = true; + }#ifdef ENABLE_CLIENT_NAT if (o->client_nat) {
@@ -2806,6 +2811,14 @@ pre_pull_restore (struct options *o)else o->routes =NULL ; +if (pp->routes_ipv6_defined) + { +rol6_check_alloc (o); +copy_route_ipv6_option_list (o->routes_ipv6, pp->routes_ipv6); + } +else + o->routes_ipv6 =NULL ; +#ifdef ENABLE_CLIENT_NAT if (pp->client_nat_defined) {
options.h +3 -0
@@ -68,6 +68,9 @@ struct options_pre_pullbool routes_defined;struct route_option_list *routes; +bool routes_ipv6_defined; +struct route_ipv6_option_list *routes_ipv6; +#ifdef ENABLE_CLIENT_NAT bool client_nat_defined;struct client_nat_option_list *client_nat;
route.c +19 -0
@@ -108,6 +108,15 @@ clone_route_option_list (const struct route_option_list *src, struct gc_arena *areturn ret; } +struct route_ipv6_option_list * +clone_route_ipv6_option_list (const struct route_ipv6_option_list *src,struct gc_arena *a) +{ +const size_t rl_size =array_mult_safe (sizeof (struct route_ipv6_option ), src->capacity,sizeof (struct route_ipv6_option_list )); +struct route_ipv6_option_list *ret =gc_malloc (rl_size, false, a); +memcpy (ret, src, rl_size); +return ret; +} +void copy_route_option_list (struct route_option_list *dest,const struct route_option_list *src) {
@@ -117,6 +126,16 @@ copy_route_option_list (struct route_option_list *dest, const struct route_optiomemcpy (dest, src, src_size); } +void +copy_route_ipv6_option_list (struct route_ipv6_option_list *dest, +const struct route_ipv6_option_list *src) +{ +const size_t src_size =array_mult_safe (sizeof (struct route_ipv6_option ), src->capacity,sizeof (struct route_ipv6_option_list )); +if (src->n > dest->capacity) +msg (M_FATAL ,PACKAGE_NAME " ROUTE: (copy) number of route options in src (%d) is greater than route list capacity in dest (%d)" , src->n, dest->capacity); +memcpy (dest, src, src_size); +} +struct route_list *new_route_list (const int max_routes,struct gc_arena *a) {
route.h +3 -0
@@ -211,7 +211,10 @@ struct route_option_list *new_route_option_list (const int max_routes, struct gcstruct route_ipv6_option_list *new_route_ipv6_option_list (const int max_routes,struct gc_arena *a);struct route_option_list *clone_route_option_list (const struct route_option_list *src,struct gc_arena *a); +struct route_ipv6_option_list *clone_route_ipv6_option_list (const struct route_ipv6_option_list *src,struct gc_arena *a);void copy_route_option_list (struct route_option_list *dest,const struct route_option_list *src); +void copy_route_ipv6_option_list (struct route_ipv6_option_list *dest, +const struct route_ipv6_option_list *src);struct route_list *new_route_list (const int max_routes,struct gc_arena *a);struct route_ipv6_list *new_route_ipv6_list (const int max_routes,struct gc_arena *a);
Signature · 1 line
1.7.3.4
David Sommerseth
Acked-by-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 27 lines · Gert Doering
Hi,
Quoted 5 lines · Gert Doering
Quoted 4 lines · Michal Ludvig
I'm using the latest openvpn from GIT on OpenSUSE 11.4 and am experiencing a problem with IPv6 payload setup. It works but openvpn seems to be somewhat confused when setting up the v6 route.
[..]
Quoted 3 lines
Bug. For workarounds, see above :-) and a patch will follow as soon as I have cornered the bug (or have understood why this is not happening for IPv4).
"lazy coder error". OpenVPN in p2mp client mode saves certain(!) options before pulling options from the server (
pre_pull_save()etc. inoptions.c) and this only happened for IPv4 - because, when adding IPv6 support, I just overlooked this code path.So on reconnection, the IPv4 "
route_option_list" was reset, and the corresponding IPv6 "route_ipv6_option_list" wasn't - and thus, all the IPv6 routes were added to whatever was pushed by the server previously, leading to duplicate routes.A patch is attached. I have tested this here for various cases, and with the patch, the problem is gone (as expected) and I haven't seen any adverse cases.
Quoted 8 lines
Michal, if you could test that this fixes the problem for you, it would be great.
David, this patch is pretty much straightforward duplication of the corresponding IPv4 code path. It needs helpers in
route.c, thus the patch is somewhat bigger than expected... but it should be "fairly easy" to review.
ACK. Applied to master branch on -testing and -stable trees.
commit 9140223643f7d9bdfd2214304a7bd6ab4b662f97
Author: Gert Doering <[email protected]...> Date: Fri Dec 30 21:08:49 2011 +0100
Fix build-up of duplicate IPv6 routes on reconnect.
options.c: extend pre_pull_save() and pre_pull_restore() to
save/restore options->routes_ipv6 as well
options.h: add routes_ipv6 to "struct options_pre_pull" route.h, route.c: add clone_route_ipv6_option_list() and
copy_route_ipv6_option_list() helper functions
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk8EPwAACgkQDC186MBRfrr2ZQCdH78BvqhxhOmJEI3Ur+3/q7XN mwwAn25WhXEoQZa1PIkbW5H3sVTN1NDM
=jLpt
-----END PGP SIGNATURE-----