From: "its_Giaan (Code Review)" Date: Tue, 1 Oct 2024 15:30:04 +0000 In-Reply-To: References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <0773292678aae06b1a7cacb78ede5364a56a78f1-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="SxKq2/pXin0="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Refinement to handle simultaneous UDP and TCP connections List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --SxKq2/pXin0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/766?usp=3Demail to look at the new patch set (#2). Change subject: Refinement to handle simultaneous UDP and TCP connections ...................................................................... Refinement to handle simultaneous UDP and TCP connections MULTI: properly remove TCP instances by checking the multi_instance protocol instead of the global one. TLS: set the tls_option xmit_hold bool value to true only in case of TCP child instance to avoid checking the global protocol value. INIT: initialize the c->c2.event_set in the inherit_context_top() by default and not only in case of UDP since we could have multiple different sockets. Change-Id: Ibe0614bf6ced210c136b2d13036048188196f7ef Signed-off-by: Gianmarco De Gregori --- M src/openvpn/init.c M src/openvpn/mtcp.c M src/openvpn/mudp.c M src/openvpn/multi.c M src/openvpn/multi.h M src/openvpn/multi_io.c M src/openvpn/options.c M src/openvpn/options.h 8 files changed, 142 insertions(+), 53 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/766/2 diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 5877ebb..b2f772b 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -225,7 +225,7 @@ if (streq(p[1], "HTTP")) { struct http_proxy_options *ho; - if (ce->proto !=3D PROTO_TCP && ce->proto !=3D PROTO_TCP_CLIEN= T) + if (ce->proto !=3D PROTO_TCP && c->mode !=3D CM_CHILD_TCP) { msg(M_WARN, "HTTP proxy support only works for TCP based c= onnections"); return false; @@ -602,7 +602,10 @@ ce_defined =3D false; } + int proto =3D c->options.ce.proto; c->options.ce =3D *ce; + c->options.ce.proto =3D proto; + #ifdef ENABLE_MANAGEMENT if (ce_defined && management && management_query_remote_enabled(ma= nagement)) { @@ -2673,7 +2676,7 @@ if (found & OPT_P_EXPLICIT_NOTIFY) { - if (!proto_is_udp(c->options.ce.proto) && c->options.ce.explicit_e= xit_notification) + if (!proto_is_udp(c->c2.link_sockets[0]->info.proto) && c->options= .ce.explicit_exit_notification) { msg(D_PUSH, "OPTIONS IMPORT: --explicit-exit-notify can only b= e used with --proto udp"); c->options.ce.explicit_exit_notification =3D 0; @@ -2833,14 +2836,21 @@ int sec =3D 2; int backoff =3D 0; - switch (c->options.ce.proto) + switch (c->mode) { - case PROTO_TCP_SERVER: - sec =3D 1; + case CM_TOP: + if (has_udp_in_local_list(&c->options)) + { + sec =3D c->options.ce.connect_retry_seconds; + } + else + { + sec =3D 1; + } break; - case PROTO_UDP: - case PROTO_TCP_CLIENT: + case CM_CHILD_UDP: + case CM_CHILD_TCP: sec =3D c->options.ce.connect_retry_seconds; break; } @@ -2858,7 +2868,7 @@ } /* Slow down reconnection after 5 retries per remote -- for TCP client= or UDP tls-client only */ - if (c->options.ce.proto =3D=3D PROTO_TCP_CLIENT + if (c->mode =3D=3D CM_CHILD_TCP || (c->options.ce.proto =3D=3D PROTO_UDP && c->options.tls_client)) { backoff =3D (c->options.unsuccessful_attempts / c->options.connect= ion_list->len) - 4; @@ -3338,7 +3348,21 @@ to.server =3D options->tls_server; to.replay_window =3D options->replay_window; to.replay_time =3D options->replay_time; - to.tcp_mode =3D link_socket_proto_connection_oriented(options->ce.prot= o); + + if (c->options.ce.local_list->len > 1) + { + for (int i =3D 0; i < c->options.ce.local_list->len; i++) + { + if (proto_is_dgram(c->options.ce.local_list->array[i]->proto)) + { + to.tcp_mode =3D false; + } + } + } + else + { + to.tcp_mode =3D link_socket_proto_connection_oriented(c->options.c= e.local_list->array[0]->proto); + } to.config_ciphername =3D c->options.ciphername; to.config_ncp_ciphers =3D c->options.ncp_ciphers; to.transition_window =3D options->transition_window; @@ -3383,7 +3407,7 @@ /* should we not xmit any packets until we get an initial * response from client? */ - if (to.server && options->ce.proto =3D=3D PROTO_TCP_SERVER) + if (to.server && c->mode =3D=3D CM_CHILD_TCP) { to.xmit_hold =3D true; } @@ -4287,20 +4311,13 @@ #ifdef _WIN32 msg(M_INFO, "NOTE: --fast-io is disabled since we are running on W= indows"); #else - if (!proto_is_udp(c->options.ce.proto)) + if (c->options.shaper) { - msg(M_INFO, "NOTE: --fast-io is disabled since we are not usin= g UDP"); + msg(M_INFO, "NOTE: --fast-io is disabled since we are using --= shaper"); } else { - if (c->options.shaper) - { - msg(M_INFO, "NOTE: --fast-io is disabled since we are usin= g --shaper"); - } - else - { - c->c2.fast_io =3D true; - } + c->c2.fast_io =3D true; } #endif } @@ -4997,6 +5014,7 @@ /* options */ dest->options =3D src->options; + dest->options.ce.proto =3D sock->info.proto; options_detach(&dest->options); dest->c2.event_set =3D src->c2.event_set; @@ -5095,10 +5113,7 @@ dest->c2.es_owned =3D false; dest->c2.event_set =3D NULL; - if (proto_is_dgram(src->options.ce.proto)) - { - do_event_set_init(dest, false); - } + do_event_set_init(dest, false); #ifdef USE_COMP dest->c2.comp_context =3D NULL; diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index 5d04c64..c1107ab 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -153,12 +153,19 @@ { if (mi) { - mi->socket_set_called =3D true; - socket_set(mi->context.c2.link_sockets[0], - m->multi_io->es, - mbuf_defined(mi->tcp_link_out_deferred) ? EVENT_WRITE := EVENT_READ, - &mi->ev_arg, - &mi->tcp_rwflags); + if (proto_is_dgram(mi->context.c2.link_sockets[0]->info.proto)) + { + return; + } + else + { + mi->socket_set_called =3D true; + socket_set(mi->context.c2.link_sockets[0], + m->multi_io->es, + mbuf_defined(mi->tcp_link_out_deferred) ? EVENT_WRI= TE : EVENT_READ, + &mi->ev_arg, + &mi->tcp_rwflags); + } } } diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 50b4e21..3189fe9 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -194,6 +194,7 @@ struct hash *hash =3D m->hash; real.proto =3D sock->info.proto; m->local.proto =3D real.proto; + m->hmac_reply_ls =3D sock; if (mroute_extract_openvpn_sockaddr(&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len > 0) @@ -320,15 +321,8 @@ msg_set_prefix("Connection Attempt"); m->top.c2.to_link =3D m->hmac_reply; m->top.c2.to_link_addr =3D m->hmac_reply_dest; - for (int i =3D 0; i < m->top.c1.link_sockets_num; i++) - { - if (!proto_is_dgram(m->top.c2.link_sockets[i]->info.proto)) - { - continue; - } - - process_outgoing_link(&m->top, m->top.c2.link_sockets[i]); - } + process_outgoing_link(&m->top, m->hmac_reply_ls); + m->hmac_reply_ls =3D NULL; m->hmac_reply_dest =3D NULL; } } diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 0d2ad78..b5efb3a 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -606,6 +606,7 @@ ASSERT(!mi->halt); mi->halt =3D true; + bool is_dgram =3D proto_is_dgram(mi->context.c2.link_sockets[0]->info.= proto); dmsg(D_MULTI_DEBUG, "MULTI: multi_close_instance called"); @@ -664,7 +665,7 @@ mi->did_iroutes =3D false; } - if (m->multi_io && !proto_is_dgram(m->top.options.ce.proto)) + if (!is_dgram) { multi_tcp_dereference_instance(m->multi_io, mi); } @@ -3400,7 +3401,7 @@ /* decrypt in instance context */ perf_push(PERF_PROC_IN_LINK); - lsi =3D get_link_socket_info(c); + lsi =3D &sock->info; orig_buf =3D c->c2.buf.data; if (process_incoming_link_part1(c, lsi, floated)) { @@ -3851,7 +3852,7 @@ while ((he =3D hash_iterator_next(&hi))) { struct multi_instance *mi =3D (struct multi_instance *) he->value; - if (!mi->halt) + if (!mi->halt && proto_is_dgram(mi->context.options.ce.proto)) { send_control_channel_string(&mi->context, next_server ? "RESTA= RT,[N]" : "RESTART", D_PUSH); multi_schedule_context_wakeup(m, mi); @@ -3889,13 +3890,15 @@ status_close(so); return false; } - else if (proto_is_dgram(m->top.options.ce.proto) - && is_exit_restart(m->top.sig->signal_received) - && (m->deferred_shutdown_signal.signal_received =3D=3D 0) - && m->top.options.ce.explicit_exit_notification !=3D 0) + else if (has_udp_in_local_list(&m->top.options)) { - multi_push_restart_schedule_exit(m, m->top.options.ce.explicit_exi= t_notification =3D=3D 2); - return false; + if (is_exit_restart(m->top.sig->signal_received) + && (m->deferred_shutdown_signal.signal_received =3D=3D 0) + && m->top.options.ce.explicit_exit_notification !=3D 0) + { + multi_push_restart_schedule_exit(m, m->top.options.ce.explicit= _exit_notification =3D=3D 2); + return false; + } } return true; } diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index 0a15fd9..ad56416 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -205,6 +205,7 @@ struct buffer hmac_reply; struct link_socket_actual *hmac_reply_dest; + struct link_socket *hmac_reply_ls; /* * Timer object for stale route check diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c index 43fe24b..59661ed 100644 --- a/src/openvpn/multi_io.c +++ b/src/openvpn/multi_io.c @@ -142,6 +142,11 @@ &m->top.c2.link_sockets[i]->ev_arg); } + if (has_udp_in_local_list(&m->top.options)) + { + get_io_flags_udp(&m->top, m->multi_io, p2mp_iow_flags(m)); + } + #ifdef _WIN32 if (tuntap_is_wintun(m->top.c1.tuntap)) { @@ -396,6 +401,10 @@ multi_protocol_process_io(struct multi_context *m) { struct multi_protocol *multi_io =3D m->multi_io; + const unsigned int udp_status =3D multi_io->udp_flags; + const unsigned int mpp_flags =3D m->top.c2.fast_io + ? (MPP_CONDITIONAL_PRE_SELECT | MPP_CLO= SE_ON_SIGNAL) + : (MPP_PRE_SELECT | MPP_CLOSE_ON_SIGNAL= ); int i; for (i =3D 0; i < multi_io->n_esr; ++i) @@ -447,6 +456,39 @@ } break; } + else + { + if (e->arg >=3D MULTI_N) + { + struct event_arg *ev_arg =3D (struct event_arg= *)e->arg; + if (ev_arg->type !=3D EVENT_ARG_LINK_SOCKET) + { + multi_io->udp_flags =3D ES_ERROR; + msg(D_LINK_ERRORS, + "MULTI PROTOCOL: io_work: non socket e= vent delivered"); + break; + } + } + else + { + ev_arg->pending =3D true; + } + + if (udp_status & SOCKET_READ) + { + read_incoming_link(&m->top, ev_arg->u.sock); + if (!IS_SIG(&m->top)) + { + multi_process_incoming_link(m, NULL, mpp_f= lags, + ev_arg->u.sock= ); + } + } + else + { + multi_process_io_udp(m); + } + break; + } } } else diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 6f4d5e2..edda0bb 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -993,10 +993,13 @@ const struct connection_entry *e, const int i) { - setenv_str_i(es, "proto", proto2ascii(e->proto, e->af, false), i); - /* expected to be for single socket contexts only */ - setenv_str_i(es, "local", e->local_list->array[0]->local, i); - setenv_str_i(es, "local_port", e->local_list->array[0]->port, i); + for (int j =3D 0; j < e->local_list->len; j++) + { + setenv_str_i(es, "proto", proto2ascii(e->local_list->array[j]->pro= to, e->af, false), i); + /* expected to be for single socket contexts only */ + setenv_str_i(es, "local", e->local_list->array[j]->local, i); + setenv_str_i(es, "local_port", e->local_list->array[j]->port, i); + } setenv_str_i(es, "remote", e->remote, i); setenv_str_i(es, "remote_port", e->remote_port, i); @@ -2466,7 +2469,7 @@ { struct local_entry *le =3D ce->local_list->array[i]; - if (proto_is_net(ce->proto) + if (proto_is_net(le->proto) && string_defined_equal(le->local, ce->remote) && string_defined_equal(le->port, ce->remote_port)) { @@ -3828,6 +3831,12 @@ options_postprocess_mutate_ce(o, o->connection_list->array[i]); } + if (!has_udp_in_local_list(o)) + { + o->fast_io =3D false; + msg(M_INFO, "NOTE: --fast-io is disabled while using multi-socket"= ); + } + if (o->ce.local_list) { for (i =3D 0; i < o->ce.local_list->len; i++) @@ -9722,3 +9731,19 @@ err: gc_free(&gc); } + +bool +has_udp_in_local_list(const struct options *options) +{ + if (options->ce.local_list) + { + for (int i =3D 0; i < options->ce.local_list->len; i++) + { + if (proto_is_dgram(options->ce.local_list->array[i]->proto)) + { + return true; + } + } + } + return false; +} diff --git a/src/openvpn/options.h b/src/openvpn/options.h index f3cf7e5..30bd5aa 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -917,6 +917,8 @@ bool key_is_external(const struct options *options); +bool has_udp_in_local_list(const struct options *options); + /** * Returns whether the current configuration has dco enabled. */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/766?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ibe0614bf6ced210c136b2d13036048188196f7ef Gerrit-Change-Number: 766 Gerrit-PatchSet: 2 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --SxKq2/pXin0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

its_Giaan uploaded patch set #2 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/766?usp=3Demail">View Chang= e

Refinement to handle simultaneous UDP and TCP connections

MULT= I: properly remove TCP instances by checking the multi_instance
p= rotocol instead of the global one.

TLS: set the tls_option xmit_hold= bool value to true only in case of
TCP child instance to avoid che= cking the global protocol
value.

INIT: initialize the c->= c2.event_set in the inherit_context_top()
by default and not only = in case of UDP since we could have
multiple different sockets.
=
Change-Id: Ibe0614bf6ced210c136b2d13036048188196f7ef
Signed-off-by: = Gianmarco De Gregori <gianmarco@...2726...>
---
M src/openvpn/i= nit.c
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/mult= i.c
M src/openvpn/multi.h
M src/openvpn/multi_io.c
M src/openvpn/o= ptions.c
M src/openvpn/options.h
8 files changed, 142 insertions(+), = 53 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn r=
efs/changes/66/766/2
diff --git a/src/openvpn/init.c b/src/openvpn/=
init.c
index 5877ebb..b2f772b 100644
--- a/= src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -225,7 +225,7 @@
if (streq(p[1], "HTTP&qu= ot;))
{
struct http_p= roxy_options *ho;
- = if (ce->proto !=3D PROTO_TCP && ce->proto !=3D PROTO_= TCP_CLIENT)
+ = if (ce->proto !=3D PROTO_TCP && c->mode !=3D CM_CHILD_TCP= )
{
msg(M_WAR= N, "HTTP proxy support only works for TCP based connections");
return false;
@@ -602,7 +602= ,10 @@
ce_defined =3D false;
= }

+ int proto =3D c->options.ce.proto;
= c->options.ce =3D *ce;
+ c->options.ce.proto =3D proto;
+
#ifdef ENABLE_MANAGEMEN= T
if (ce_defined && management && = management_query_remote_enabled(management))
{
@@ -2673,7 +2676,7 @@

i= f (found & OPT_P_EXPLICIT_NOTIFY)
{
- if (!proto_is_udp(c->opti= ons.ce.proto) && c->options.ce.explicit_exit_notification)

+ if (!proto_is_udp= (c->c2.link_sockets[0]->info.proto) && c->options.ce.expli= cit_exit_notification)
{
= msg(D_PUSH, "OPTIONS IMPORT: --explicit-exit-notify can only be us= ed with --proto udp");
c->options.ce.e= xplicit_exit_notification =3D 0;
@@ -2833,14 +2836,21 @@
int sec =3D 2;
int backoff =3D 0;

- s= witch (c->options.ce.proto)
+ switch (c->mode)
{
- case PROTO_TCP_SERVER:- sec =3D 1;<= br>+ case CM_TOP:=
+ if (has_udp_in= _local_list(&c->options))
+ {
+ sec =3D c->options.ce.connect_retry_seconds;
+ }
= + else
+ {

+ sec =3D 1;
+ }

= break;

- case PROTO_UDP:
- case PROTO_TCP_CLIENT:
+ case CM_CHILD_UDP:
+ case CM_CHILD_TCP:
sec =3D c->options.ce.connect_retry_seconds;

break;
}
@@ -2858,7 += 2868,7 @@
}

/* = Slow down reconnection after 5 retries per remote -- for TCP client or UDP = tls-client only */
- = if (c->options.ce.proto =3D=3D PROTO_TCP_CLIENT
+ if (c->mode =3D=3D CM_CHILD_TCP

|| (c->options.ce.proto =3D=3D PROTO_UDP &&am= p; c->options.tls_client))
{
= backoff =3D (c->options.unsuccessful_attempts / c->options.connect= ion_list->len) - 4;
@@ -3338,7 +3348,21 @@
to.server =3D options->tls_server;
to.repla= y_window =3D options->replay_window;
to.replay_time= =3D options->replay_time;
- to.tcp_mode =3D link_socket_proto_connection_oriented(options-&= gt;ce.proto);
+
+ if (c->options.ce.= local_list->len > 1)
+ {
+ = for (int i =3D 0; i < c->options.ce.local_list->len; i++)<= br>+ {
+ if (proto_is_dgram(c->= options.ce.local_list->array[i]->proto))
+ {
+ to.tcp_mode =3D false;
+ }

+ }
+ }
+ else
+ = {
+ to.tcp_= mode =3D link_socket_proto_connection_oriented(c->options.ce.local_list-= >array[0]->proto);
+ }
to.config_ciphername =3D c->options.ciph= ername;
to.config_ncp_ciphers =3D c->options.ncp_ci= phers;
to.transition_window =3D options->transition= _window;
@@ -3383,7 +3407,7 @@

= /* should we not xmit any packets until we get an initial=
* response from client? */
- if (to.server && options->ce.proto =3D= =3D PROTO_TCP_SERVER)
+ if (to.server && c->mode =3D=3D CM_CHILD_TCP)
{
to.xmit_hold =3D true;
= }
@@ -4287,20 +4311,13 @@
#ifdef _WIN= 32
msg(M_INFO, "NOTE: --fast-io is disabled s= ince we are running on Windows");
#else
- if (!proto_is_udp(c->opt= ions.ce.proto))
+ = if (c->options.shaper)
{
- msg(M_INFO, "NOTE: --fa= st-io is disabled since we are not using UDP");
+ msg(M_INFO, "NOTE: --fas= t-io is disabled since we are using --shaper");
= }
else
{
- if (c->options.shape= r)
- {
- msg(M_INFO,= "NOTE: --fast-io is disabled since we are using --shaper");
- }
- else

- {
- c->c2.fast_io =3D true;
- }
+ c->c2.fast_io =3D= true;

}
#endif
= }
@@ -4997,6 +5014,7 @@

/* options */

dest->options =3D src->opt= ions;
+ dest->o= ptions.ce.proto =3D sock->info.proto;
options_detac= h(&dest->options);

dest->c= 2.event_set =3D src->c2.event_set;
@@ -5095,10 +5113,7 @= @
dest->c2.es_owned =3D false;

dest->c2.event_set =3D NULL;
- if (proto_is_dgram(src->options.ce.prot= o))
- {
- do_event_set_init(dest, fa= lse);
- }
= + do_event_set_init(dest, fa= lse);

#ifdef USE_COMP
= dest->c2.comp_context =3D NULL;
diff --git a/src/open= vpn/mtcp.c b/src/openvpn/mtcp.c
index 5d04c64..c1107ab 1006= 44
--- a/src/openvpn/mtcp.c
+++ b/src/openv= pn/mtcp.c
@@ -153,12 +153,19 @@
{ if (mi)
{
- mi->socket_set_called =3D true;
= - socket_set(mi->contex= t.c2.link_sockets[0],
-= m->multi_io->es,
- mbuf_defined(mi->tcp_link_out_def= erred) ? EVENT_WRITE : EVENT_READ,
- &mi->ev_arg,
- &mi->tcp_rwflags)= ;
+ if (proto_= is_dgram(mi->context.c2.link_sockets[0]->info.proto))
+ {
+ return;
+ }
+ else
+ {
+ socket_set(mi->context.c2.link= _sockets[0],
+ = m->multi_io->es,
+ mbuf_defined(mi->tcp_link_out_= deferred) ? EVENT_WRITE : EVENT_READ,
+ &mi->ev_arg,
+ &mi->= ;tcp_rwflags);
+ = }
}
}

= diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
= index 50b4e21..3189fe9 100644
--- a/src/openvpn/mudp.c

+++ b/src/openvpn/mudp.c
@@ -194,6 +194,7 @@

struct hash *hash =3D m->hash;
r= eal.proto =3D sock->info.proto;
m->local.proto = =3D real.proto;
+ = m->hmac_reply_ls =3D sock;

if (mr= oute_extract_openvpn_sockaddr(&real, &m->top.c2.from.dest, true)=
&& m->top.c2.buf.len > 0)@@ -320,15 +321,8 @@
msg_set_prefix("C= onnection Attempt");
m->top.c2.to_link =3D= m->hmac_reply;
m->top.c2.to_link_addr =3D m= ->hmac_reply_dest;
-= for (int i =3D 0; i < m->top.c1.link_sockets_num; i++)=
- {
- if (!proto_is_dgram(m->to= p.c2.link_sockets[i]->info.proto))
- {
- continue;
- }
-
- proce= ss_outgoing_link(&m->top, m->top.c2.link_sockets[i]);
<= span style=3D"color: hsl(0, 100%, 40%);">- }
+ process_outgoing_link(&m->= top, m->hmac_reply_ls);
+ m->hmac_reply_ls =3D NULL;
m->= ;hmac_reply_dest =3D NULL;
}
}=
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
= index 0d2ad78..b5efb3a 100644
--- a/src/openvpn/multi= .c
+++ b/src/openvpn/multi.c
@@ -606,6 +606= ,7 @@

ASSERT(!mi->halt); mi->halt =3D true;
+ bool is_dgram =3D proto_is_dgram(mi->context.c2.link_= sockets[0]->info.proto);

dmsg(D_M= ULTI_DEBUG, "MULTI: multi_close_instance called");

@@ -664,7 +665,7 @@
mi->= ;did_iroutes =3D false;
}
=
- if (m->multi_io &= amp;& !proto_is_dgram(m->top.options.ce.proto))
+ if (!is_dgram)
= {
multi_tcp_dereference_instance(m->= ;multi_io, mi);
}
@@ -3400,7 +3401= ,7 @@
/* decrypt in instance context */=

perf_push(PERF_PROC_IN_LINK);

- lsi =3D get_li= nk_socket_info(c);
+ = lsi =3D &sock->info;
orig_bu= f =3D c->c2.buf.data;
if (process_incoming_= link_part1(c, lsi, floated))
{
@@ -3851,7 +3852,7 @@
while ((he =3D hash_iterator_ne= xt(&hi)))
{
struct multi_= instance *mi =3D (struct multi_instance *) he->value;
- if (!mi->halt)
+ if (!mi->halt &&= ; proto_is_dgram(mi->context.options.ce.proto))
= {
send_control_channel_string(&mi->con= text, next_server ? "RESTART,[N]" : "RESTART", D_PUSH);=
multi_schedule_context_wakeup(m, mi);<= br>@@ -3889,13 +3890,15 @@
status_close(so);=
return false;
}
- else if (proto_is_dgram(m->= top.options.ce.proto)
-= && is_exit_restart(m->top.sig->signal_received)<= /span>
- &&= ; (m->deferred_shutdown_signal.signal_received =3D=3D 0)
- && m->top.opt= ions.ce.explicit_exit_notification !=3D 0)

+ else if (has_udp_in_local_list(&m->top.op= tions))
{
- multi_push_restart_schedule_exit(m, m->top.options.ce.e= xplicit_exit_notification =3D=3D 2);
- return false;
+ if (is_exit_restart(m->top.sig->signal_recei= ved)
+ &am= p;& (m->deferred_shutdown_signal.signal_received =3D=3D 0)+ && m->= top.options.ce.explicit_exit_notification !=3D 0)
+ {
+ multi_push_restart_schedule_exit(m, m->t= op.options.ce.explicit_exit_notification =3D=3D 2);
+ return false;
+ }
}

return true;
}
diff --g= it a/src/openvpn/multi.h b/src/openvpn/multi.h
index 0a15fd= 9..ad56416 100644
--- a/src/openvpn/multi.h
+++ b/src/openvpn/multi.h
@@ -205,6 +205,7 @@

struct buffer hmac_reply;
s= truct link_socket_actual *hmac_reply_dest;
+ struct link_socket *hmac_reply_ls;

/*
* Timer object for stale= route check
diff --git a/src/openvpn/multi_io.c b/src/open= vpn/multi_io.c
index 43fe24b..59661ed 100644
--- a/src/openvpn/multi_io.c
+++ b/src/openvpn/multi_io.c=
@@ -142,6 +142,11 @@
= &m->top.c2.link_sockets[i]->ev_arg);
<= span> }

+ if (has_udp_in_local_list(&m->top.options))
= + {
+ get_io_flags_udp(&m->top, m-&= gt;multi_io, p2mp_iow_flags(m));
+ }
+<= /span>
#ifdef _WIN32
if (tuntap_is_wintun(m-= >top.c1.tuntap))
{
@@ -396,6 +401,1= 0 @@
multi_protocol_process_io(struct multi_context *m)

{
struct multi_protocol *multi_io =3D m= ->multi_io;
+ c= onst unsigned int udp_status =3D multi_io->udp_flags;
+ const unsigned int mpp_flags =3D m= ->top.c2.fast_io
+= ? (MPP_CONDITIONAL_PRE_SELECT | MPP_CLOS= E_ON_SIGNAL)
+ = : (MPP_PRE_SELECT | MPP_CLOSE_ON_SIGNAL);

int i;

for (i =3D 0;= i < multi_io->n_esr; ++i)
@@ -447,6 +456,39 @@

}
= break;
}
+ else
+ {
+ if (e->arg = >=3D MULTI_N)
+ = {
+ = if (ev_arg->type !=3D EVENT_ARG_LINK_SOCKET)

+ = {
+ = multi_io->udp_flags =3D ES_ERROR;
+ msg(D_L= INK_ERRORS,
+ = "MULTI PROTOCOL: io_work: non socket event= delivered");
+ = break;
+ }
+ }
+ else
+ {=
+ = ev_arg->pending =3D true;
+ }
+
+ = if (udp_status & SOCKET_READ)
+ {
+ read_= incoming_link(&m->top, ev_arg->u.sock);
+ if (!IS_SIG(&= m->top))
+ = {
+ multi_process_incoming_link(m, NULL, mpp_= flags,
+ = ev_arg->u.sock);+ = }
+ = }
+ = else
+ = {
+ }
+ break;

+ }<= /span>
}
}
= else
diff --git a/src/openvpn/options.c b/src/openv= pn/options.c
index 6f4d5e2..edda0bb 100644
= --- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -993,10 +993,13 @@
= const struct connection_entry *e,
= const int i)
{
- setenv_str_i(es, "proto", proto2ascii(e->proto,= e->af, false), i);
= - /* expected to be for single socket contexts only */
- setenv_str_i(es, "local",= e->local_list->array[0]->local, i);
- setenv_str_i(es, "local_port", e->= local_list->array[0]->port, i);
+ for (int j =3D 0; j < e->local_list->len; j+= +)
+ {
<= span style=3D"color: hsl(120, 100%, 40%);">+ setenv_str_i(es, "= proto", proto2ascii(e->local_list->array[j]->proto, e->af,= false), i);

+ = /* expected to be for single socket contexts only */
+ setenv_str_i(es, "local"= ;, e->local_list->array[j]->local, i);
+ setenv_str_i(es, "local_port"= , e->local_list->array[j]->port, i);
+ }
setenv_str_i(es, "= ;remote", e->remote, i);
setenv_str_i(es, &quo= t;remote_port", e->remote_port, i);

@@ -2466,7 +2469,7 @@

{
st= ruct local_entry *le =3D ce->local_list->array[i];
<= /span>
- if (proto_is_n= et(ce->proto)
+ = if (proto_is_net(le->proto)
&&= string_defined_equal(le->local, ce->remote)
= && string_defined_equal(le->port, ce->remote_port))
{
@@ -3828,6 +3831,12 @@
options_postprocess_mutate_ce(o, o->connection_list->arra= y[i]);

}

+ if (!has_udp_in_local_list(o))
+ {

+ o->fast_io =3D false;
+ msg(M_INFO, "NOTE: -= -fast-io is disabled while using multi-socket");
+ }
+
if (o->ce.local_list) {
for (i =3D 0; i < o->ce.local= _list->len; i++)
@@ -9722,3 +9731,19 @@
= err:
gc_free(&gc);
}
<= span style=3D"color: hsl(120, 100%, 40%);">+
+bool
+has_udp_in_local_list(const struct options *options)
+{
+ if (options->ce.local_list)
+ {
+ for (int i =3D 0; i < options->ce.l= ocal_list->len; i++)
+ {
+ = if (proto_is_dgram(options->ce.local_list->array[i]->proto))=
+ {

+ return tr= ue;
+ }

+ }
+ }
+ return false;
+}
diff --git a/src/openvpn/optio= ns.h b/src/openvpn/options.h
index f3cf7e5..30bd5aa 100644<= /span>
--- a/src/openvpn/options.h
+++ b/src/openv= pn/options.h
@@ -917,6 +917,8 @@
bool key_is_external(const struct options *options);

+bool has_udp_in= _local_list(const struct options *options);
+
/**
* Returns w= hether the current configuration has dco enabled.
*/

To view, visit change 766. To unsubscribe, or fo= r help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ibe0614bf6ced210c136b2d13036= 048188196f7ef
Gerrit-Change-Number: 766
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--SxKq2/pXin0=--