From: "cron2 (Code Review)" cron2 submitted this change.Ensures all params are ready before invoking d=
co_set_peer()
In UDP case, on a p2mp server, dco_set_peer() is curre=
ntly called
at the wrong time since the mssfix param is calculated later=
on in
tls_session_update_crypto_params_do_work().
Move the dco_s=
et_peer() inside tls_session_update_crypto_params_do_work(),
and remove =
p2p_set_dco_keepalive() to avoid calling dco_set_peer()
twice on the cli=
ent side.
This way, we'll ensure that all crypto and frame param=
s are properly
initialized and if an update occurs DCO will be notified.=
Change-Id: Ic8538e734dba53cd43fead3961e4401c8037e079
Signed-off-=
by: Gianmarco De Gregori <gianmarco@...2726...>
Acked-by: Lev Stip=
akov <lstipakov@...277...>
Message-Id: <20240906145745.67596-1-=
frank@...2641...>
URL: https://www.mail-archive.com/openvpn-devel@...1484...=
ts.sourceforge.net/msg29086.html
Signed-off-by: Gert Doering <gert@...1186...=
.1296...>
---
M src/openvpn/init.c
M src/openvpn/multi.c
M s=
rc/openvpn/ssl.c
M src/openvpn/ssl.h
4 files changed, 34 insertions(+=
), 49 deletions(-)
ind=
ex 4f63346..dd56961 100644
--- a/src/openvpn/init.c<=
br>+++ b/src/openvpn/init.c
@@ -2178,27 +2178,6 @@
|| !memcmp(a, &zero, sizeof(struct sha256_dig=
est));
}
-static bool
-p2p_set_dco_keepalive(struct context *c)
-{
- if (dco_enabled(&c->options)
- && (c->options.ping_send=
_timeout || c->c2.frame.mss_fix))
- {
- =
int ret =3D dco_set_peer(&c->c1.tuntap->dco,
- c->options.ping_send_timeout,=
span>
- =
c->options.ping_rec_timeout,
- c->c2.frame.mss_fix);=
span>
- if (ret < 0)=
- {
<=
span style=3D"color: hsl(0, 100%, 40%);">- msg(D_DCO, "Cann=
ot set parameters for DCO peer (id=3D%u): %s",
- c->c2.tls_multi->dco_=
peer_id, strerror(-ret));
- return false;
- }
- =
}
- return true;
-}
-
/**
* H=
elper function for tls_print_deferred_options_results
* A=
dds the ", " delimitor if there already some data in the@@ -2363,7 +2342,8 @@
if (!tls_session_update_=
crypto_params(c->c2.tls_multi, session,
=
&c->options, &c->c2.frame,<=
br> frame_fragment,<=
br>- =
get_link_socket_info(c)))
+ get_link_socke=
t_info(c),
+ =
&c->c1.tuntap->dco))
<=
span> {
msg(D_TLS_ERRORS, "OPTIONS ERROR:=
failed to import crypto options");
return fa=
lse;
@@ -2472,12 +2452,6 @@
}<=
/span>
}
- if (c->mode =3D=3D MODE_POINT_TO_POINT &a=
mp;& !p2p_set_dco_keepalive(c))
- {
- msg(D_TLS_ERRORS, "ERROR: Failed to apply DCO keepalive =
or MSS fix parameters");
- return false;
- }
-=
if (c->c2.did_open_tun)
=
{
c->c1.pulled_options_digest_save =3D c=
->c2.pulled_options_digest;
@@ -2582,7 +2556,8 @@=
if (!tls_session_update_crypto_params(c-&g=
t;c2.tls_multi, session, &c->options,
=
&c->c2.frame, frame_fragment,
- =
get_link_socket_info(c)))
+ get_link_socket_=
info(c),
+ =
&c->c1.tuntap->dco))
msg(D_TLS_ERRORS, "ERROR: failed to=
set crypto cipher");
return false;
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
--- a/src/openvpn/multi.c<=
/span>
+++ b/src/openvpn/multi.c
@@ -2364,21 +2364=
,6 @@
return false;
}<=
br>
- if (mi-=
>context.options.ping_send_timeout || mi->context.c2.frame.mss_fix)=
span>
- {
- ret =3D dco_set_peer(&mi-&g=
t;context.c1.tuntap->dco,
- mi->context.c2.tls_multi->dco_peer_=
id,
- =
mi->context.options.ping_send_timeout,
- mi->context.opti=
ons.ping_rec_timeout,
-=
mi->context.c2.frame.mss_fix);- {
- msg(D_DCO, "Cannot set DCO pe=
er parameters for %s (id=3D%u): %s",
- multi_instance_string(mi, false, gc),=
span>
- mi->=
context.c2.tls_multi->dco_peer_id, strerror(-ret));
- return false;
- }
- }
return true;
=
}
@@ -2398,7 +2383,8 @@
=
struct tls_session *session =3D &c->c2.tls_multi->sess=
ion[TM_ACTIVE];
if (!tls_session_update_crypto_params(=
c->c2.tls_multi, session, &c->options,
=
&c->c2.frame, frame_fragment,
- =
get_link_socket_info(c)))
+ get_link_soc=
ket_info(c),
+ =
&c->c1.tuntap->dco))
{
msg(D_TLS_ERRORS, "TLS Error: i=
nitializing data channel failed");
register_s=
ignal(c->sig, SIGUSR1, "process-push-msg-failed");
<=
span>diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
ind=
ex 8c72d0b..e2be614 100644
--- a/src/openvpn/ssl.c+++ b/src/openvpn/ssl.c
@@ -1591,7 +1591,8 @@
struct options *option=
s,
struct frame *=
frame,
struct fra=
me *frame_fragment,
- =
struct link_socket_info *lsi)=
+ =
struct link_socket_info *lsi,
+ dco_conte=
xt_t *dco)
{
if (session->key[KS_P=
RIMARY].crypto_options.key_ctx_bi.initialized)
{
@@ -1638,6 +1639,25 @@
return false=
;
}
}
+
+ if (dco_enabled(options))
+ {
+ /* dco_set_peer() must be called if either keepalive or<=
/span>
+ * mssfix ar=
e set to update in-kernel config */
+ if (options->ping_send_timeout || frame->mss_=
fix)
+ {
+ int ret =3D d=
co_set_peer(dco, multi->dco_peer_id,
+ options->ping_sen=
d_timeout,
+ =
options->ping_rec_timeout,
+ fram=
e->mss_fix);
+ =
if (ret < 0)
+ {
+ =
msg(D_DCO, "Cannot set DCO peer parameters for peer (id=
=3D%u): %s",
+ =
multi->dco_peer_id, strerror(-ret));
+ return false;<=
br>+ }
+ }
return tls_ses=
sion_generate_data_channel_keys(multi, session);
}<=
br>
@@ -1646,7 +1666,8 @@
=
struct tls_session *session,
=
struct options *options, struct frame *frame,=
span>
struct frame *frame_fragme=
nt,
- =
struct link_socket_info *lsi)
+ struct link_socke=
t_info *lsi,
+ =
dco_context_t *dco)
{
=
if (!check_session_cipher(session, options))
=
{
@@ -1657,7 +1678,7 @@
session->=
opt->crypto_flags |=3D options->imported_protocol_flags;
return tls_session_update_crypto_params_do_work(=
multi, session, options,
- frame, frame_fragmen=
t, lsi);
+ =
frame, frame_fragment, lsi, dco);<=
/span>
}
diff=
--git a/src/openvpn/ssl.h b/src/openvpn/ssl.h
index 6c2bfc=
3..eea1323 100644
--- a/src/openvpn/ssl.h
+=
++ b/src/openvpn/ssl.h
@@ -460,6 +460,8 @@
=
* @param frame_fragment The fragment frame options.
* =
@param lsi link socket info to adjust MTU related options
* depending on the current protocol
+ * @param dco =
The dco context to perform dco_set_peer()
+ * whenever a crypto param =
update occurs.
*
* @return true if upda=
ting succeeded or keys are already generated, false otherwise. */
@@ -468,7 +470,8 @@
=
struct options *options,
=
struct frame *frame,
=
struct frame *frame_fragment,
+ struct link_socket_info =
*lsi,
+ =
dco_context_t *dco);
/*
* inline functions
To view, visit change 587. To unsubscribe, or for help writing mail filter= s, visit settings.