Allow skipping multple remotes via management interface
PATCH 1/1 Allow skipping multple remotes via management interface
From: Selva Nair <[email protected]...>
The mamangement command "remote SKIP" is extended with an optional parameter 'count' > 0. If count is greater than number of connection entries (len), count % len is used. On going past the index of the last connection entry, counting is restarted from the first connection entry.
Without this, use of management-query-remote from a UI is virtually impractical except when there are only a handful of remote entries. Skipping the entries one by one takes a long time when there are many entries to be skipped (~ 1 second per entry). Use of "remote MOD" is not an option as change of protocol is not supported.
Management clients can determine the availablity of this feature by checking that the management interface version is > 3. Older versions will ignore the count parameter and behave identically to using count = 1.
--- doc/management-notes.txt | 7 +++++++ src/openvpn/init.c | 20 ++++++++++++++++---- src/openvpn/options.h | 2 ++ 3 files changed, 25 insertions(+), 4 deletions(-)
doc/management-notes.txt +7 -0
@@ -929,6 +929,13 @@ use this command: remote SKIP +Starting OpenVPN version 2.6 (management version > 3), skip +multiple remotes using: + + remote SKIP n + +where n > 0 is the number of remotes to skip. + COMMAND -- proxy (OpenVPN 2.3 or higher) --------------------------------------------
src/openvpn/init.c +16 -4
@@ -348,6 +348,7 @@ management_callback_remote_cmd(void *arg, const char **p) { flags =CE_MAN_QUERY_REMOTE_SKIP ; ret = true; + c->options.ce_advance_count = (p[2 ]) ?atoi (p[2 ]) :1 ; } else if (!strcmp(p[1], "MOD") && p[2] && p[3]) {
@@ -520,18 +521,28 @@ next_connection_entry(struct context *c) c->c1.link_socket_addr.remote_list; } +int advance_count =1 ; + +/* If previous connection entry was skipped by management client +* with a count to advance by, apply it. +*/ +if (c->options.ce_advance_count >0 ) + { + advance_count = c->options.ce_advance_count; + } +/* * Increase the number of connection attempts * If this is connect-retry-max * size(l) * OpenVPN will quit */ - c->options.unsuccessful_attempts++; + c->options.unsuccessful_attempts += advance_count; + l->current += advance_count; -if (++l->current >= l->len) +if (l->current >= l->len) { - - l->current =0 ; + l->current %= l->len;if (++n_cycles >=2 ) {msg (M_FATAL ,"No usable connection profiles are present" );
@@ -540,6 +551,7 @@ next_connection_entry(struct context *c) } } + c->options.ce_advance_count =1 ; ce = l->array[l->current];if (ce->flags &CE_DISABLED )
src/openvpn/options.h +2 -0
@@ -253,6 +253,8 @@ struct optionsbool no_advance;/* Counts the number of unsuccessful connection attempts */ unsigned int unsuccessful_attempts; +/* count of connection entries to advance by when no_advance is not set */ +int ce_advance_count;#if ENABLE_MANAGEMENT struct http_proxy_options *http_proxy_override;
Signature · 1 line
2.20.1
Am 08.09.21 um 00:36 schrieb [email protected]...:
Quoted 8 lines
From: Selva Nair <[email protected]...>
The mamangement command "remote SKIP" is extended with an optional parameter 'count' > 0. If count is greater than number of connection entries (len), count % len is used. On going past the index of the last connection entry, counting is restarted from the first connection entry.
Quoted 8 lines
Without this, use of management-query-remote from a UI is virtually impractical except when there are only a handful of remote entries. Skipping the entries one by one takes a long time when there are many entries to be skipped (~ 1 second per entry). Use of "remote MOD" is not an option as change of protocol is not supported.
Management clients can determine the availablity of this
Should be availability (found my the squiggly line of Thunderbird :D)
Quoted 3 lines
feature by checking that the management interface version is > 3. Older versions will ignore the count parameter and behave identically to using count = 1.
Arne
We really shouldn't let patches linger for so long... the options.h hunk had context that now looks completely different, both up and down...
Looking at the code, I do wonder why we increase the unsuccessful_attempts by the number of entries *skipped*
- c->options.unsuccessful_attempts++;
+ c->options.unsuccessful_attempts += advance_count;
.. the rest of the patch looks fine. Haven't actually tested beyond "compile / t_client".
Your patch has been applied to the master branch.
commit ec5ffe35a394c44b1ea25b7c10dab7da7d792ef2 (master) commit 42bfb5b03031de7b46a82bdec4f03dbaa1fc6ecb (release/2.6)
Author: Selva Nair Date: Tue Sep 7 18:36:14 2021 -0400
Allow skipping multple remotes via management interface
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg22817.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Hi,
src/openvpn/init.c next_connection_entry(struct context *c) · line 540
Quoted 6 lines · Gert Doering
Looking at the code, I do wonder why we increase the
unsuccessful_attemptsby the number of entries *skipped*src/openvpn/init.c +1
-1- c->options.unsuccessful_attempts++; + c->options.unsuccessful_attempts += advance_count;
I was not sure. In response to an old patch (now obsolete) where I had removed skip to not count as a failure, Arne had this comment:
"Also I want skip to count a failure since a UI might have some knowledge that certain remotes cannot work and skipping therefore should also count as "have tried this remote""
But that was when SKIP always advanced by 1.
Selva