Miscallenous patches for OpenVPN
cover Miscallenous patches for OpenVPN
Submission of multiple patches that are still in my OpenVPN for Android "fork" of OpenVPN for Android.
Some of the patches are specific for the Android version (1, 3-6)
2 and 7 are cleanup patches (remove unused function and remove an Inline).
The only major patch is the timeout patch. (8). We talked about changing it this way in the Munich meeting.
Arne Schwabe (8):
Add support for requesting the fd again to rebind to the next
interface.
Remove #ifdefs for client nat support.
Don’t redirect the gateway on Android even if requested Use pseudo gw as default gw on Android as a workaround for not being
able to read /proc/net/route
Fix loglevel of protect socket message
Extend network-change command to allow reprotecting on the same
network (for short connection losses)
Remove unused function h_errno_msg
Remove http-proxy-timeout, socks timeout and set default of
server-poll-timeout to 120s
doc/openvpn.8 | 33 ++++++---------------- src/openvpn/clinat.c | 4 --- src/openvpn/clinat.h | 2 +- src/openvpn/forward-inline.h | 2 +- src/openvpn/forward.c | 19 +++++++++---- src/openvpn/forward.h | 2 +- src/openvpn/init.c | 67 +++++++++++++++++++++++++++++++++----------- src/openvpn/interval.h | 9 ++++++ src/openvpn/manage.c | 31 ++++++++++++++++++++ src/openvpn/manage.h | 3 ++ src/openvpn/multi.c | 2 -- src/openvpn/openvpn.h | 8 +++--- src/openvpn/options.c | 56 ++++++------------------------------ src/openvpn/options.h | 10 ------- src/openvpn/proxy.c | 22 +++++++++------ src/openvpn/proxy.h | 2 +- src/openvpn/push.c | 2 -- src/openvpn/route.c | 18 ++++++++++++ src/openvpn/socket.c | 31 ++++++-------------- src/openvpn/socket.h | 7 +++-- src/openvpn/syshead.h | 5 ---- 21 files changed, 177 insertions(+), 158 deletions(-)
Signature · 1 line
2.3.2 (Apple Git-55)
PATCH 1/8 Add support for requesting the fd again to rebind to the next interface.
This not done via android_control since calling management from management leads to an infinitive loop
--- src/openvpn/init.c | 34 ++++++++++++++++++++++++++++++++++ src/openvpn/manage.c | 26 ++++++++++++++++++++++++++ src/openvpn/manage.h | 3 +++ 3 files changed, 63 insertions(+)
src/openvpn/init.c +34 -0
@@ -3158,6 +3158,37 @@ management_show_net_callback (void *arg, const int msglevel) #endif } +#ifdef TARGET_ANDROID +int +managmenet_callback_network_change (void *arg) +{ +/* Check if the client should translate the network change to a SIGUSR1 to +reestablish the connection or just reprotect the socket + +At the moment just assume that, for all settings that use pull (not +--static) and are not using peer-id reestablishing the connection is +required + +The function returns -1 on invalid fd and -2 if the socket cannot be +reused. On the -2 return value the man_network_change function triggers +a SIGUSR1 to force a reconnect. +*/ + +int socketfd=-1 ; +struct context *c = (struct context *) arg; +if (!c->c2.link_socket) +return -1 ; +if (c->c2.link_socket->sd ==SOCKET_UNDEFINED ) +return -1 ; + + socketfd = c->c2.link_socket->sd; +if (!c->options.pull || c->c2.tls_multi->use_peer_id) +return socketfd; +else +return -2 ; +} +#endif +#endif void
@@ -3173,6 +3204,9 @@ init_management_callback_p2p (struct context *c) cb.show_net = management_show_net_callback; cb.proxy_cmd = management_callback_proxy_cmd; cb.remote_cmd = management_callback_remote_cmd; +#ifdef TARGET_ANDROID + cb.network_change = managmenet_callback_network_change; +#endif management_set_callback (management, &cb); }#endif
src/openvpn/manage.c +26 -0
@@ -1127,6 +1127,26 @@ man_remote (struct management *man, const char **p) } } +#ifdef TARGET_ANDROID +static void +man_network_change (struct management *man) +{ +/* Called to signal the OpenVPN that the network configuration has changed and +the client should either float or reconnect. + +The code is currently only used by ics-openvpn +*/ +if (man->persist.callback.network_change) + { +int fd = (*man->persist.callback.network_change)(man->persist.callback.arg); + man->connection.fdtosend = fd; +msg (M_CLIENT ,"PROTECTFD: fd '%d' sent to be protected" , fd); +if (fd ==-2 ) +man_signal (man,"SIGUSR1" ); + } +} +#endif +static void man_dispatch_command (struct management *man,struct status_output *so,const char **p,const int nparms) {
@@ -1170,6 +1190,12 @@ man_dispatch_command (struct management *man, struct status_output *so, const chif (man_need (man, p,1 ,0 ))man_signal (man, p[1 ]); } +#ifdef TARGET_ANDROID + else if (streq (p[0], "network-change")) + { +man_network_change (man); + } +#endif else if (streq (p[0], "load-stats")) {man_load_stats (man);
src/openvpn/manage.h +3 -0
@@ -173,6 +173,9 @@ struct management_callback#endif bool (*proxy_cmd) (void *arg,const char **p);bool (*remote_cmd) (void *arg,const char **p); +#ifdef TARGET_ANDROID +int (*network_change) (void *arg); +#endif };/*
Signature · 1 line
2.3.2 (Apple Git-55)
Re: [Openvpn-devel] [PATCH 1/8] Add support for requesting the fd again to rebind to the next interface.
Hi,
Quoted 1 line · Arne Schwabe
This not done via
android_controlsince calling management from management leads to an infinitive loop
I'm all willing to ACK it, but...
src/openvpn/init.c management_show_net_callback (void *arg, const int msglevel) · line 3163
Quoted 3 lines
src/openvpn/init.c +3
-0+#ifdef TARGET_ANDROID +int +managmenet_callback_network_change (void *arg)
^^^
... the typo police is not letting me.
src/openvpn/init.c init_management_callback_p2p (struct context *c) · line 3209
Quoted 7 lines
src/openvpn/init.c +3
-0@@ -3173,6 +3204,9 @@ init_management_callback_p2p (struct context *c) cb.show_net = management_show_net_callback; cb.proxy_cmd = management_callback_proxy_cmd; cb.remote_cmd = management_callback_remote_cmd; +#ifdef TARGET_ANDROID + cb.network_change = managmenet_callback_network_change; +#endif
As the typo is here as well, it *works*, but we should still fix it :)
All the rest looks good, as in "only touches Android anyway, but even there, pointer accesses are checked, in line with the rest, etc."
Shall I just fix the typo, ACK and commit, or do you want to re-send?
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]...[Openvpn-devel] [PATCH applied] Re: Add support for requesting the fd again to rebind to the next interface.
In reply to Arne SchwabeACK.
As discussed, I've changed the two occurances of "managmenet" into "management". Otherwise, unchanged.
Your patch has been applied to the master branch.
commit 300039789b23216f1733890063cef3120722f4cf
Author: Arne Schwabe Date: Tue Sep 15 11:23:32 2015 +0200
Add support for requesting the fd again to rebind to the next interface.
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10110
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 2/8 Remove #ifdefs for client nat support.
In reply to Arne SchwabeThe client-nat feature was always unconditionally enabled
--- src/openvpn/clinat.c | 4 ---- src/openvpn/clinat.h | 2 +- src/openvpn/forward.c | 12 +++++++----- src/openvpn/multi.c | 2 -- src/openvpn/openvpn.h | 2 -- src/openvpn/options.c | 18 +----------------- src/openvpn/options.h | 7 ------- src/openvpn/push.c | 2 -- src/openvpn/syshead.h | 5 ----- 9 files changed, 9 insertions(+), 45 deletions(-)
src/openvpn/clinat.c +0 -4
@@ -30,8 +30,6 @@#include "syshead.h" -#if defined(ENABLE_CLIENT_NAT ) -#include "clinat.h" #include "proto.h" #include "socket.h"
@@ -265,5 +263,3 @@ client_nat_transform (const struct client_nat_option_list *list, } } } - -#endif
src/openvpn/clinat.h +1 -1
@@ -22,7 +22,7 @@* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#if !defined(CLINAT_H ) && defined(ENABLE_CLIENT_NAT ) +#if !defined(CLINAT_H )#define CLINAT_H #include "buffer.h"
src/openvpn/forward.c +7 -5
@@ -1029,6 +1029,8 @@ process_ip_header (struct context *c, unsigned int flags, struct buffer *buf)if (!c->options.passtos) flags &= ~PIPV4_PASSTOS ;#endif +if (!c->options.client_nat) + flags &= ~PIPV4_CLIENT_NAT ;if (!c->options.route_gateway_via_dhcp) flags &= ~PIPV4_EXTRACT_DHCP_ROUTER ;
@@ -1038,11 +1040,13 @@ process_ip_header (struct context *c, unsigned int flags, struct buffer *buf)* The --passtos and --mssfix options require * us to examine the IPv4 header. */ + +if (flags & (PIP_MSSFIX #if PASSTOS_CAPABILITY -if (flags & (PIPV4_PASSTOS |PIP_MSSFIX )) -#else - if (flags & PIP_MSSFIX) + |PIPV4_PASSTOS #endif + |PIPV4_CLIENT_NAT + )) {struct buffer ipbuf = *buf;if (is_ipv4 (TUNNEL_TYPE (c->c1.tuntap), &ipbuf))
@@ -1057,14 +1061,12 @@ process_ip_header (struct context *c, unsigned int flags, struct buffer *buf)if (flags &PIP_MSSFIX )mss_fixup_ipv4 (&ipbuf,MTU_TO_MSS (TUN_MTU_SIZE_DYNAMIC (&c->c2.frame))); -#ifdef ENABLE_CLIENT_NAT /* possibly do NAT on packet */ if ((flags &PIPV4_CLIENT_NAT ) && c->options.client_nat) {const int direction = (flags &PIPV4_OUTGOING ) ?CN_INCOMING :CN_OUTGOING ;client_nat_transform (c->options.client_nat, &ipbuf, direction); } -#endif /* possibly extract a DHCP router message */ if (flags &PIPV4_EXTRACT_DHCP_ROUTER ) {
src/openvpn/multi.c +0 -2
@@ -1311,9 +1311,7 @@ multi_select_virtual_addr (struct multi_context *m, struct multi_instance *mi) mi->context.c2.push_ifconfig_defined = true; mi->context.c2.push_ifconfig_local = mi->context.options.push_ifconfig_local; mi->context.c2.push_ifconfig_remote_netmask = mi->context.options.push_ifconfig_remote_netmask; -#ifdef ENABLE_CLIENT_NAT mi->context.c2.push_ifconfig_local_alias = mi->context.options.push_ifconfig_local_alias; -#endif /* the current implementation does not allow "static IPv4, pool IPv6", * (see below) so issue a warning if that happens - don't break the
src/openvpn/openvpn.h +0 -2
@@ -440,9 +440,7 @@ struct context_2time_t sent_push_reply_expiry;in_addr_t push_ifconfig_local;in_addr_t push_ifconfig_remote_netmask; -#ifdef ENABLE_CLIENT_NAT in_addr_t push_ifconfig_local_alias; -#endif bool push_ifconfig_ipv6_defined;struct in6_addr push_ifconfig_ipv6_local;
src/openvpn/options.c +1 -17
@@ -225,9 +225,7 @@ static const char usage_message[] =" Add 'bypass-dns' flag to similarly bypass tunnel for DNS.\n" "--redirect-private [flags]: Like --redirect-gateway, but omit actually changing\n" " the default gateway. Useful when pushing private subnets.\n" -#ifdef ENABLE_CLIENT_NAT"--client-nat snat|dnat network netmask alias : on client add 1-to-1 NAT rule.\n" -#endif #ifdef ENABLE_PUSH_PEER_INFO"--push-peer-info : (client only) push client info to server.\n" #endif
@@ -1299,9 +1297,7 @@ options_detach (struct options *o) {gc_detach (&o->gc); o->routes =NULL ; -#ifdef ENABLE_CLIENT_NAT o->client_nat =NULL ; -#endif #if P2MP_SERVER clone_push_list (o);#endif
@@ -1321,14 +1317,12 @@ rol6_check_alloc (struct options *options) options->routes_ipv6 =new_route_ipv6_option_list (&options->gc); } -#ifdef ENABLE_CLIENT_NAT static void cnol_check_alloc (struct options *options) {if (!options->client_nat) options->client_nat =new_client_nat_list (&options->gc); } -#endif #ifndef ENABLE_SMALL static void
@@ -1524,11 +1518,9 @@ show_settings (const struct options *o)SHOW_BOOL (allow_pull_fqdn);if (o->routes)print_route_options (o->routes,D_SHOW_PARMS ); - -#ifdef ENABLE_CLIENT_NAT +if (o->client_nat)print_client_nat_list (o->client_nat,D_SHOW_PARMS ); -#endif #ifdef ENABLE_MANAGEMENT SHOW_STR (management_addr);
@@ -2821,13 +2813,11 @@ pre_pull_save (struct options *o) 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) { o->pre_pull->client_nat =clone_client_nat_option_list (o->client_nat, &o->gc); o->pre_pull->client_nat_defined = true; } -#endif } }
@@ -2857,7 +2847,6 @@ pre_pull_restore (struct options *o, struct gc_arena *gc)else o->routes_ipv6 =NULL ; -#ifdef ENABLE_CLIENT_NAT if (pp->client_nat_defined) {cnol_check_alloc (o);
@@ -2865,7 +2854,6 @@ pre_pull_restore (struct options *o, struct gc_arena *gc) }else o->client_nat =NULL ; -#endif o->foreign_option_index = pp->foreign_option_index; }
@@ -5221,14 +5209,12 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_PERSIST_IP ); options->persist_remote_ip = true; } -#ifdef ENABLE_CLIENT_NAT else if (streq (p[0 ],"client-nat" ) && p[1 ] && p[2 ] && p[3 ] && p[4 ] && !p[5 ]) {VERIFY_PERMISSION (OPT_P_ROUTE );cnol_check_alloc (options);add_client_nat_to_option_list (options->client_nat, p[1 ], p[2 ], p[3 ], p[4 ], msglevel); } -#endif else if (streq (p[0 ],"route" ) && p[1 ] && !p[5 ]) {VERIFY_PERMISSION (OPT_P_ROUTE );
@@ -5814,10 +5800,8 @@ add_option (struct options *options, options->push_ifconfig_defined = true; options->push_ifconfig_local = local; options->push_ifconfig_remote_netmask = remote_netmask; -#ifdef ENABLE_CLIENT_NAT if (p[3 ]) options->push_ifconfig_local_alias =getaddr (GETADDR_HOST_ORDER |GETADDR_RESOLVE , p[3 ],0 ,NULL ,NULL ); -#endif }else {
src/openvpn/options.h +0 -7
@@ -71,10 +71,8 @@ struct options_pre_pullbool 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; -#endif int foreign_option_index; };
@@ -346,10 +344,7 @@ struct optionsbool route_nopull;bool route_gateway_via_dhcp;bool allow_pull_fqdn;/* as a client, allow server to push a FQDN for certain parameters */ - -#ifdef ENABLE_CLIENT_NAT struct client_nat_option_list *client_nat; -#endif #ifdef ENABLE_OCC /* Enable options consistency check between peers */
@@ -431,9 +426,7 @@ struct optionsbool push_ifconfig_defined;in_addr_t push_ifconfig_local;in_addr_t push_ifconfig_remote_netmask; -#ifdef ENABLE_CLIENT_NAT in_addr_t push_ifconfig_local_alias; -#endif bool push_ifconfig_constraint_defined;in_addr_t push_ifconfig_constraint_network;in_addr_t push_ifconfig_constraint_netmask;
src/openvpn/push.c +0 -2
@@ -294,10 +294,8 @@ send_push_reply (struct context *c)if (c->c2.push_ifconfig_defined && c->c2.push_ifconfig_local && c->c2.push_ifconfig_remote_netmask) {in_addr_t ifconfig_local = c->c2.push_ifconfig_local; -#ifdef ENABLE_CLIENT_NAT if (c->c2.push_ifconfig_local_alias) ifconfig_local = c->c2.push_ifconfig_local_alias; -#endif buf_printf (&buf,",ifconfig %s %s" ,print_in_addr_t (ifconfig_local,0 , &gc),print_in_addr_t (c->c2.push_ifconfig_remote_netmask,0 , &gc));
src/openvpn/syshead.h +0 -5
@@ -702,11 +702,6 @@ socket_defined (const socket_descriptor_t sd)#endif /* -* Do we support internal client-side NAT? -*/ -#define ENABLE_CLIENT_NAT - -/* * Compression support */ #if defined(ENABLE_SNAPPY) || defined(ENABLE_LZO) || defined(ENABLE_LZ4) || \
Signature · 1 line
2.3.2 (Apple Git-55)
[Openvpn-devel] [PATCH applied] Re: Remove #ifdefs for client nat support.
ACK. I can't remember when we discussed this (some IRC meeting), but as this is always enabled anyway, and all the #ifdefs are really hurting the eyes, away with it :-)
(I admit I have never used it and have no idea what nice stuff one can do with it... should set up a test case for it!)
Your patch has been applied to the master branch.
commit 8db23a57c878abd5b01c784c7db570176de555ef
Author: Arne Schwabe Date: Tue Sep 15 11:23:33 2015 +0200
Remove #ifdefs for client nat support.
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10109
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 3/8 Don’t redirect the gateway on Android even if requested
In reply to Arne SchwabeRouting loops are avoided using the VPNService API
--- src/openvpn/route.c | 4 ++++ 1 file changed, 4 insertions(+)
src/openvpn/route.c +4 -0
@@ -528,8 +528,10 @@ add_block_local (struct route_list *rl) {size_t i; +#ifndef TARGET_ANDROID /* add bypass for gateway addr */ add_bypass_address (&rl->spec.bypass, rl->rgi.gateway.addr); +#endif /* block access to local subnet */ add_block_local_item (rl, &rl->rgi.gateway, rl->spec.remote_endpoint);
@@ -817,6 +819,7 @@ redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, u }else { +#ifndef TARGET_ANDROID bool local =BOOL_CAST (rl->flags &RG_LOCAL );if (rl->flags &RG_AUTO_LOCAL ) {const int tla = rl->spec.remote_host_local;
@@ -849,6 +852,7 @@ redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, u dmsg (D_ROUTE, "ROUTE remote_host protocol differs from tunneled"); } } +#endif /* route DHCP/DNS server traffic through original default gateway */ add_bypass_routes (&rl->spec.bypass, rl->rgi.gateway.addr, tt, flags, &rl->rgi, es);
Signature · 1 line
2.3.2 (Apple Git-55)
[Openvpn-devel] [PATCH applied] Re: Don't redirect the gateway on Android even if requested
Your patch has been applied to the master branch.
(I've taken the liberty to replace the UTF-8 apostroph in "Don't" with a 7 bit one... still living in ISO8859-1 land and this messes up my terminals :) )
commit ad80d6779488e77bc81f395f61d4052184f9a589
Author: Arne Schwabe Date: Tue Sep 15 11:23:34 2015 +0200
Don?t redirect the gateway on Android even if requested
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10113
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Don't redirect the gateway on Android even if requested
In reply to Arne SchwabeArgh, too fast...
"ACK!"
And I expect we'll need a similar patch for the IPv6 routing bits, as soon as they are fully merged - the code is not needed on Android, and the best thing it can do is "get in the way", so #ifndef is good :)
Your patch has been applied to the master branch.
(I've taken the liberty to replace the UTF-8 apostroph in "Don't" with a 7 bit one... still living in ISO8859-1 land and this messes up my terminals :) )
commit ad80d6779488e77bc81f395f61d4052184f9a589
Author: Arne Schwabe Date: Tue Sep 15 11:23:34 2015 +0200
Don?t redirect the gateway on Android even if requested
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10113
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 4/8 Use pseudo gw as default gw on Android as a workaround for not being able to read /proc/net/route
In reply to Arne Schwabe--- src/openvpn/route.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
src/openvpn/route.c +14 -0
@@ -2474,6 +2474,7 @@ get_default_gateway (struct route_gateway_info *rgi)CLEAR (*rgi); +#ifndef TARGET_ANDROID /* get default gateway IP addr */ {FILE *fp =fopen ("/proc/net/route" ,"r" );
@@ -2530,6 +2531,19 @@ get_default_gateway (struct route_gateway_info *rgi) } } } +#else +/* Android, set some pseudo GW, addr is in host byte order, +* Determining the default GW on Android 5.0+ is non trivial +* and serves almost no purpose since OpenVPN only uses the +* default GW address to add routes for networks that should +* NOT be routed over the VPN. Using a well known address +* (127.'d'.'g'.'w') for the default GW make detecting +* these routes easier from the controlling app. +*/ + rgi->gateway.addr =127 <<24 |'d' <<16 |'g' <<8 |'w' ; + rgi->flags |=RGI_ADDR_DEFINED ; +strcpy (best_name,"android-gw" ); +#endif /* scan adapter list */ if (rgi->flags &RGI_ADDR_DEFINED )
Signature · 1 line
2.3.2 (Apple Git-55)
[Openvpn-devel] [PATCH applied] Re: Use pseudo gw as default gw on Android as a workaround for not being able to read /proc/net/route
ACK. To be expected :-) - and why bother creating error messages when the VPN API does not need this information anyway.
I wondered why the part after " /* scan adapter list */" is still
active, but this is about "which locally connected networks exist?" (--redirect-gateway block-local), so that's still useful.
Your patch has been applied to the master branch.
commit 429f0560e3a908ffa00f18ba1a81af03ba05751e
Author: Arne Schwabe Date: Tue Sep 15 11:23:35 2015 +0200
Use pseudo gw as default gw on Android as a workaround for not being able to read /proc/net/route
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10111
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 5/8 Fix loglevel of protect socket message
In reply to Arne Schwabe--- src/openvpn/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/openvpn/socket.c +2 -2
@@ -898,11 +898,11 @@ static void protect_fd_nonlocal (int fd, const struct sockaddr* addr)* as "protected socket" (exempt from being routed into tunnel) */ if (addr_local (addr)) { -msg (M_DEBUG ,"Address is local, not protecting socket fd %d" , fd); +msg (D_SOCKET_DEBUG ,"Address is local, not protecting socket fd %d" , fd);return ; } -msg (M_DEBUG ,"Protecting socket fd %d" , fd); +msg (D_SOCKET_DEBUG ,"Protecting socket fd %d" , fd); management->connection.fdtosend = fd;management_android_control (management,"PROTECTFD" , __func__); }
Signature · 1 line
2.3.2 (Apple Git-55)
[Openvpn-devel] [PATCH applied] Re: Fix loglevel of protect socket message
ACK. Makes sense, and TARGET_ANDROID anyway...
Your patch has been applied to the master branch.
commit acd487d0f3597e67f451aa23b73ad03dc19842b0
Author: Arne Schwabe Date: Tue Sep 15 11:23:36 2015 +0200
Fix loglevel of protect socket message
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10112
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 6/8 Extend network-change command to allow reprotecting on the same network (for short connection losses)
In reply to Arne Schwabe--- src/openvpn/init.c | 6 +++--- src/openvpn/manage.c | 11 ++++++++--- src/openvpn/manage.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-)
src/openvpn/init.c +3 -3
@@ -3160,14 +3160,14 @@ management_show_net_callback (void *arg, const int msglevel)#ifdef TARGET_ANDROID int -managmenet_callback_network_change (void *arg) +managmenet_callback_network_change (void *arg,bool samenetwork) {/* Check if the client should translate the network change to a SIGUSR1 to reestablish the connection or just reprotect the socket At the moment just assume that, for all settings that use pull (not --static) and are not using peer-id reestablishing the connection is -required +required (unless the network is the same) The function returns -1 on invalid fd and -2 if the socket cannot be reused. On the -2 return value the man_network_change function triggers
@@ -3182,7 +3182,7 @@ managmenet_callback_network_change (void *arg)return -1 ; socketfd = c->c2.link_socket->sd; -if (!c->options.pull || c->c2.tls_multi->use_peer_id) +if (!c->options.pull || c->c2.tls_multi->use_peer_id || samenetwork)return socketfd;else return -2 ;
src/openvpn/manage.c +8 -3
@@ -1129,7 +1129,7 @@ man_remote (struct management *man, const char **p)#ifdef TARGET_ANDROID static void -man_network_change (struct management *man) +man_network_change (struct management *man,bool samenetwork) {/* Called to signal the OpenVPN that the network configuration has changed and the client should either float or reconnect.
@@ -1138,7 +1138,8 @@ man_network_change (struct management *man)*/ if (man->persist.callback.network_change) { -int fd = (*man->persist.callback.network_change)(man->persist.callback.arg); +int fd = (*man->persist.callback.network_change) + (man->persist.callback.arg, samenetwork); man->connection.fdtosend = fd;msg (M_CLIENT ,"PROTECTFD: fd '%d' sent to be protected" , fd);if (fd ==-2 )
@@ -1193,7 +1194,11 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch#ifdef TARGET_ANDROID else if (streq (p[0], "network-change")) { -man_network_change (man); +bool samenetwork = false; +if (p[1 ] &&streq (p[1 ],"samenetwork" )) + samenetwork = true; + +man_network_change (man, samenetwork); }#endif else if (streq (p[0], "load-stats"))
src/openvpn/manage.h +1 -1
@@ -174,7 +174,7 @@ struct management_callbackbool (*proxy_cmd) (void *arg,const char **p);bool (*remote_cmd) (void *arg,const char **p);#ifdef TARGET_ANDROID -int (*network_change) (void *arg); +int (*network_change) (void *arg,bool samenetwork);#endif };
Signature · 1 line
2.3.2 (Apple Git-55)
[Openvpn-devel] [PATCH applied] Re: Extend network-change command to allow reprotecting on the same network (for short connection losses)
ACK. Android specific, no obvious code issues.
Taking the "management <-> managmenet" typo of 1/8 into account.
Your patch has been applied to the master branch.
commit d967ec289df5c5196f68a3708a9f36a5ba354833
Author: Arne Schwabe Date: Tue Sep 15 11:23:37 2015 +0200
Extend network-change command to allow reprotecting on the same network (for short connection losses)
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10106
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 7/8 Remove unused function h_errno_msg
In reply to Arne Schwabe--- src/openvpn/socket.c | 17 ----------------- 1 file changed, 17 deletions(-)
src/openvpn/socket.c +0 -17
@@ -71,23 +71,6 @@ sf2gaf(const unsigned int getaddr_flags,* Functions related to the translation of DNS names to IP addresses. */ -static const char * -h_errno_msg (int h_errno_err) -{ -switch (h_errno_err) - { -case HOST_NOT_FOUND : -return "[HOST_NOT_FOUND] The specified host is unknown." ; -case NO_DATA : -return "[NO_DATA] The requested name is valid but does not have an IP address." ; -case NO_RECOVERY : -return "[NO_RECOVERY] A non-recoverable name server error occurred." ; -case TRY_AGAIN : -return "[TRY_AGAIN] A temporary error occurred on an authoritative name server." ; - } -return "[unknown h_errno value]" ; -} -/* * Translate IP addr or hostname to in_addr_t. * If resolve error, try again for
Signature · 1 line
2.3.2 (Apple Git-55)
[Openvpn-devel] [PATCH applied] Re: Remove unused function h_errno_msg
ACK, this was an easy one :-)
Your patch has been applied to the master branch.
commit 1d11134feee33689904ded0c6a0108e865d17d7e
Author: Arne Schwabe Date: Tue Sep 15 11:23:38 2015 +0200
Remove unused function h_errno_msg
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10108
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 8/8 Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
In reply to Arne SchwabeWith this change all timeouts before the first packet from the OpenVPN server are unified into the server-poll-timeout option.
Also make connect-timeout and server-poll-timeout aliases. The old connect-timeout handling the tcp timeout now also uses the same timeout.
The default of 120s has been chosen to be a safe value is larger as it is larger the sums of the old small timeouts.
--- doc/openvpn.8 | 33 ++++++++------------------------- src/openvpn/forward-inline.h | 2 +- src/openvpn/forward.c | 7 +++++++ src/openvpn/forward.h | 2 +- src/openvpn/init.c | 33 +++++++++++++++++---------------- src/openvpn/interval.h | 9 +++++++++ src/openvpn/openvpn.h | 6 ++++-- src/openvpn/options.c | 38 +++++++------------------------------- src/openvpn/options.h | 3 --- src/openvpn/proxy.c | 22 ++++++++++++++-------- src/openvpn/proxy.h | 2 +- src/openvpn/socket.c | 10 ++++++---- src/openvpn/socket.h | 7 +++++-- 13 files changed, 80 insertions(+), 94 deletions(-)
doc/openvpn.8 +8 -25
@@ -354,11 +354,10 @@ block: .B explicit\-exit\-notify, .B float, .B fragment, -.B http\-proxy, -.B http\-proxy\-option, -.B http\-proxy\-retry, -.B http\-proxy\-timeout, -.B link\-mtu, +.B http-proxy, +.B http-proxy-option, +.B http-proxy-retry, +.B link-mtu, .B local, .B lport, .B mssfix,
@@ -473,14 +472,6 @@ Wait seconds between connection attempts (default=5). .\"********************************************************* .TP -.B \-\-connect\-timeout n -For -.B \-\-proto tcp\-client, -set connection timeout to -.B n -seconds (default=10). -.\"********************************************************* -.TP .B \-\-connect\-retry\-max n .B n specifies the number of times all
@@ -538,12 +529,6 @@ Retry indefinitely on HTTP proxy errors. If an HTTP proxy error occurs, simulate a SIGUSR1 reset. .\"********************************************************* .TP -.B \-\-http\-proxy\-timeout n -Set proxy timeout to -.B n -seconds, default=5. -.\"********************************************************* -.TP .B \-\-http\-proxy\-option type [parm] Set extended HTTP proxy options. Repeat to set multiple options.
@@ -3800,14 +3785,12 @@ description of the OpenVPN challenge/response protocol. .\"********************************************************* .TP .B \-\-server\-poll\-timeout n -when polling possible remote servers to connect to -in a round-robin fashion, spend no more than +.B \-\-connect\-timeout n +when connecting to a remote server do not wait for more than .B n seconds waiting for a response before trying the next server. -As this only makes sense in client-to-server setups, it cannot -be used in point-to-point setups using -.B \-\-secret -symmetrical key mode. +The default value is 120s. This timeout includes proxy and TCP +connect timeouts. .\"********************************************************* .TP .B \-\-explicit\-exit\-notify [n]
src/openvpn/forward-inline.h +1 -1
@@ -125,7 +125,7 @@ check_server_poll_timeout (struct context *c) {void check_server_poll_timeout_dowork (struct context *c); -if (c->options.server_poll_timeout +if (c->options.ce.connect_timeout &&event_timeout_trigger (&c->c2.server_poll_interval, &c->c2.timeval,ETT_DEFAULT ))check_server_poll_timeout_dowork (c); }
src/openvpn/forward.c +7 -0
@@ -322,6 +322,13 @@ check_inactivity_timeout_dowork (struct context *c)register_signal (c,SIGTERM ,"inactive" ); } +int +get_server_poll_remaining_time (struct event_timeout * server_poll_timeout) +{ +update_time (); +int remaining =event_timeout_remaining (server_poll_timeout); +return max_int (0 , remaining); +}#if P2MP void
src/openvpn/forward.h +1 -1
@@ -103,7 +103,7 @@ void show_wait_status (struct context *c);* once for each remaining fragment with this parameter set to false. */ void encrypt_sign (struct context *c,bool comp_frag); - +int get_server_poll_remaining_time (struct event_timeout * server_poll_timeout);/**********************************************************************/ /**
src/openvpn/init.c +17 -16
@@ -1050,6 +1050,19 @@ reset_coarse_timers (struct context *c) }/* +* Initialize the server poll timeout timer +* Thie timer is used in the http/socks proxy setup so it needs to be setup +* before +*/ +static void +do_init_server_poll_timer (struct context *c) +{ +update_time (); +if (c->options.ce.connect_timeout) +event_timeout_init (&c->c2.server_poll_interval, c->options.ce.connect_timeout, now); +} + +/* * Initialize timers */ static void
@@ -1070,11 +1083,6 @@ do_init_timers (struct context *c, bool deferred)if (c->options.ping_rec_timeout)event_timeout_init (&c->c2.ping_rec_interval, c->options.ping_rec_timeout, now); -#if P2MP -if (c->options.server_poll_timeout) -event_timeout_init (&c->c2.server_poll_interval, c->options.server_poll_timeout, now); -#endif -if (!deferred) {/* initialize connection establishment timer */
@@ -1859,11 +1867,6 @@ socket_restart_pause (struct context *c)#if P2MP if (auth_retry_get () ==AR_NOINTERACT ) sec =10 ; - -#if 0 /* not really needed because of c->persist.restart_sleep_seconds */ -if (c->options.server_poll_timeout && sec >1 ) - sec =1 ; -#endif #endif if (c->persist.restart_sleep_seconds >0 && c->persist.restart_sleep_seconds > sec)
@@ -2519,11 +2522,6 @@ do_option_warnings (struct context *c)msg (M_WARN ,"WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info." );#endif -#ifndef CONNECT_NONBLOCK -if (o->ce.connect_timeout_defined) -msg (M_WARN ,"NOTE: --connect-timeout option is not supported on this OS" ); -#endif -/* If a script is used, print appropiate warnings */ if (o->user_script_used) {
@@ -2678,11 +2676,11 @@ do_init_socket_1 (struct context *c, const int mode) c->options.ipchange, c->plugins, c->options.resolve_retry_seconds, - c->options.ce.connect_timeout, c->options.ce.mtu_discover_type, c->options.rcvbuf, c->options.sndbuf, c->options.mark, + &c->c2.server_poll_interval, sockflags); }
@@ -3510,6 +3508,9 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int*/ do_uid_gid_chroot (c, c->c2.did_open_tun); +/* initialse connect timeout timer */ +do_init_server_poll_timer (c); +/* finalize the TCP/UDP socket */ if (c->mode ==CM_P2P || c->mode ==CM_TOP || c->mode ==CM_CHILD_TCP )do_init_socket_2 (c);
src/openvpn/interval.h +9 -0
@@ -186,6 +186,15 @@ event_timeout_modify_wakeup (struct event_timeout* et, interval_t n) }/* +* Will return the time left for a timeout, this function does not check +* if the timeout is actually valid +*/ +static inline interval_t event_timeout_remaining (struct event_timeout * et) +{ +return (int ) et->last + et->n - now; +} + +/* * This is the principal function for testing and triggering recurring * timers and will return true on a timer signal event. * If et_const_retry == ETT_DEFAULT and a signal occurs,
src/openvpn/openvpn.h +4 -2
@@ -413,6 +413,10 @@ struct context_2time_t update_timeout_random_component;struct timeval timeout_random_component; +/* Timer for everything up to the first packet from the *OpenVPN* server +* socks, http proxy, and tcp packets do not count */ +struct event_timeout server_poll_interval; +/* indicates that the do_up_delay function has run */ bool do_up_ran;
@@ -465,8 +469,6 @@ struct context_2md_ctx_t pulled_options_state;struct md5_digest pulled_options_digest; -struct event_timeout server_poll_interval; -struct event_timeout scheduled_exit;int scheduled_exit_signal;#endif
src/openvpn/options.c +7 -31
@@ -128,7 +128,6 @@ static const char usage_message[] =" p = udp6, tcp6-server, or tcp6-client (ipv6)\n" "--connect-retry n : For --proto tcp-client, number of seconds to wait\n" " between connection retries (default=%d).\n" -"--connect-timeout n : For --proto tcp-client, connection timeout (in seconds).\n" "--connect-retry-max n : Maximum connection attempt retries, default infinite.\n" "--http-proxy s p [up] [auth] : Connect to remote host\n" " through an HTTP proxy at address s and port p.\n"
@@ -140,7 +139,6 @@ static const char usage_message[] =" determine auth method and query for username/password\n" " if needed. auto-nct disables weak proxy auth methods.\n" "--http-proxy-retry : Retry indefinitely on HTTP proxy errors.\n" -"--http-proxy-timeout n : Proxy timeout in seconds, default=5.\n" "--http-proxy-option type [parm] : Set extended HTTP proxy options.\n" " Repeat to set multiple options.\n" " VERSION version (default=1.0)\n"
@@ -488,7 +486,7 @@ static const char usage_message[] =" none (default), interact, or nointeract.\n" "--static-challenge t e : Enable static challenge/response protocol using\n" " challenge text t, with e indicating echo flag (0|1)\n" -"--server-poll-timeout n : when polling possible remote servers to connect to\n" +"--connect-timeout n : when polling possible remote servers to connect to\n" " in a round-robin fashion, spend no more than n seconds\n" " waiting for a response before trying the next server.\n"#endif
@@ -758,7 +756,7 @@ init_options (struct options *o, const bool init_gc) o->ce.af =AF_UNSPEC ; o->ce.bind_ipv6_only = false; o->ce.connect_retry_seconds =5 ; - o->ce.connect_timeout =10 ; + o->ce.connect_timeout =120 ; o->connect_retry_max =0 ; o->ce.local_port = o->ce.remote_port =OPENVPN_PORT ; o->verbosity =1 ;
@@ -813,7 +811,6 @@ init_options (struct options *o, const bool init_gc)#endif #if P2MP o->scheduled_exit_interval =5 ; - o->server_poll_timeout =0 ;#endif #ifdef ENABLE_CRYPTO o->ciphername ="BF-CBC" ;
@@ -1276,7 +1273,6 @@ show_http_proxy_options (const struct http_proxy_options *o)SHOW_STR (auth_method_string);SHOW_STR (auth_file);SHOW_BOOL (retry); -SHOW_INT (timeout);SHOW_STR (http_version);SHOW_STR (user_agent);for (i=0 ; i <MAX_CUSTOM_HTTP_HEADER && o->custom_headers[i].name;i++)
@@ -1680,7 +1676,6 @@ parse_http_proxy_override (const char *server, ho->server =string_alloc (server, gc); ho->port = port; ho->retry = true; - ho->timeout =5 ;if (flags && !strcmp (flags,"nct" )) ho->auth_retry =PAR_NCT ;else
@@ -1849,13 +1844,6 @@ options_postprocess_verify_ce (const struct options *options, const struct connemsg (M_USAGE ,"--lladdr can only be used in --dev tap mode" );/* -* Sanity check on TCP mode options -*/ -if (ce->connect_timeout_defined && ce->proto !=PROTO_TCP_CLIENT ) -msg (M_USAGE ,"--connect-timeout doesn't make sense unless also used with " -"--proto tcp-client or tcp6-client" ); - -/* * Sanity check on MTU parameters */ if (options->ce.tun_mtu_defined && options->ce.link_mtu_defined)
@@ -2303,9 +2291,6 @@ options_postprocess_verify_ce (const struct options *options, const struct conneMUST_BE_UNDEF (pkcs11_id);MUST_BE_UNDEF (pkcs11_id_management);#endif -#if P2MP -MUST_BE_UNDEF (server_poll_timeout); -#endif if (pull)msg (M_USAGE , err,"--pull" );
@@ -4577,11 +4562,11 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); options->ce.connect_retry_seconds =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"connect-timeout" ) && p[1 ] && !p[2 ]) +else if ((streq (p[0 ],"connect-timeout" ) ||streq (p[0 ],"server-poll-timeout" )) + && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); options->ce.connect_timeout =positive_atoi (p[1 ]); - options->ce.connect_timeout_defined = true; }else if (streq (p[0 ],"connect-retry-max" ) && p[1 ] && !p[2 ]) {
@@ -5074,11 +5059,9 @@ add_option (struct options *options, }else if (streq (p[0 ],"http-proxy-timeout" ) && p[1 ] && !p[2 ]) { -struct http_proxy_options *ho; -VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); - ho =init_http_proxy_options_once (&options->ce.http_proxy_options, &options->gc); - ho->timeout =positive_atoi (p[1 ]); +msg (M_WARN ,"DEPRECATED OPTION: http-proxy-timeout: In OpenVPN 2.4 the timeout until a connection to a " +"server is established is managed with a single timeout set by connect-timeout" ); }else if (streq (p[0 ],"http-proxy-option" ) && p[1 ] && !p[4 ]) {
@@ -5392,12 +5375,10 @@ add_option (struct options *options, options->push_peer_info = true; }#endif -#if P2MP else if (streq (p[1], "SERVER_POLL_TIMEOUT") && p[2]) { - options->server_poll_timeout =positive_atoi (p[2 ]); + options->ce.connect_timeout =positive_atoi (p[2 ]); } -#endif else {if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" ))
@@ -5911,11 +5892,6 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_PULL_MODE ); options->push_continuation =atoi (p[1 ]); } -else if (streq (p[0 ],"server-poll-timeout" ) && p[1 ] && !p[2 ]) - { -VERIFY_PERMISSION (OPT_P_GENERAL ); - options->server_poll_timeout =positive_atoi (p[1 ]); - }else if (streq (p[0 ],"auth-user-pass" ) && !p[2 ]) {VERIFY_PERMISSION (OPT_P_GENERAL );
src/openvpn/options.h +0 -3
@@ -97,7 +97,6 @@ struct connection_entrybool bind_local;int connect_retry_seconds;int connect_timeout; -bool connect_timeout_defined;struct http_proxy_options *http_proxy_options;const char *socks_proxy_server;const char *socks_proxy_port;
@@ -459,8 +458,6 @@ struct optionsconst char *auth_user_pass_file;struct options_pre_pull *pre_pull; -int server_poll_timeout; -int scheduled_exit_interval;#ifdef ENABLE_CLIENT_CR
src/openvpn/proxy.c +14 -8
@@ -41,6 +41,7 @@#include "httpdigest.h" #include "ntlm.h" #include "memdbg.h" +#include "forward.h" #define UP_TYPE_PROXY "HTTP Proxy"
@@ -52,7 +53,6 @@ init_http_proxy_options_once (struct http_proxy_options **hpo, { ALLOC_OBJ_CLEAR_GC (*hpo, struct http_proxy_options, gc);/* http proxy defaults */ - (*hpo)->timeout =5 ; (*hpo)->http_version ="1.0" ; }return *hpo;
@@ -93,6 +93,7 @@ recv_line (socket_descriptor_t sd,FD_ZERO (&reads);FD_SET (sd, &reads); + tv.tv_sec = timeout_sec; tv.tv_usec =0 ;
@@ -255,6 +256,8 @@ clear_user_pass_http (void)purge_user_pass (&static_proxy_user_pass, true); } +#if 0 +/* function only used in #if 0 debug statement */ static void dump_residual (socket_descriptor_t sd, int timeout,
@@ -269,6 +272,7 @@ dump_residual (socket_descriptor_t sd, msg (D_PROXY, "PROXY HEADER: '%s'", buf); } } +#endif /* * Extract the Proxy-Authenticate header from the stream.
@@ -552,6 +556,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,socket_descriptor_t sd,/* already open to proxy */ const char *host, /* openvpn server remote */ const char *port, /* openvpn server port */ + struct event_timeout* server_poll_timeout, struct buffer *lookahead, volatile int *signal_received) {
@@ -633,8 +638,9 @@ establish_http_proxy_passthru (struct http_proxy_info *p,if (!send_crlf (sd)) goto error; +/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -663,7 +669,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,while (true) { -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;chomp (buf);msg (D_PROXY ,"HTTP proxy returned: '%s'" , buf);
@@ -730,7 +736,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p, goto error;/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -838,7 +844,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p, goto error;/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -862,7 +868,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,/* figure out what kind of authentication the proxy needs */ char *pa =NULL ;const int method =get_proxy_authenticate (sd, - p->options.timeout, +get_server_poll_remaining_time (server_poll_timeout), &pa,NULL , signal_received);
@@ -906,7 +912,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,msg (D_LINK_ERRORS ,"HTTP proxy returned bad status" );#if 0 /* DEBUGGING -- show a multi-line HTTP error response */ -dump_residual (sd, p->options.timeout, signal_received); +dump_residual (sd,get_server_poll_remaining_time (server_poll_timeout), signal_received);#endif goto error; }
@@ -914,7 +920,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,/* SUCCESS */ /* receive line from proxy and discard */ -if (!recv_line (sd,NULL ,0 , p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd,NULL ,0 ,get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/*
src/openvpn/proxy.h +1 -1
@@ -46,7 +46,6 @@ struct http_proxy_options {const char *server;const char *port;bool retry; -int timeout;# define PAR_NO 0/* don't support any auth retries */ # define PAR_ALL 1/* allow all proxy auth protocols */
@@ -86,6 +85,7 @@ bool establish_http_proxy_passthru (struct http_proxy_info *p,socket_descriptor_t sd,/* already open to proxy */ const char *host, /* openvpn server remote */ const char *port, /* openvpn server port */ + struct event_timeout* server_poll_timeout, struct buffer *lookahead, volatile int *signal_received);
src/openvpn/socket.c +6 -4
@@ -40,6 +40,7 @@#include "misc.h" #include "manage.h" #include "openvpn.h" +#include "forward.h" #include "memdbg.h"
@@ -1511,11 +1512,11 @@ link_socket_init_phase1 (struct link_socket *sock,const char *ipchange_command, const struct plugin_list *plugins, int resolve_retry_seconds, - int connect_timeout, int mtu_discover_type, int rcvbuf, int sndbuf, int mark, + struct event_timeout* server_poll_timeout, unsigned int sockflags) {ASSERT (sock );
@@ -1530,7 +1531,6 @@ link_socket_init_phase1 (struct link_socket *sock, sock->bind_local = bind_local; sock->inetd = inetd; sock->resolve_retry_seconds = resolve_retry_seconds; - sock->connect_timeout = connect_timeout; sock->mtu_discover_type = mtu_discover_type;#ifdef ENABLE_DEBUG
@@ -1550,6 +1550,7 @@ link_socket_init_phase1 (struct link_socket *sock, sock->info.bind_ipv6_only = bind_ipv6_only; sock->info.ipchange_command = ipchange_command; sock->info.plugins = plugins; + sock->server_poll_timeout = server_poll_timeout; sock->mode = mode;if (mode ==LS_MODE_TCP_ACCEPT_FROM )
@@ -1770,7 +1771,7 @@ phase2_tcp_client (struct link_socket *sock, struct signal_info *sig_info) do { socket_connect (&sock->sd, sock->info.lsa->current_remote->ai_addr, - sock->connect_timeout, + get_server_poll_remaining_time (sock->server_poll_timeout), sig_info); if (sig_info->signal_received)
@@ -1782,6 +1783,7 @@ phase2_tcp_client (struct link_socket *sock, struct signal_info *sig_info) sock->sd, sock->proxy_dest_host, sock->proxy_dest_port, + sock->server_poll_timeout, &sock->stream_buf.residual, &sig_info->signal_received); }
@@ -1808,7 +1810,7 @@ phase2_socks_client (struct link_socket *sock, struct signal_info *sig_info) {socket_connect (&sock->ctrl_sd, sock->info.lsa->current_remote->ai_addr, - sock->connect_timeout, +get_server_poll_remaining_time (sock->server_poll_timeout), sig_info);if (sig_info->signal_received)
src/openvpn/socket.h +5 -2
@@ -205,7 +205,6 @@ struct link_socketint mode;int resolve_retry_seconds; -int connect_timeout;int mtu_discover_type;struct socket_buffer_size socket_buffer_sizes;
@@ -236,6 +235,10 @@ struct link_socketconst char *proxy_dest_host;const char *proxy_dest_port; +/* Pointer to the server-poll to trigger the timeout in function which have +* their own loop instead of using the main oop */ +struct event_timeout * server_poll_timeout; +#if PASSTOS_CAPABILITY /* used to get/set TOS. */ #if defined(TARGET_LINUX )
@@ -324,11 +327,11 @@ link_socket_init_phase1 (struct link_socket *sock,const char *ipchange_command, const struct plugin_list *plugins, int resolve_retry_seconds, - int connect_timeout, int mtu_discover_type, int rcvbuf, int sndbuf, int mark, + struct event_timeout* server_poll_timeout, unsigned int sockflags); void link_socket_init_phase2 (struct link_socket *sock,
Signature · 1 line
2.3.2 (Apple Git-55)
PATCH v2 1/1 Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
With this change all timeouts before the first packet from the OpenVPN server are unified into the server-poll-timeout option.
The default of 120s has been chosen to be a safe value is larger as it is larger the sums of the old small timeouts.
Patch V2: Fix a regression with --static
--- android-config/config.h | 2 +- doc/openvpn.8 | 33 ++++++++------------------------- src/openvpn/forward-inline.h | 2 +- src/openvpn/forward.c | 22 ++++++++++++++++------ src/openvpn/forward.h | 2 +- src/openvpn/init.c | 33 +++++++++++++++++---------------- src/openvpn/interval.h | 9 +++++++++ src/openvpn/openvpn.h | 6 ++++-- src/openvpn/options.c | 38 +++++++------------------------------- src/openvpn/options.h | 3 --- src/openvpn/proxy.c | 22 ++++++++++++++-------- src/openvpn/proxy.h | 2 +- src/openvpn/socket.c | 10 ++++++---- src/openvpn/socket.h | 7 +++++-- 14 files changed, 90 insertions(+), 101 deletions(-)
android-config/config.h +1 -1
@@ -348,7 +348,7 @@#define HAVE_STROPTS_H 1/* Define to 1 if you have the `syslog' function. */ -#define HAVE_SYSLOG 1 +#define HAVE_SYSLOG 1/* Define to 1 if you have the <syslog.h> header file. */ #define HAVE_SYSLOG_H 1
doc/openvpn.8 +8 -25
@@ -354,11 +354,10 @@ block: .B explicit\-exit\-notify, .B float, .B fragment, -.B http\-proxy, -.B http\-proxy\-option, -.B http\-proxy\-retry, -.B http\-proxy\-timeout, -.B link\-mtu, +.B http-proxy, +.B http-proxy-option, +.B http-proxy-retry, +.B link-mtu, .B local, .B lport, .B mssfix,
@@ -473,14 +472,6 @@ Wait seconds between connection attempts (default=5). .\"********************************************************* .TP -.B \-\-connect\-timeout n -For -.B \-\-proto tcp\-client, -set connection timeout to -.B n -seconds (default=10). -.\"********************************************************* -.TP .B \-\-connect\-retry\-max n .B n specifies the number of times all
@@ -538,12 +529,6 @@ Retry indefinitely on HTTP proxy errors. If an HTTP proxy error occurs, simulate a SIGUSR1 reset. .\"********************************************************* .TP -.B \-\-http\-proxy\-timeout n -Set proxy timeout to -.B n -seconds, default=5. -.\"********************************************************* -.TP .B \-\-http\-proxy\-option type [parm] Set extended HTTP proxy options. Repeat to set multiple options.
@@ -3823,14 +3808,12 @@ description of the OpenVPN challenge/response protocol. .\"********************************************************* .TP .B \-\-server\-poll\-timeout n -when polling possible remote servers to connect to -in a round-robin fashion, spend no more than +.B \-\-connect\-timeout n +when connecting to a remote server do not wait for more than .B n seconds waiting for a response before trying the next server. -As this only makes sense in client-to-server setups, it cannot -be used in point-to-point setups using -.B \-\-secret -symmetrical key mode. +The default value is 120s. This timeout includes proxy and TCP +connect timeouts. .\"********************************************************* .TP .B \-\-explicit\-exit\-notify [n]
src/openvpn/forward-inline.h +1 -1
@@ -125,7 +125,7 @@ check_server_poll_timeout (struct context *c) {void check_server_poll_timeout_dowork (struct context *c); -if (c->options.server_poll_timeout +if (c->options.ce.connect_timeout &&event_timeout_trigger (&c->c2.server_poll_interval, &c->c2.timeval,ETT_DEFAULT ))check_server_poll_timeout_dowork (c); }
src/openvpn/forward.c +16 -6
@@ -322,6 +322,13 @@ check_inactivity_timeout_dowork (struct context *c)register_signal (c,SIGTERM ,"inactive" ); } +int +get_server_poll_remaining_time (struct event_timeout * server_poll_timeout) +{ +update_time (); +int remaining =event_timeout_remaining (server_poll_timeout); +return max_int (0 , remaining); +}#if P2MP void
@@ -533,13 +540,16 @@ process_coarse_timers (struct context *c)return ;#if P2MP -check_server_poll_timeout (c); -if (c->sig->signal_received) -return ; +if (c->c2.tls_multi) + { +check_server_poll_timeout (c); +if (c->sig->signal_received) +return ; -check_scheduled_exit (c); -if (c->sig->signal_received) -return ; +check_scheduled_exit (c); +if (c->sig->signal_received) +return ; + }#endif #ifdef ENABLE_OCC
src/openvpn/forward.h +1 -1
@@ -103,7 +103,7 @@ void show_wait_status (struct context *c);* once for each remaining fragment with this parameter set to false. */ void encrypt_sign (struct context *c,bool comp_frag); - +int get_server_poll_remaining_time (struct event_timeout * server_poll_timeout);/**********************************************************************/ /**
src/openvpn/init.c +17 -16
@@ -1052,6 +1052,19 @@ reset_coarse_timers (struct context *c) }/* +* Initialize the server poll timeout timer +* Thie timer is used in the http/socks proxy setup so it needs to be setup +* before +*/ +static void +do_init_server_poll_timer (struct context *c) +{ +update_time (); +if (c->options.ce.connect_timeout) +event_timeout_init (&c->c2.server_poll_interval, c->options.ce.connect_timeout, now); +} + +/* * Initialize timers */ static void
@@ -1072,11 +1085,6 @@ do_init_timers (struct context *c, bool deferred)if (c->options.ping_rec_timeout)event_timeout_init (&c->c2.ping_rec_interval, c->options.ping_rec_timeout, now); -#if P2MP -if (c->options.server_poll_timeout) -event_timeout_init (&c->c2.server_poll_interval, c->options.server_poll_timeout, now); -#endif -if (!deferred) {/* initialize connection establishment timer */
@@ -1878,11 +1886,6 @@ socket_restart_pause (struct context *c)#if P2MP if (auth_retry_get () ==AR_NOINTERACT ) sec =10 ; - -#if 0 /* not really needed because of c->persist.restart_sleep_seconds */ -if (c->options.server_poll_timeout && sec >1 ) - sec =1 ; -#endif #endif if (c->persist.restart_sleep_seconds >0 && c->persist.restart_sleep_seconds > sec)
@@ -2554,11 +2557,6 @@ do_option_warnings (struct context *c)msg (M_WARN ,"WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info." );#endif -#ifndef CONNECT_NONBLOCK -if (o->ce.connect_timeout_defined) -msg (M_WARN ,"NOTE: --connect-timeout option is not supported on this OS" ); -#endif -/* If a script is used, print appropiate warnings */ if (o->user_script_used) {
@@ -2713,11 +2711,11 @@ do_init_socket_1 (struct context *c, const int mode) c->options.ipchange, c->plugins, c->options.resolve_retry_seconds, - c->options.ce.connect_timeout, c->options.ce.mtu_discover_type, c->options.rcvbuf, c->options.sndbuf, c->options.mark, + &c->c2.server_poll_interval, sockflags); }
@@ -3545,6 +3543,9 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int*/ do_uid_gid_chroot (c, c->c2.did_open_tun); +/* initialse connect timeout timer */ +do_init_server_poll_timer (c); +/* finalize the TCP/UDP socket */ if (c->mode ==CM_P2P || c->mode ==CM_TOP || c->mode ==CM_CHILD_TCP )do_init_socket_2 (c);
src/openvpn/interval.h +9 -0
@@ -186,6 +186,15 @@ event_timeout_modify_wakeup (struct event_timeout* et, interval_t n) }/* +* Will return the time left for a timeout, this function does not check +* if the timeout is actually valid +*/ +static inline interval_t event_timeout_remaining (struct event_timeout * et) +{ +return (int ) et->last + et->n - now; +} + +/* * This is the principal function for testing and triggering recurring * timers and will return true on a timer signal event. * If et_const_retry == ETT_DEFAULT and a signal occurs,
src/openvpn/openvpn.h +4 -2
@@ -416,6 +416,10 @@ struct context_2time_t update_timeout_random_component;struct timeval timeout_random_component; +/* Timer for everything up to the first packet from the *OpenVPN* server +* socks, http proxy, and tcp packets do not count */ +struct event_timeout server_poll_interval; +/* indicates that the do_up_delay function has run */ bool do_up_ran;
@@ -471,8 +475,6 @@ struct context_2md_ctx_t pulled_options_state;struct md5_digest pulled_options_digest; -struct event_timeout server_poll_interval; -struct event_timeout scheduled_exit;int scheduled_exit_signal;#endif
src/openvpn/options.c +7 -31
@@ -125,7 +125,6 @@ static const char usage_message[] =" p = udp6, tcp6-server, or tcp6-client (ipv6)\n" "--connect-retry n : For --proto tcp-client, number of seconds to wait\n" " between connection retries (default=%d).\n" -"--connect-timeout n : For --proto tcp-client, connection timeout (in seconds).\n" "--connect-retry-max n : Maximum connection attempt retries, default infinite.\n" "--http-proxy s p [up] [auth] : Connect to remote host\n" " through an HTTP proxy at address s and port p.\n"
@@ -137,7 +136,6 @@ static const char usage_message[] =" determine auth method and query for username/password\n" " if needed. auto-nct disables weak proxy auth methods.\n" "--http-proxy-retry : Retry indefinitely on HTTP proxy errors.\n" -"--http-proxy-timeout n : Proxy timeout in seconds, default=5.\n" "--http-proxy-option type [parm] : Set extended HTTP proxy options.\n" " Repeat to set multiple options.\n" " VERSION version (default=1.0)\n"
@@ -485,7 +483,7 @@ static const char usage_message[] =" none (default), interact, or nointeract.\n" "--static-challenge t e : Enable static challenge/response protocol using\n" " challenge text t, with e indicating echo flag (0|1)\n" -"--server-poll-timeout n : when polling possible remote servers to connect to\n" +"--connect-timeout n : when polling possible remote servers to connect to\n" " in a round-robin fashion, spend no more than n seconds\n" " waiting for a response before trying the next server.\n"#endif
@@ -759,7 +757,7 @@ init_options (struct options *o, const bool init_gc) o->ce.af =AF_UNSPEC ; o->ce.bind_ipv6_only = false; o->ce.connect_retry_seconds =5 ; - o->ce.connect_timeout =10 ; + o->ce.connect_timeout =120 ; o->connect_retry_max =0 ; o->ce.local_port = o->ce.remote_port =OPENVPN_PORT ; o->verbosity =1 ;
@@ -814,7 +812,6 @@ init_options (struct options *o, const bool init_gc)#endif #if P2MP o->scheduled_exit_interval =5 ; - o->server_poll_timeout =0 ;#endif #ifdef ENABLE_CRYPTO o->ciphername ="BF-CBC" ;
@@ -1277,7 +1274,6 @@ show_http_proxy_options (const struct http_proxy_options *o)SHOW_STR (auth_method_string);SHOW_STR (auth_file);SHOW_BOOL (retry); -SHOW_INT (timeout);SHOW_STR (http_version);SHOW_STR (user_agent);for (i=0 ; i <MAX_CUSTOM_HTTP_HEADER && o->custom_headers[i].name;i++)
@@ -1681,7 +1677,6 @@ parse_http_proxy_override (const char *server, ho->server =string_alloc (server, gc); ho->port = port; ho->retry = true; - ho->timeout =5 ;if (flags && !strcmp (flags,"nct" )) ho->auth_retry =PAR_NCT ;else
@@ -1850,13 +1845,6 @@ options_postprocess_verify_ce (const struct options *options, const struct connemsg (M_USAGE ,"--lladdr can only be used in --dev tap mode" );/* -* Sanity check on TCP mode options -*/ -if (ce->connect_timeout_defined && ce->proto !=PROTO_TCP_CLIENT ) -msg (M_USAGE ,"--connect-timeout doesn't make sense unless also used with " -"--proto tcp-client or tcp6-client" ); - -/* * Sanity check on MTU parameters */ if (options->ce.tun_mtu_defined && options->ce.link_mtu_defined)
@@ -2304,9 +2292,6 @@ options_postprocess_verify_ce (const struct options *options, const struct conneMUST_BE_UNDEF (pkcs11_id);MUST_BE_UNDEF (pkcs11_id_management);#endif -#if P2MP -MUST_BE_UNDEF (server_poll_timeout); -#endif if (pull)msg (M_USAGE , err,"--pull" );
@@ -4586,11 +4571,11 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); options->ce.connect_retry_seconds =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"connect-timeout" ) && p[1 ] && !p[2 ]) +else if ((streq (p[0 ],"connect-timeout" ) ||streq (p[0 ],"server-poll-timeout" )) + && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); options->ce.connect_timeout =positive_atoi (p[1 ]); - options->ce.connect_timeout_defined = true; }else if (streq (p[0 ],"connect-retry-max" ) && p[1 ] && !p[2 ]) {
@@ -5083,11 +5068,9 @@ add_option (struct options *options, }else if (streq (p[0 ],"http-proxy-timeout" ) && p[1 ] && !p[2 ]) { -struct http_proxy_options *ho; -VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); - ho =init_http_proxy_options_once (&options->ce.http_proxy_options, &options->gc); - ho->timeout =positive_atoi (p[1 ]); +msg (M_WARN ,"DEPRECATED OPTION: http-proxy-timeout: In OpenVPN 2.4 the timeout until a connection to a " +"server is established is managed with a single timeout set by connect-timeout" ); }else if (streq (p[0 ],"http-proxy-option" ) && p[1 ] && !p[4 ]) {
@@ -5408,12 +5391,10 @@ add_option (struct options *options, options->push_peer_info = true; }#endif -#if P2MP else if (streq (p[1], "SERVER_POLL_TIMEOUT") && p[2]) { - options->server_poll_timeout =positive_atoi (p[2 ]); + options->ce.connect_timeout =positive_atoi (p[2 ]); } -#endif else {if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" ))
@@ -5927,11 +5908,6 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_PULL_MODE ); options->push_continuation =atoi (p[1 ]); } -else if (streq (p[0 ],"server-poll-timeout" ) && p[1 ] && !p[2 ]) - { -VERIFY_PERMISSION (OPT_P_GENERAL ); - options->server_poll_timeout =positive_atoi (p[1 ]); - }else if (streq (p[0 ],"auth-user-pass" ) && !p[2 ]) {VERIFY_PERMISSION (OPT_P_GENERAL );
src/openvpn/options.h +0 -3
@@ -97,7 +97,6 @@ struct connection_entrybool bind_local;int connect_retry_seconds;int connect_timeout; -bool connect_timeout_defined;struct http_proxy_options *http_proxy_options;const char *socks_proxy_server;const char *socks_proxy_port;
@@ -459,8 +458,6 @@ struct optionsconst char *auth_user_pass_file;struct options_pre_pull *pre_pull; -int server_poll_timeout; -int scheduled_exit_interval;#ifdef ENABLE_CLIENT_CR
src/openvpn/proxy.c +14 -8
@@ -41,6 +41,7 @@#include "httpdigest.h" #include "ntlm.h" #include "memdbg.h" +#include "forward.h" #define UP_TYPE_PROXY "HTTP Proxy"
@@ -52,7 +53,6 @@ init_http_proxy_options_once (struct http_proxy_options **hpo, { ALLOC_OBJ_CLEAR_GC (*hpo, struct http_proxy_options, gc);/* http proxy defaults */ - (*hpo)->timeout =5 ; (*hpo)->http_version ="1.0" ; }return *hpo;
@@ -93,6 +93,7 @@ recv_line (socket_descriptor_t sd,FD_ZERO (&reads);FD_SET (sd, &reads); + tv.tv_sec = timeout_sec; tv.tv_usec =0 ;
@@ -255,6 +256,8 @@ clear_user_pass_http (void)purge_user_pass (&static_proxy_user_pass, true); } +#if 0 +/* function only used in #if 0 debug statement */ static void dump_residual (socket_descriptor_t sd, int timeout,
@@ -269,6 +272,7 @@ dump_residual (socket_descriptor_t sd, msg (D_PROXY, "PROXY HEADER: '%s'", buf); } } +#endif /* * Extract the Proxy-Authenticate header from the stream.
@@ -552,6 +556,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,socket_descriptor_t sd,/* already open to proxy */ const char *host, /* openvpn server remote */ const char *port, /* openvpn server port */ + struct event_timeout* server_poll_timeout, struct buffer *lookahead, volatile int *signal_received) {
@@ -633,8 +638,9 @@ establish_http_proxy_passthru (struct http_proxy_info *p,if (!send_crlf (sd)) goto error; +/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -663,7 +669,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,while (true) { -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;chomp (buf);msg (D_PROXY ,"HTTP proxy returned: '%s'" , buf);
@@ -730,7 +736,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p, goto error;/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -838,7 +844,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p, goto error;/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -862,7 +868,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,/* figure out what kind of authentication the proxy needs */ char *pa =NULL ;const int method =get_proxy_authenticate (sd, - p->options.timeout, +get_server_poll_remaining_time (server_poll_timeout), &pa,NULL , signal_received);
@@ -906,7 +912,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,msg (D_LINK_ERRORS ,"HTTP proxy returned bad status" );#if 0 /* DEBUGGING -- show a multi-line HTTP error response */ -dump_residual (sd, p->options.timeout, signal_received); +dump_residual (sd,get_server_poll_remaining_time (server_poll_timeout), signal_received);#endif goto error; }
@@ -914,7 +920,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,/* SUCCESS */ /* receive line from proxy and discard */ -if (!recv_line (sd,NULL ,0 , p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd,NULL ,0 ,get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/*
src/openvpn/proxy.h +1 -1
@@ -46,7 +46,6 @@ struct http_proxy_options {const char *server;const char *port;bool retry; -int timeout;# define PAR_NO 0/* don't support any auth retries */ # define PAR_ALL 1/* allow all proxy auth protocols */
@@ -86,6 +85,7 @@ bool establish_http_proxy_passthru (struct http_proxy_info *p,socket_descriptor_t sd,/* already open to proxy */ const char *host, /* openvpn server remote */ const char *port, /* openvpn server port */ + struct event_timeout* server_poll_timeout, struct buffer *lookahead, volatile int *signal_received);
src/openvpn/socket.c +6 -4
@@ -40,6 +40,7 @@#include "misc.h" #include "manage.h" #include "openvpn.h" +#include "forward.h" #include "memdbg.h"
@@ -1511,11 +1512,11 @@ link_socket_init_phase1 (struct link_socket *sock,const char *ipchange_command, const struct plugin_list *plugins, int resolve_retry_seconds, - int connect_timeout, int mtu_discover_type, int rcvbuf, int sndbuf, int mark, + struct event_timeout* server_poll_timeout, unsigned int sockflags) {ASSERT (sock );
@@ -1530,7 +1531,6 @@ link_socket_init_phase1 (struct link_socket *sock, sock->bind_local = bind_local; sock->inetd = inetd; sock->resolve_retry_seconds = resolve_retry_seconds; - sock->connect_timeout = connect_timeout; sock->mtu_discover_type = mtu_discover_type;#ifdef ENABLE_DEBUG
@@ -1550,6 +1550,7 @@ link_socket_init_phase1 (struct link_socket *sock, sock->info.bind_ipv6_only = bind_ipv6_only; sock->info.ipchange_command = ipchange_command; sock->info.plugins = plugins; + sock->server_poll_timeout = server_poll_timeout; sock->mode = mode;if (mode ==LS_MODE_TCP_ACCEPT_FROM )
@@ -1770,7 +1771,7 @@ phase2_tcp_client (struct link_socket *sock, struct signal_info *sig_info) do { socket_connect (&sock->sd, sock->info.lsa->current_remote->ai_addr, - sock->connect_timeout, + get_server_poll_remaining_time (sock->server_poll_timeout), sig_info); if (sig_info->signal_received)
@@ -1782,6 +1783,7 @@ phase2_tcp_client (struct link_socket *sock, struct signal_info *sig_info) sock->sd, sock->proxy_dest_host, sock->proxy_dest_port, + sock->server_poll_timeout, &sock->stream_buf.residual, &sig_info->signal_received); }
@@ -1808,7 +1810,7 @@ phase2_socks_client (struct link_socket *sock, struct signal_info *sig_info) {socket_connect (&sock->ctrl_sd, sock->info.lsa->current_remote->ai_addr, - sock->connect_timeout, +get_server_poll_remaining_time (sock->server_poll_timeout), sig_info);if (sig_info->signal_received)
src/openvpn/socket.h +5 -2
@@ -205,7 +205,6 @@ struct link_socketint mode;int resolve_retry_seconds; -int connect_timeout;int mtu_discover_type;struct socket_buffer_size socket_buffer_sizes;
@@ -236,6 +235,10 @@ struct link_socketconst char *proxy_dest_host;const char *proxy_dest_port; +/* Pointer to the server-poll to trigger the timeout in function which have +* their own loop instead of using the main oop */ +struct event_timeout * server_poll_timeout; +#if PASSTOS_CAPABILITY /* used to get/set TOS. */ #if defined(TARGET_LINUX )
@@ -324,11 +327,11 @@ link_socket_init_phase1 (struct link_socket *sock,const char *ipchange_command, const struct plugin_list *plugins, int resolve_retry_seconds, - int connect_timeout, int mtu_discover_type, int rcvbuf, int sndbuf, int mark, + struct event_timeout* server_poll_timeout, unsigned int sockflags); void link_socket_init_phase2 (struct link_socket *sock,
Signature · 1 line
2.3.8 (Apple Git-58)
Re: [Openvpn-devel] [PATCH V2] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Hi,
Quoted 1 line · Arne Schwabe
With this change all timeouts before the first packet from the OpenVPN server are unified into the server-poll-timeout option.
Time to get this done...
Quoted 3 lines
The default of 120s has been chosen to be a safe value is larger as it is larger the sums of the old small timeouts.
Patch V2: Fix a regression with --static
I think I want a v3, due to a few "it has been too long" artifacts in the v2 patch...
android-config/config.h line 354
Quoted 13 lines
android-config/config.h +1
-1@@ -348,7 +348,7 @@#define HAVE_STROPTS_H 1/* Define to 1 if you have the `syslog' function. */ -#define HAVE_SYSLOG 1 +#define HAVE_SYSLOG 1/* Define to 1 if you have the <syslog.h> header file. */ #define HAVE_SYSLOG_H 1
This shouldn't be here...
Quoted 10 lines
doc/openvpn.8 +0
-2@@ -354,11 +354,10 @@ block: .B explicit\-exit\-notify, .B float, .B fragment, -.B http\-proxy, -.B http\-proxy\-option,
doc/openvpn.8 block: · line 363
Quoted 10 lines
doc/openvpn.8 +4
-3-.B http\-proxy\-retry, -.B http\-proxy\-timeout, -.B link\-mtu, +.B http-proxy, +.B http-proxy-option, +.B http-proxy-retry, +.B link-mtu, .B local, .B lport, .B mssfix,
And of these, only the removal of "-.B http\-proxy\-timeout," makes sense, the rest is likely caused by merge/rebase conflicts with Samuli's addition of gratituous "\-" all over openvpn.8 :-)
doc/openvpn.8 process_coarse_timers (struct context *c) · line 544
Quoted 9 lines
doc/openvpn.8 +2
-3@@ -533,13 +540,16 @@ process_coarse_timers (struct context *c) return; #if P2MP - check_server_poll_timeout (c); - if (c->sig->signal_received) - return; + if (c->c2.tls_multi) + {
This check "c2.tls_multi" - is this a short form for "we're not a peer-to-peer session"?
Other parts of the code seem to check "we have --pull or we have --mode server", so I wonder if we should make this somewhat more uninform. Eventually... :-)
[..]
doc/openvpn.8 reset_coarse_timers (struct context *c) · line 1056
Quoted 7 lines
doc/openvpn.8 +3
-0+++ b/src/openvpn/init.c@@ -1052,6 +1052,19 @@ reset_coarse_timers (struct context *c) } /* + * Initialize the server poll timeout timer + * Thie timer is used in the http/socks proxy setup so it needs to be setup
Typo...
doc/openvpn.8 reset_coarse_timers (struct context *c) · line 1065
Quoted 9 lines
doc/openvpn.8 +9
-0+ * before + */ +static void +do_init_server_poll_timer (struct context *c) +{ + update_time (); + if (c->options.ce.connect_timeout) + event_timeout_init (&c->c2.server_poll_interval, c->options.ce.connect_timeout, now); +}
Shouldn't this function be named "do_init_server_poll_time*out*()"?
(But I can see that part of the code speaks about "timer" while all the rest is calling the things "timeout", like "event_timeout_init()"...)
doc/openvpn.8 init_instance (struct context *c, const struct env_set *env, const unsigned int · line 3546
Quoted 5 lines
doc/openvpn.8 +1
-0@@ -3545,6 +3543,9 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int */ do_uid_gid_chroot (c, c->c2.did_open_tun); + /* initialse connect timeout timer */
Typo :)
Quoted 5 lines
doc/openvpn.8 +2
-0+ do_init_server_poll_timer(c); + /* finalize the TCP/UDP socket */ if (c->mode == CM_P2P || c->mode == CM_TOP || c->mode == CM_CHILD_TCP) do_init_socket_2 (c);
[..]
Quoted 2 lines
-#if P2MP
else if (streq (p[1], "SERVER_POLL_TIMEOUT") && p[2])
One just has to love these magic options :)
doc/openvpn.8 establish_http_proxy_passthru (struct http_proxy_info *p, · line 641
Quoted 5 lines
doc/openvpn.8 +1
-0@@ -633,8 +638,9 @@ establish_http_proxy_passthru (struct http_proxy_info *p, if (!send_crlf (sd)) goto error; +
spurious extra empty line... (which leads to "two empty lines" which looks funny, otherwise I wouldn't have complained)
Besides these, the patch looks reasonable - and I assume it has been very very thoroughly tested in those last 8 months, no? ;-)
So - ready to go!
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]...Re: [Openvpn-devel] [PATCH V2] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Am 11.06.16 um 14:10 schrieb Gert Doering:
Quoted 6 lines
This check "c2.tls_multi" - is this a short form for "we're not a peer-to-peer session"?
Other parts of the code seem to check "we have --pull or we have --mode server", so I wonder if we should make this somewhat more uninform. Eventually... :-)
Actually tls session server session. Aka everything but server in p2mp mode.
Quoted 4 lines
Besides these, the patch looks reasonable - and I assume it has been very very thoroughly tested in those last 8 months, no?
Yeah, it is in the ics-openvpn code base for ages.
I will send a v3 shortly.
Arne
PATCH v3 1/1 ] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
With this change all timeouts before the first packet from the OpenVPN server are unified into the server-poll-timeout option.
The default of 120s has been chosen to be a safe value is larger as it is larger the sums of the old small timeouts.
V3: fix some whitespace/typos problems
--- doc/openvpn.8 | 25 ++++--------------------- src/openvpn/forward-inline.h | 2 +- src/openvpn/forward.c | 22 ++++++++++++++++------ src/openvpn/forward.h | 2 +- src/openvpn/init.c | 33 +++++++++++++++++---------------- src/openvpn/interval.h | 9 +++++++++ src/openvpn/openvpn.h | 6 ++++-- src/openvpn/options.c | 38 +++++++------------------------------- src/openvpn/options.h | 3 --- src/openvpn/proxy.c | 20 ++++++++++++-------- src/openvpn/proxy.h | 2 +- src/openvpn/socket.c | 10 ++++++---- src/openvpn/socket.h | 7 +++++-- 13 files changed, 83 insertions(+), 96 deletions(-)
doc/openvpn.8 +4 -21
@@ -357,7 +357,6 @@ block: .B http\-proxy, .B http\-proxy\-option, .B http\-proxy\-retry, -.B http\-proxy\-timeout, .B link\-mtu, .B local, .B lport,
@@ -473,14 +472,6 @@ Wait seconds between connection attempts (default=5). .\"********************************************************* .TP -.B \-\-connect\-timeout n -For -.B \-\-proto tcp\-client, -set connection timeout to -.B n -seconds (default=10). -.\"********************************************************* -.TP .B \-\-connect\-retry\-max n .B n specifies the number of times all
@@ -538,12 +529,6 @@ Retry indefinitely on HTTP proxy errors. If an HTTP proxy error occurs, simulate a SIGUSR1 reset. .\"********************************************************* .TP -.B \-\-http\-proxy\-timeout n -Set proxy timeout to -.B n -seconds, default=5. -.\"********************************************************* -.TP .B \-\-http\-proxy\-option type [parm] Set extended HTTP proxy options. Repeat to set multiple options.
@@ -3976,14 +3961,12 @@ description of the OpenVPN challenge/response protocol. .\"********************************************************* .TP .B \-\-server\-poll\-timeout n -when polling possible remote servers to connect to -in a round-robin fashion, spend no more than +.B \-\-connect\-timeout n +when connecting to a remote server do not wait for more than .B n seconds waiting for a response before trying the next server. -As this only makes sense in client-to-server setups, it cannot -be used in point-to-point setups using -.B \-\-secret -symmetrical key mode. +The default value is 120s. This timeout includes proxy and TCP +connect timeouts. .\"********************************************************* .TP .B \-\-explicit\-exit\-notify [n]
src/openvpn/forward-inline.h +1 -1
@@ -125,7 +125,7 @@ check_server_poll_timeout (struct context *c) {void check_server_poll_timeout_dowork (struct context *c); -if (c->options.server_poll_timeout +if (c->options.ce.connect_timeout &&event_timeout_trigger (&c->c2.server_poll_interval, &c->c2.timeval,ETT_DEFAULT ))check_server_poll_timeout_dowork (c); }
src/openvpn/forward.c +16 -6
@@ -324,6 +324,13 @@ check_inactivity_timeout_dowork (struct context *c)register_signal (c,SIGTERM ,"inactive" ); } +int +get_server_poll_remaining_time (struct event_timeout * server_poll_timeout) +{ +update_time (); +int remaining =event_timeout_remaining (server_poll_timeout); +return max_int (0 , remaining); +}#if P2MP void
@@ -538,13 +545,16 @@ process_coarse_timers (struct context *c)return ;#if P2MP -check_server_poll_timeout (c); -if (c->sig->signal_received) -return ; +if (c->c2.tls_multi) + { +check_server_poll_timeout (c); +if (c->sig->signal_received) +return ; -check_scheduled_exit (c); -if (c->sig->signal_received) -return ; +check_scheduled_exit (c); +if (c->sig->signal_received) +return ; + }#endif #ifdef ENABLE_OCC
src/openvpn/forward.h +1 -1
@@ -103,7 +103,7 @@ void show_wait_status (struct context *c);* once for each remaining fragment with this parameter set to false. */ void encrypt_sign (struct context *c,bool comp_frag); - +int get_server_poll_remaining_time (struct event_timeout * server_poll_timeout);/**********************************************************************/ /**
src/openvpn/init.c +17 -16
@@ -1058,6 +1058,19 @@ reset_coarse_timers (struct context *c) }/* +* Initialise the server poll timeout timer +* This timer is used in the http/socks proxy setup so it needs to be setup +* before +*/ +static void +do_init_server_poll_timeout (struct context *c) +{ +update_time (); +if (c->options.ce.connect_timeout) +event_timeout_init (&c->c2.server_poll_interval, c->options.ce.connect_timeout, now); +} + +/* * Initialize timers */ static void
@@ -1078,11 +1091,6 @@ do_init_timers (struct context *c, bool deferred)if (c->options.ping_rec_timeout)event_timeout_init (&c->c2.ping_rec_interval, c->options.ping_rec_timeout, now); -#if P2MP -if (c->options.server_poll_timeout) -event_timeout_init (&c->c2.server_poll_interval, c->options.server_poll_timeout, now); -#endif -if (!deferred) {/* initialize connection establishment timer */
@@ -1969,11 +1977,6 @@ socket_restart_pause (struct context *c)#if P2MP if (auth_retry_get () ==AR_NOINTERACT ) sec =10 ; - -#if 0 /* not really needed because of c->persist.restart_sleep_seconds */ -if (c->options.server_poll_timeout && sec >1 ) - sec =1 ; -#endif #endif if (c->persist.restart_sleep_seconds >0 && c->persist.restart_sleep_seconds > sec)
@@ -2660,11 +2663,6 @@ do_option_warnings (struct context *c)msg (M_WARN ,"WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info." );#endif -#ifndef CONNECT_NONBLOCK -if (o->ce.connect_timeout_defined) -msg (M_WARN ,"NOTE: --connect-timeout option is not supported on this OS" ); -#endif -/* If a script is used, print appropiate warnings */ if (o->user_script_used) {
@@ -2819,11 +2817,11 @@ do_init_socket_1 (struct context *c, const int mode) c->options.ipchange, c->plugins, c->options.resolve_retry_seconds, - c->options.ce.connect_timeout, c->options.ce.mtu_discover_type, c->options.rcvbuf, c->options.sndbuf, c->options.mark, + &c->c2.server_poll_interval, sockflags); }
@@ -3653,6 +3651,9 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int*/ do_uid_gid_chroot (c, c->c2.did_open_tun); +/* initialise connect timeout timer */ +do_init_server_poll_timeout (c); +/* finalize the TCP/UDP socket */ if (c->mode ==CM_P2P || c->mode ==CM_TOP || c->mode ==CM_CHILD_TCP )do_init_socket_2 (c);
src/openvpn/interval.h +9 -0
@@ -186,6 +186,15 @@ event_timeout_modify_wakeup (struct event_timeout* et, interval_t n) }/* +* Will return the time left for a timeout, this function does not check +* if the timeout is actually valid +*/ +static inline interval_t event_timeout_remaining (struct event_timeout * et) +{ +return (int ) et->last + et->n - now; +} + +/* * This is the principal function for testing and triggering recurring * timers and will return true on a timer signal event. * If et_const_retry == ETT_DEFAULT and a signal occurs,
src/openvpn/openvpn.h +4 -2
@@ -417,6 +417,10 @@ struct context_2time_t update_timeout_random_component;struct timeval timeout_random_component; +/* Timer for everything up to the first packet from the *OpenVPN* server +* socks, http proxy, and tcp packets do not count */ +struct event_timeout server_poll_interval; +/* indicates that the do_up_delay function has run */ bool do_up_ran;
@@ -472,8 +476,6 @@ struct context_2md_ctx_t pulled_options_state;struct md5_digest pulled_options_digest; -struct event_timeout server_poll_interval; -struct event_timeout scheduled_exit;int scheduled_exit_signal;#endif
src/openvpn/options.c +7 -31
@@ -125,7 +125,6 @@ static const char usage_message[] =" p = udp6, tcp6-server, or tcp6-client (ipv6)\n" "--connect-retry n : For --proto tcp-client, number of seconds to wait\n" " between connection retries (default=%d).\n" -"--connect-timeout n : For --proto tcp-client, connection timeout (in seconds).\n" "--connect-retry-max n : Maximum connection attempt retries, default infinite.\n" "--http-proxy s p [up] [auth] : Connect to remote host\n" " through an HTTP proxy at address s and port p.\n"
@@ -137,7 +136,6 @@ static const char usage_message[] =" determine auth method and query for username/password\n" " if needed. auto-nct disables weak proxy auth methods.\n" "--http-proxy-retry : Retry indefinitely on HTTP proxy errors.\n" -"--http-proxy-timeout n : Proxy timeout in seconds, default=5.\n" "--http-proxy-option type [parm] : Set extended HTTP proxy options.\n" " Repeat to set multiple options.\n" " VERSION version (default=1.0)\n"
@@ -498,7 +496,7 @@ static const char usage_message[] =" none (default), interact, or nointeract.\n" "--static-challenge t e : Enable static challenge/response protocol using\n" " challenge text t, with e indicating echo flag (0|1)\n" -"--server-poll-timeout n : when polling possible remote servers to connect to\n" +"--connect-timeout n : when polling possible remote servers to connect to\n" " in a round-robin fashion, spend no more than n seconds\n" " waiting for a response before trying the next server.\n"#endif
@@ -773,7 +771,7 @@ init_options (struct options *o, const bool init_gc) o->ce.af =AF_UNSPEC ; o->ce.bind_ipv6_only = false; o->ce.connect_retry_seconds =5 ; - o->ce.connect_timeout =10 ; + o->ce.connect_timeout =120 ; o->connect_retry_max =0 ; o->ce.local_port = o->ce.remote_port =OPENVPN_PORT ; o->verbosity =1 ;
@@ -825,7 +823,6 @@ init_options (struct options *o, const bool init_gc)#endif #if P2MP o->scheduled_exit_interval =5 ; - o->server_poll_timeout =0 ;#endif #ifdef ENABLE_CRYPTO o->ciphername ="BF-CBC" ;
@@ -1333,7 +1330,6 @@ show_http_proxy_options (const struct http_proxy_options *o)SHOW_STR (auth_method_string);SHOW_STR (auth_file);SHOW_BOOL (retry); -SHOW_INT (timeout);SHOW_STR (http_version);SHOW_STR (user_agent);for (i=0 ; i <MAX_CUSTOM_HTTP_HEADER && o->custom_headers[i].name;i++)
@@ -1754,7 +1750,6 @@ parse_http_proxy_override (const char *server, ho->server =string_alloc (server, gc); ho->port = port; ho->retry = true; - ho->timeout =5 ;if (flags && !strcmp (flags,"nct" )) ho->auth_retry =PAR_NCT ;else
@@ -1952,13 +1947,6 @@ options_postprocess_verify_ce (const struct options *options, const struct connemsg (M_USAGE ,"--lladdr can only be used in --dev tap mode" );/* -* Sanity check on TCP mode options -*/ -if (ce->connect_timeout_defined && ce->proto !=PROTO_TCP_CLIENT ) -msg (M_USAGE ,"--connect-timeout doesn't make sense unless also used with " -"--proto tcp-client or tcp6-client" ); - -/* * Sanity check on MTU parameters */ if (options->ce.tun_mtu_defined && options->ce.link_mtu_defined)
@@ -2411,9 +2399,6 @@ options_postprocess_verify_ce (const struct options *options, const struct conneMUST_BE_UNDEF (pkcs11_id);MUST_BE_UNDEF (pkcs11_id_management);#endif -#if P2MP -MUST_BE_UNDEF (server_poll_timeout); -#endif if (pull)msg (M_USAGE , err,"--pull" );
@@ -4741,11 +4726,11 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); options->ce.connect_retry_seconds =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"connect-timeout" ) && p[1 ] && !p[2 ]) +else if ((streq (p[0 ],"connect-timeout" ) ||streq (p[0 ],"server-poll-timeout" )) + && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); options->ce.connect_timeout =positive_atoi (p[1 ]); - options->ce.connect_timeout_defined = true; }else if (streq (p[0 ],"connect-retry-max" ) && p[1 ] && !p[2 ]) {
@@ -5238,11 +5223,9 @@ add_option (struct options *options, }else if (streq (p[0 ],"http-proxy-timeout" ) && p[1 ] && !p[2 ]) { -struct http_proxy_options *ho; -VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_CONNECTION ); - ho =init_http_proxy_options_once (&options->ce.http_proxy_options, &options->gc); - ho->timeout =positive_atoi (p[1 ]); +msg (M_WARN ,"DEPRECATED OPTION: http-proxy-timeout: In OpenVPN 2.4 the timeout until a connection to a " +"server is established is managed with a single timeout set by connect-timeout" ); }else if (streq (p[0 ],"http-proxy-option" ) && p[1 ] && !p[4 ]) {
@@ -5583,12 +5566,10 @@ add_option (struct options *options, options->push_peer_info = true; }#endif -#if P2MP else if (streq (p[1], "SERVER_POLL_TIMEOUT") && p[2]) { - options->server_poll_timeout =positive_atoi (p[2 ]); + options->ce.connect_timeout =positive_atoi (p[2 ]); } -#endif else {if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" ))
@@ -6129,11 +6110,6 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_PULL_MODE ); options->push_continuation =atoi (p[1 ]); } -else if (streq (p[0 ],"server-poll-timeout" ) && p[1 ] && !p[2 ]) - { -VERIFY_PERMISSION (OPT_P_GENERAL ); - options->server_poll_timeout =positive_atoi (p[1 ]); - }else if (streq (p[0 ],"auth-user-pass" ) && !p[2 ]) {VERIFY_PERMISSION (OPT_P_GENERAL );
src/openvpn/options.h +0 -3
@@ -97,7 +97,6 @@ struct connection_entrybool bind_local;int connect_retry_seconds;int connect_timeout; -bool connect_timeout_defined;struct http_proxy_options *http_proxy_options;const char *socks_proxy_server;const char *socks_proxy_port;
@@ -458,8 +457,6 @@ struct optionsconst char *auth_user_pass_file;struct options_pre_pull *pre_pull; -int server_poll_timeout; -int scheduled_exit_interval;#ifdef ENABLE_CLIENT_CR
src/openvpn/proxy.c +12 -8
@@ -41,6 +41,7 @@#include "httpdigest.h" #include "ntlm.h" #include "memdbg.h" +#include "forward.h" #define UP_TYPE_PROXY "HTTP Proxy"
@@ -52,7 +53,6 @@ init_http_proxy_options_once (struct http_proxy_options **hpo, { ALLOC_OBJ_CLEAR_GC (*hpo, struct http_proxy_options, gc);/* http proxy defaults */ - (*hpo)->timeout =5 ; (*hpo)->http_version ="1.0" ; }return *hpo;
@@ -255,6 +255,8 @@ clear_user_pass_http (void)purge_user_pass (&static_proxy_user_pass, true); } +#if 0 +/* function only used in #if 0 debug statement */ static void dump_residual (socket_descriptor_t sd, int timeout,
@@ -269,6 +271,7 @@ dump_residual (socket_descriptor_t sd, msg (D_PROXY, "PROXY HEADER: '%s'", buf); } } +#endif /* * Extract the Proxy-Authenticate header from the stream.
@@ -552,6 +555,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,socket_descriptor_t sd,/* already open to proxy */ const char *host, /* openvpn server remote */ const char *port, /* openvpn server port */ + struct event_timeout* server_poll_timeout, struct buffer *lookahead, volatile int *signal_received) {
@@ -634,7 +638,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p, goto error;/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -663,7 +667,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,while (true) { -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;chomp (buf);msg (D_PROXY ,"HTTP proxy returned: '%s'" , buf);
@@ -730,7 +734,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p, goto error;/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -838,7 +842,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p, goto error;/* receive reply from proxy */ -if (!recv_line (sd, buf,sizeof (buf), p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd, buf,sizeof (buf),get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/* remove trailing CR, LF */
@@ -862,7 +866,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,/* figure out what kind of authentication the proxy needs */ char *pa =NULL ;const int method =get_proxy_authenticate (sd, - p->options.timeout, +get_server_poll_remaining_time (server_poll_timeout), &pa,NULL , signal_received);
@@ -906,7 +910,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,msg (D_LINK_ERRORS ,"HTTP proxy returned bad status" );#if 0 /* DEBUGGING -- show a multi-line HTTP error response */ -dump_residual (sd, p->options.timeout, signal_received); +dump_residual (sd,get_server_poll_remaining_time (server_poll_timeout), signal_received);#endif goto error; }
@@ -914,7 +918,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,/* SUCCESS */ /* receive line from proxy and discard */ -if (!recv_line (sd,NULL ,0 , p->options.timeout, true,NULL , signal_received)) +if (!recv_line (sd,NULL ,0 ,get_server_poll_remaining_time (server_poll_timeout), true,NULL , signal_received)) goto error;/*
src/openvpn/proxy.h +1 -1
@@ -46,7 +46,6 @@ struct http_proxy_options {const char *server;const char *port;bool retry; -int timeout;# define PAR_NO 0/* don't support any auth retries */ # define PAR_ALL 1/* allow all proxy auth protocols */
@@ -86,6 +85,7 @@ bool establish_http_proxy_passthru (struct http_proxy_info *p,socket_descriptor_t sd,/* already open to proxy */ const char *host, /* openvpn server remote */ const char *port, /* openvpn server port */ + struct event_timeout* server_poll_timeout, struct buffer *lookahead, volatile int *signal_received);
src/openvpn/socket.c +6 -4
@@ -40,6 +40,7 @@#include "misc.h" #include "manage.h" #include "openvpn.h" +#include "forward.h" #include "memdbg.h"
@@ -1519,11 +1520,11 @@ link_socket_init_phase1 (struct link_socket *sock,const char *ipchange_command, const struct plugin_list *plugins, int resolve_retry_seconds, - int connect_timeout, int mtu_discover_type, int rcvbuf, int sndbuf, int mark, + struct event_timeout* server_poll_timeout, unsigned int sockflags) {ASSERT (sock );
@@ -1538,7 +1539,6 @@ link_socket_init_phase1 (struct link_socket *sock, sock->bind_local = bind_local; sock->inetd = inetd; sock->resolve_retry_seconds = resolve_retry_seconds; - sock->connect_timeout = connect_timeout; sock->mtu_discover_type = mtu_discover_type;#ifdef ENABLE_DEBUG
@@ -1558,6 +1558,7 @@ link_socket_init_phase1 (struct link_socket *sock, sock->info.bind_ipv6_only = bind_ipv6_only; sock->info.ipchange_command = ipchange_command; sock->info.plugins = plugins; + sock->server_poll_timeout = server_poll_timeout; sock->mode = mode;if (mode ==LS_MODE_TCP_ACCEPT_FROM )
@@ -1778,7 +1779,7 @@ phase2_tcp_client (struct link_socket *sock, struct signal_info *sig_info) do { socket_connect (&sock->sd, sock->info.lsa->current_remote->ai_addr, - sock->connect_timeout, + get_server_poll_remaining_time (sock->server_poll_timeout), sig_info); if (sig_info->signal_received)
@@ -1790,6 +1791,7 @@ phase2_tcp_client (struct link_socket *sock, struct signal_info *sig_info) sock->sd, sock->proxy_dest_host, sock->proxy_dest_port, + sock->server_poll_timeout, &sock->stream_buf.residual, &sig_info->signal_received); }
@@ -1816,7 +1818,7 @@ phase2_socks_client (struct link_socket *sock, struct signal_info *sig_info) {socket_connect (&sock->ctrl_sd, sock->info.lsa->current_remote->ai_addr, - sock->connect_timeout, +get_server_poll_remaining_time (sock->server_poll_timeout), sig_info);if (sig_info->signal_received)
src/openvpn/socket.h +5 -2
@@ -200,7 +200,6 @@ struct link_socketint mode;int resolve_retry_seconds; -int connect_timeout;int mtu_discover_type;struct socket_buffer_size socket_buffer_sizes;
@@ -231,6 +230,10 @@ struct link_socketconst char *proxy_dest_host;const char *proxy_dest_port; +/* Pointer to the server-poll to trigger the timeout in function which have +* their own loop instead of using the main oop */ +struct event_timeout * server_poll_timeout; +#if PASSTOS_CAPABILITY /* used to get/set TOS. */ #if defined(TARGET_LINUX )
@@ -319,11 +322,11 @@ link_socket_init_phase1 (struct link_socket *sock,const char *ipchange_command, const struct plugin_list *plugins, int resolve_retry_seconds, - int connect_timeout, int mtu_discover_type, int rcvbuf, int sndbuf, int mark, + struct event_timeout* server_poll_timeout, unsigned int sockflags); void link_socket_init_phase2 (struct link_socket *sock,
Signature · 1 line
2.7.4 (Apple Git-66)
Re: [Openvpn-devel] [[PATCH v3]] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Hi,
Quoted 3 lines · Arne Schwabe
With this change all timeouts before the first packet from the OpenVPN server are unified into the server-poll-timeout option.
The default of 120s has been chosen to be a safe value is larger as it is larger the sums of the old small timeouts.
One thing I noticed when testing which is not *caused* by this patch but which you/we might want to fix while at it.
When talking to a "deaf" HTTP proxy - namely, one that accepts the TCP connect, but then never sends back anything (try 195.30.4.1:23, it's a "Teergrube" to annoy wannabe hackers) the timeout will fire at the correct interval - 25s in my test, but then it won't restart but exit:
Sat Jun 11 20:05:59 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:23 [nonblock] Sat Jun 11 20:06:00 2016 TCP connection established with [AF_INET]195.30.4.1:23
Sat Jun 11 20:06:00 2016 Send to HTTP proxy: 'CONNECT 10.0.0.1:51196 HTTP/1.0'
Sat Jun 11 20:06:00 2016 Send to HTTP proxy: 'Host: 10.0.0.1'
Sat Jun 11 20:06:24 2016 recv_line: TCP port read timeout expired: Operation now in progress (errno=115) Sat Jun 11 20:06:24 2016 SIGTERM[soft,init_instance] received, process exiting
The same thing happens if I lure openvpn into trying a SOCKS proxy connection to that host:
Sat Jun 11 20:10:47 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:23 [nonblock] Sat Jun 11 20:10:48 2016 TCP connection established with [AF_INET]195.30.4.1:23
Sat Jun 11 20:10:53 2016 socks_handshake: TCP port read timeout expired: Operation now in progress (errno=115) Sat Jun 11 20:10:53 2016 SIGTERM[soft,init_instance] received, process exiting
... while all *other* connection failures I could test trigger a SIGUSR1 restart...
- plain TCP connection timeout:
Sat Jun 11 20:12:09 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:20 [nonblock] Sat Jun 11 20:12:34 2016 TCP: connect to [AF_INET]195.30.4.1:20 failed: Connection timed out Sat Jun 11 20:12:34 2016 SIGUSR1[connection failed(soft),init_instance] received, process restarting Sat Jun 11 20:12:34 2016 Restart pause, 5 second(s)
- TCP connects, but "only dead air":
Sat Jun 11 20:12:48 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:23 [nonblock] Sat Jun 11 20:12:49 2016 TCP connection established with [AF_INET]195.30.4.1:23
Sat Jun 11 20:12:49 2016 TCP_CLIENT link local: (not bound)
Sat Jun 11 20:12:49 2016 TCP_CLIENT link remote: [AF_INET]195.30.4.1:23
Sat Jun 11 20:13:14 2016 Server poll timeout, restarting
Sat Jun 11 20:13:14 2016 SIGUSR1[soft,server_poll] received, process restarting
(interesting enough, no "Restart pause" here)
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]...Re: [Openvpn-devel] [[PATCH v3]] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Quoted 8 lines · Gert Doering
One thing I noticed when testing which is not *caused* by this patch but which you/we might want to fix while at it.
When talking to a "deaf" HTTP proxy - namely, one that accepts the TCP connect, but then never sends back anything (try 195.30.4.1:23, it's a "Teergrube" to annoy wannabe hackers) the timeout will fire at the correct interval - 25s in my test, but then it won't restart but exit:
Quoted 12 lines
Sat Jun 11 20:05:59 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:23 [nonblock]
Sat Jun 11 20:06:00 2016 TCP connection established with [AF_INET] 195.30.4.1:23
Sat Jun 11 20:06:00 2016 Send to HTTP proxy: 'CONNECT 10.0.0.1:51196 HTTP/1.0'
Sat Jun 11 20:06:00 2016 Send to HTTP proxy: 'Host: 10.0.0.1' Sat Jun 11 20:06:24 2016recv_line: TCP port read timeout expired:
Operation now in progress (errno=115)
Sat Jun 11 20:06:24 2016 SIGTERM[soft,init_instance] received, process exiting
Isn't this controlled by the http-proxy-retry option which is off by default? Set that in the config and SIGUSR1 restart should happen, I think...
Selva
Re: [Openvpn-devel] [[PATCH v3]] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Hi,
Quoted 3 lines · Selva Nair
Isn't this controlled by the http-proxy-retry option which is off by default? Set that in the config and SIGUSR1 restart should happen, I think...
Right you are, and ditto for --socks-proxy-retry.
Sat Jun 11 22:23:50 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:23 [nonblock] Sat Jun 11 22:23:51 2016 TCP connection established with [AF_INET]195.30.4.1:23
Sat Jun 11 22:23:51 2016 Send to HTTP proxy: 'CONNECT 10.0.0.1:51196 HTTP/1.0'
Sat Jun 11 22:23:51 2016 Send to HTTP proxy: 'Host: 10.0.0.1'
Sat Jun 11 22:24:10 2016 recv_line: TCP port read timeout expired: Operation now in progress (errno=115) Sat Jun 11 22:24:10 2016 SIGUSR1[soft,init_instance] received, process restarting
Sat Jun 11 22:24:10 2016 Restart pause, 5 second(s)
[..]
Sat Jun 11 22:24:15 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:23 [nonblock]
(Side note: you win the "who knows more obscure/rarely used OpenVPN options" contest today :-) )
I do wonder how useful these settings are, and why they are not default... they predate my OpenVPN involvement by many years.
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]...Re: [Openvpn-devel] [[PATCH v3]] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Quoted 24 lines · Gert Doering
Quoted 3 lines · Selva Nair
Isn't this controlled by the http-proxy-retry option which is off by default? Set that in the config and SIGUSR1 restart should happen, I think...
Right you are, and ditto for --socks-proxy-retry.
Sat Jun 11 22:23:50 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:23 [nonblock]
Sat Jun 11 22:23:51 2016 TCP connection established with [AF_INET] 195.30.4.1:23
Sat Jun 11 22:23:51 2016 Send to HTTP proxy: 'CONNECT 10.0.0.1:51196 HTTP/1.0'
Sat Jun 11 22:23:51 2016 Send to HTTP proxy: 'Host: 10.0.0.1' Sat Jun 11 22:24:10 2016recv_line: TCP port read timeout expired:
Operation now in progress (errno=115)
Sat Jun 11 22:24:10 2016 SIGUSR1[soft,init_instance] received, process restarting
Sat Jun 11 22:24:10 2016 Restart pause, 5 second(s)
[..]
Sat Jun 11 22:24:15 2016 Attempting to establish TCP connection with [AF_INET]195.30.4.1:23 [nonblock]
Quoted 4 lines
(Side note: you win the "who knows more obscure/rarely used OpenVPN options"
contest today :-) )
I respectfully decline to accept..:-)
I've been scruitinizing every SIGsomething in the code as a part of my foray into "Signals in OpenVPN", saw this option only the other day for the first time..
Quoted 3 lines
I do wonder how useful these settings are, and why they are not default... they predate my OpenVPN involvement by many years.
No clue..
Selva
Re: [Openvpn-devel] [[PATCH v3]] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Quoted 10 lines
I do wonder how useful these settings are, and why they are not default...
they predate my OpenVPN involvement by many years.No clue..
I would just propose to remove the option (but accept configs with it in it). Connecting logic with dualstack and new timeouts has changed enough that this corner case behaviour isn't probably worth keeping. The option probably predates even the connection list.
Arne
Re: [Openvpn-devel] [[PATCH v3]] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Hi,
Quoted 9 lines · Arne Schwabe
Quoted 5 lines
I do wonder how useful these settings are, and why they are not default...
they predate my OpenVPN involvement by many years.No clue..
I would just propose to remove the option (but accept configs with it in it). Connecting logic with dualstack and new timeouts has changed enough that this corner case behaviour isn't probably worth keeping. The option probably predates even the connection list.
I think that is a reasonable way forward out of the option jungle - make --http-proxy-retry and --socks-proxy-retry NOOP-with-warning, and change the behaviour to "always SIGUSR1". That way, all connection errors either "direct" or "via any sort of proxy" will (should?) lead to the same restart behaviour, no special options to remember.
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]...[Openvpn-devel] [PATCH applied] Re: ] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
In reply to Arne SchwabeACK. Stared at the code for a while, and went out testing it (also, we got a feature-ACK for that waaay back in Munich already).
I have added a note to Changes.rst explaining the change, and how to get back the old default behaviour of a 10s timeout on TCP connects.
Your patch has been applied to the master branch.
commit f2134b7bea37df15756c599b94f16d4bffafbbd6
Author: Arne Schwabe Date: Sat Jun 11 16:43:15 2016 +0200
Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11899
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH V2] Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
In reply to Arne SchwabeHi,
Quoted 10 lines · Arne Schwabe
Am 11.06.16 um 14:10 schrieb Gert Doering:
Quoted 6 lines
This check "c2.tls_multi" - is this a short form for "we're not a peer-to-peer session"?
Other parts of the code seem to check "we have --pull or we have --mode server", so I wonder if we should make this somewhat more uninform. Eventually... :-)
Actually tls session server session. Aka everything but server in p2mp mode.
Uh, what, "server session" or "everything but server"? Now I'm totally confused.
Quoted 1 line
I will send a v3 shortly.
Seen it, thanks. Will have a go at it later.
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]...