From: "cron2 (Code Review)" Date: Sat, 2 Dec 2023 19:50:38 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <2c870bd1d082050b6c35cf0c4254aae3ff21be3b-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="5OKzxiglfiE="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Rename state_change to continue_tls_process List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --5OKzxiglfiE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#4) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/452?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by flichtenheld 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 Acked-by: Frank Lichtenheld Signed-off-by: Arne Schwabe Message-Id: <20231128103704.61046-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27= 571.html Signed-off-by: Gert Doering --- M src/openvpn/ssl.c 1 file changed, 28 insertions(+), 23 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/452/4 diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index b5d24b5..3e3696c 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -2694,7 +2694,7 @@ */ static bool read_incoming_tls_ciphertext(struct buffer *buf, struct key_state *ks, - bool *state_change) + bool *continue_tls_process) { int status =3D 0; if (buf->len) @@ -2714,7 +2714,7 @@ if (status =3D=3D 1) { reliable_mark_deleted(ks->rec_reliable, buf); - *state_change =3D true; + *continue_tls_process =3D true; dmsg(D_TLS_DEBUG, "Incoming Ciphertext -> TLS"); } return true; @@ -2730,7 +2730,7 @@ static bool read_incoming_tls_plaintext(struct key_state *ks, struct buffer *buf, - interval_t *wakeup, bool *state_change) + interval_t *wakeup, bool *continue_tls_process) { ASSERT(buf_init(buf, 0)); @@ -2744,7 +2744,7 @@ } if (status =3D=3D 1) { - *state_change =3D true; + *continue_tls_process =3D true; dmsg(D_TLS_DEBUG, "TLS -> Incoming Plaintext"); /* More data may be available, wake up again asap to check. */ @@ -2754,7 +2754,7 @@ } static bool -write_outgoing_tls_ciphertext(struct tls_session *session, bool *state_cha= nge) +write_outgoing_tls_ciphertext(struct tls_session *session, bool *continue_= tls_process) { struct key_state *ks =3D &session->key[KS_PRIMARY]; @@ -2830,7 +2830,7 @@ reliable_mark_active_outgoing(ks->send_reliable, buf, opcode); INCR_GENERATED; - *state_change =3D true; + *continue_tls_process =3D true; } dmsg(D_TLS_DEBUG, "Outgoing Ciphertext -> Reliable"); } @@ -2839,7 +2839,6 @@ return true; } - static bool tls_process_state(struct tls_multi *multi, struct tls_session *session, @@ -2848,13 +2847,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 +2877,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 +2890,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 +2932,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 +2943,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 +2959,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 +2975,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 +2993,7 @@ } if (status =3D=3D 1) { - state_change =3D true; + continue_tls_process =3D true; dmsg(D_TLS_DEBUG, "Outgoing Plaintext -> TLS"); } } @@ -2999,14 +3004,14 @@ buf =3D reliable_get_buf_output_sequenced(ks->send_reliable); if (buf) { - if (!write_outgoing_tls_ciphertext(session, &state_change)) + if (!write_outgoing_tls_ciphertext(session, &continue_tls_proc= ess)) { goto error; } } } - return state_change; + return continue_tls_process; error: tls_clear_error(); ks->state =3D S_ERROR; @@ -3065,19 +3070,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: 4 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --5OKzxiglfiE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #4 to the change originally cr= eated by plaisthos.

View Change

The following approvals got outdated= and were removed: Code-Review+2 by flichtenheld

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 shouldbe continued. There even some states that are definitively state changes<= br>(setting to_link buffer) that require continue_tls_process to be set
= to false.

Change-Id: Ib6d713f2eb08a4c39d97de3e1a4a832cedc09585
Ac= ked-by: Frank Lichtenheld <frank@...2641...>
Signed-off-by: Arne S= chwabe <arne@...1227...>
Message-Id: <20231128103704.61046-1-fr= ank@...2641...>
URL: https://www.mail-archive.com/openvpn-devel@...1697...= .sourceforge.net/msg27571.html
Signed-off-by: Gert Doering <gert@...1386...= 296...>
---
M src/openvpn/ssl.c
1 file changed, 28 insertions(+= ), 23 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvp=
n refs/changes/52/452/4
diff --git a/src/openvpn/ssl.c b/src/openvp=
n/ssl.c
index b5d24b5..3e3696c 100644
--- a= /src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
= @@ -2694,7 +2694,7 @@
*/
static bool
read_incoming_tls_ciphertext(struct buffer *buf, struct key_s= tate *ks,
- = bool *state_change)
+ bool *continue_tls_process)
{
int status =3D 0;
= if (buf->len)
@@ -2714,7 +2714,7 @@
= if (status =3D=3D 1)
{
re= liable_mark_deleted(ks->rec_reliable, buf);
- *state_change =3D true;
+ *continue_tls_process =3D true= ;
dmsg(D_TLS_DEBUG, "Incoming Ciphertext ->= ; TLS");
}
return true;
@@ -2730,7 +2730,7 @@

static= bool
read_incoming_tls_plaintext(struct key_state *ks, st= ruct buffer *buf,
- = interval_t *wakeup, bool *state_change)
<= span style=3D"color: hsl(120, 100%, 40%);">+ int= erval_t *wakeup, bool *continue_tls_process)

