From: "plaisthos (Code Review)" Date: Mon, 20 Nov 2023 13:02:36 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="uVYcNCwvIH0="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Rename state_change to continue_tls_process List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --uVYcNCwvIH0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/452?usp=3Demail to review the following change. Change subject: Rename state_change to continue_tls_process ...................................................................... Rename state_change to continue_tls_process The name state_change is more confusing than helpful as it not really indicates if there was a state change but rather if processing should be continued. There even some states that are definitively state changes (setting to_link buffer) that require continue_tls_process to be set to false. Change-Id: Ib6d713f2eb08a4c39d97de3e1a4a832cedc09585 --- M src/openvpn/ssl.c 1 file changed, 21 insertions(+), 15 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/452/1 diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index b4cd8f5..f46b661 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -2848,13 +2848,19 @@ struct link_socket_info *to_link_socket_info, interval_t *wakeup) { - bool state_change =3D false; + /* This variable indicates if we should call this method + * again to process more incoming/outgoing TLS state/data + * We want to repeat this until we either determined that there + * is nothing more to process or that further processing + * should only be done after the outer loop (sending packets etc.) + * has run once more */ + bool continue_tls_process =3D false; struct key_state *ks =3D &session->key[KS_PRIMARY]; /* primary ke= y */ /* Initial handshake */ if (ks->state =3D=3D S_INITIAL) { - state_change =3D session_move_pre_start(session, ks, false); + continue_tls_process =3D session_move_pre_start(session, ks, false= ); } /* Are we timed out on receive? */ @@ -2872,7 +2878,7 @@ if (ks->state =3D=3D S_PRE_START && reliable_empty(ks->send_reliable)) { ks->state =3D S_START; - state_change =3D true; + continue_tls_process =3D true; /* New connection, remove any old X509 env variables */ tls_x509_clear_env(session->opt->es); @@ -2885,7 +2891,7 @@ && reliable_empty(ks->send_reliable)) { session_move_active(multi, session, to_link_socket_info, ks); - state_change =3D true; + continue_tls_process =3D true; } /* Reliable buffer to outgoing TCP/UDP (send up to CONTROL_SEND_ACK_MA= X ACKs @@ -2927,7 +2933,7 @@ } else { - if (!read_incoming_tls_ciphertext(&entry->buf, ks, &state_chan= ge)) + if (!read_incoming_tls_ciphertext(&entry->buf, ks, &continue_t= ls_process)) { goto error; } @@ -2938,7 +2944,7 @@ struct buffer *buf =3D &ks->plaintext_read_buf; if (!buf->len) { - if (!read_incoming_tls_plaintext(ks, buf, wakeup, &state_change)) + if (!read_incoming_tls_plaintext(ks, buf, wakeup, &continue_tls_pr= ocess)) { goto error; } @@ -2954,7 +2960,7 @@ goto error; } - state_change =3D true; + continue_tls_process =3D true; dmsg(D_TLS_DEBUG_MED, "STATE S_SENT_KEY"); ks->state =3D S_SENT_KEY; } @@ -2970,7 +2976,7 @@ goto error; } - state_change =3D true; + continue_tls_process =3D true; dmsg(D_TLS_DEBUG_MED, "STATE S_GOT_KEY"); ks->state =3D S_GOT_KEY; } @@ -2988,7 +2994,7 @@ } if (status =3D=3D 1) { - state_change =3D true; + continue_tls_process =3D true; dmsg(D_TLS_DEBUG, "Outgoing Plaintext -> TLS"); } } @@ -3006,7 +3012,7 @@ } } - return state_change; + return continue_tls_process; error: tls_clear_error(); ks->state =3D S_ERROR; @@ -3065,19 +3071,19 @@ msg(D_TLS_DEBUG_LOW, "TLS: tls_process: killed expiring key"); } - bool state_change =3D true; - while (state_change) + bool continue_tls_process =3D true; + while (continue_tls_process) { update_time(); dmsg(D_TLS_DEBUG, "TLS: tls_process: chg=3D%d ks=3D%s lame=3D%s to= _link->len=3D%d wakeup=3D%d", - state_change, + continue_tls_process, state_name(ks->state), state_name(ks_lame->state), to_link->len, *wakeup); - state_change =3D tls_process_state(multi, session, to_link, to_lin= k_addr, - to_link_socket_info, wakeup); + continue_tls_process =3D tls_process_state(multi, session, to_link= , to_link_addr, + to_link_socket_info, wake= up); if (ks->state =3D=3D S_ERROR) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/452?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: Ib6d713f2eb08a4c39d97de3e1a4a832cedc09585 Gerrit-Change-Number: 452 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --uVYcNCwvIH0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

Rename state_change to continue_tls_process

The name s= tate_change is more confusing than helpful as it not really
indicates if= there was a state change but rather if processing should
be continued. = There even some states that are definitively state changes
(setting to_l= ink buffer) that require continue_tls_process to be set
to false.
Change-Id: Ib6d713f2eb08a4c39d97de3e1a4a832cedc09585
---
M src/openv= pn/ssl.c
1 file changed, 21 insertions(+), 15 deletions(-)

=
git=
 pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/452/1
= diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index b4= cd8f5..f46b661 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -2848,13 +2848,19 @@ struct link_socket_info *to_link_socket_info,
interval_t *wakeup)
{

- bool state_change =3D= false;
+ /* This = variable indicates if we should call this method
+ * again to process more incoming/outgoing= TLS state/data
+ = * We want to repeat this until we either determined that there
<= span style=3D"color: hsl(120, 100%, 40%);">+ * is nothing more to proce= ss or that further processing
+ * should only be done after the outer loop (sending packets = etc.)
+ * has run= once more */
+ bo= ol continue_tls_process =3D false;
struct key_state *k= s =3D &session->key[KS_PRIMARY]; /* primary key */

/* Initial handshake */
if = (ks->state =3D=3D S_INITIAL)
{
- state_change =3D session_move_pre_= start(session, ks, false);
+ continue_tls_process =3D session_move_pre_start(session, ks,= false);
}

/* A= re we timed out on receive? */
@@ -2872,7 +2878,7 @@=
if (ks->state =3D=3D S_PRE_START && reliable_empt= y(ks->send_reliable))
{
ks= ->state =3D S_START;
- state_change =3D true;
+ continue_tls_process =3D true;

/* New connection, remove any old X509 env variables */=
tls_x509_clear_env(session->opt->es);
@@ -2885,7 +2891,7 @@
&& reliab= le_empty(ks->send_reliable))
{
= session_move_active(multi, session, to_link_socket_info, ks);- state_change =3D true;=
+ continue_tl= s_process =3D true;
}

/* Reliable buffer to outgoing TCP/UDP (send up to CONTROL_SEND_ACK_= MAX ACKs

@@ -2927,7 +2933,7 @@
}
else
{
- if (!read_incoming_tls_cipher= text(&entry->buf, ks, &state_change))
+ if (!read_incoming_tls_ciphertext(= &entry->buf, ks, &continue_tls_process))
= {
goto error;
= }
@@ -2938,7 +2944,7 @@
struct = buffer *buf =3D &ks->plaintext_read_buf;
if (!b= uf->len)
{
- if (!read_incoming_tls_plaintext(ks, buf, wakeup, &= ;state_change))
+ = if (!read_incoming_tls_plaintext(ks, buf, wakeup, &continue_tls_pro= cess))
{
goto error;<= /span>
}
@@ -2954,7 +2960,7 @@
= goto error;
}
=
- state_change = =3D true;
+ co= ntinue_tls_process =3D true;
dmsg(D_TLS_DEBUG_MED,= "STATE S_SENT_KEY");
ks->state =3D S= _SENT_KEY;
}
@@ -2970,7 +2976,7 @@
goto error;
}
=
- state_= change =3D true;
+ = continue_tls_process =3D true;
dmsg(D_TLS_DEB= UG_MED, "STATE S_GOT_KEY");
ks->state= =3D S_GOT_KEY;
}
@@ -2988,7 +2994,7 @= @
}
if (status =3D=3D 1)<= /span>
{
- state_change =3D true;
+ continue_tls_process =3D true;
dmsg(D_TLS_DEBUG, "Outgoing Plaintext -> TLS"= );

}
}
@@ -30= 06,7 +3012,7 @@
}
}
- return st= ate_change;
+ retu= rn continue_tls_process;
error:
tls_c= lear_error();
ks->state =3D S_ERROR;
@@ -3065,19 +3071,19 @@

msg(D_TLS_DEBUG_LOW, &qu= ot;TLS: tls_process: killed expiring key");
}

- boo= l state_change =3D true;
+ bool continue_tls_process =3D true;
+ while (continue_tls_process)
{

update_time();
dmsg(D_TLS_DEBUG, "TLS: tls_process: chg=3D%d ks=3D%s= lame=3D%s to_link->len=3D%d wakeup=3D%d",
- state_change,
+ continue_tls_process,
state_name(ks->state),
= state_name(ks_lame->state),
to_link= ->len,
*wakeup);
- state_change =3D tls_process_state(mult= i, session, to_link, to_link_addr,
- to_link_socket_info, = wakeup);
+ con= tinue_tls_process =3D tls_process_state(multi, session, to_link, to_link_ad= dr,
+ = to_link_socket_info, wakeup);

if (ks->state =3D=3D S_ERROR)
<= span> {


To view, visit change 452. = To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib6d713f2eb08a4c39d97de3e1a4= a832cedc09585
Gerrit-Change-Number: 452
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--uVYcNCwvIH0=--