{
<= span> ASSERT(buf_init(buf, 0));


@@ -2= 744,7 +2744,7 @@
}
if (status =3D= =3D 1)
{
- *state_change =3D true;
+ *continue_tls_process =3D true;
dmsg(D_TLS_DEBUG, "TLS -> Incoming Plaintext");

/* More data may be available, wake = up again asap to check. */
@@ -2754,7 +2754,7 @@
= }

static bool
-write_outgoing_tls_ciphertext(struct tls_= session *session, bool *state_change)
+write_outgoing_tls_ciphertext(struct tls_session *session= , bool *continue_tls_process)
{
struc= t key_state *ks =3D &session->key[KS_PRIMARY];

@@ -2830,7 +2830,7 @@

= reliable_mark_active_outgoing(ks->send_reliable, buf, opcode);
INCR_GENERATED;
- *state_change =3D true;
+ *continue_tls_process =3D = true;
}
dmsg(D_TLS_DEBUG,= "Outgoing Ciphertext -> Reliable");
}
@@ -2839,7 +2839,6 @@
return true;

}

-
static bool
tls_process_state(= struct tls_multi *multi,
struct tls_sess= ion *session,
@@ -2848,13 +2847,19 @@
= struct link_socket_info *to_link_socket_info,
interval_t *wakeup)

{
- bool state_change =3D false;
+ /* This variable indi= cates if we should call this method
+ * again to process more incoming/outgoing TLS state/da= ta
+ * We want to= repeat this until we either determined that there
+ * is nothing more to process or that fu= rther processing
+ = * should only be done after the outer loop (sending packets etc.)<= br>+ * has run once more */=
+ bool continue_t= ls_process =3D false;
struct key_state *ks =3D &se= ssion->key[KS_PRIMARY]; /* primary key */
<= br> /* 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 o= ut on receive? */
@@ -2872,7 +2877,7 @@
= if (ks->state =3D=3D S_PRE_START && reliable_empty(ks->send= _reliable))
{
ks->state = =3D S_START;
- s= tate_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 +2890,7 @@
&& reliable_empty(ks= ->send_reliable))
{
sessio= n_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_MAX ACKs
@@ -2927,7 +2932,7 @@
}
<= span> else

{
- if (!read_incoming_tls_ciphertext(&= entry->buf, ks, &state_change))
+ if (!read_incoming_tls_ciphertext(&entry= ->buf, ks, &continue_tls_process))
{
goto error;
}
@@ -2938,7 +2943,7 @@
struct buffer *bu= f =3D &ks->plaintext_read_buf;
if (!buf->len= )
{
+ if (!r= ead_incoming_tls_plaintext(ks, buf, wakeup, &continue_tls_process))
{
goto error;
= }
@@ -2954,7 +2959,7 @@
= goto error;
}
- state_change =3D true;<= /span>
+ continue_tls= _process =3D true;
dmsg(D_TLS_DEBUG_MED, "STA= TE S_SENT_KEY");
ks->state =3D S_SENT_KEY;=
}
@@ -2970,7 +2975,7 @@
goto error;

}

- state_change =3D= true;
+ conti= nue_tls_process =3D true;
dmsg(D_TLS_DEBUG_MED, &q= uot;STATE S_GOT_KEY");
ks->state =3D S_GOT= _KEY;
}
@@ -2988,7 +2993,7 @@ }
if (status =3D=3D 1)
= {
- = state_change =3D true;
+ continue_tls_process =3D true;
= dmsg(D_TLS_DEBUG, "Outgoing Plaintext -> TLS");<= br> }
}
@@ -2999,14 +300= 4,14 @@
buf =3D reliable_get_buf_output_sequenced(= ks->send_reliable);
if (buf)
= {
- i= f (!write_outgoing_tls_ciphertext(session, &state_change))
+ if (!write_outgoing_= tls_ciphertext(session, &continue_tls_process))

= {
goto error;
= }
}
}
=
- return state_cha= nge;
+ return cont= inue_tls_process;
error:
tls_clear_er= ror();
ks->state =3D S_ERROR;
@@ -3= 065,19 +3070,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, se= ssion, to_link, to_link_addr,
- to_link_socket_info, wakeu= p);
+ continue= _tls_process =3D tls_process_state(multi, session, to_link, to_link_addr,
+ = to_link_socket_info, wakeup);
=
if (ks->state =3D=3D S_ERROR)
= {

To view, visit change 452. To uns= ubscribe, 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: 4
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--5OKzxiglfiE=--