From: "plaisthos (Code Review)" Attention is currently required from: plaisthos. plaisthos uploaded patch set #3 to this change. <=
a href=3D"http://gerrit.openvpn.net/c/openvpn/+/452?usp=3Demail">View Chang=
eRename state_change to continue_tls_process
The name state_cha=
nge is more confusing than helpful as it not really
indicates if there w=
as a state change but rather if processing should
be continued. There ev=
en some states that are definitively state changes
(setting to_link buff=
er) that require continue_tls_process to be set
to false.
Change-=
Id: Ib6d713f2eb08a4c39d97de3e1a4a832cedc09585
---
M src/openvpn/ssl.c=
1 file changed, 28 insertions(+), 23 deletions(-)git pull ss=
h://gerrit.openvpn.net:29418/openvpn refs/changes/52/452/3
diff --=
git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index 400230c..=
20f4956 100644
--- a/src/openvpn/ssl.c
+++ =
b/src/openvpn/ssl.c
@@ -2694,7 +2694,7 @@
=
*/
static bool
read_incoming_tls_ciphert=
ext(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_D=
EBUG, "Incoming Ciphertext -> TLS");
}
return true;
@@ -2730,7 +2730,7 @@
static bool
read_incoming_tl=
s_plaintext(struct key_state *ks, struct buffer *buf,
- interval_t *wak=
eup, bool *state_change)
+ interval_t *wakeup, bool *continue_tls_pro=
cess)
{
ASSERT(buf_init(buf, 0));
@@ -2744,7 +2744,7 @@
}=
if (status =3D=3D 1)
{
- *state_change =3D true;=
+ *continue_t=
ls_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)=
span>
+write_outgoing_tls_ci=
phertext(struct tls_session *session, bool *continue_tls_process)
{
struct key_state *ks =3D &session->ke=
y[KS_PRIMARY];
@@ -2830,7 +2830,7 @@
reliable_mark_active_outgoing(ks=
->send_reliable, buf, opcode);
INCR_GENERAT=
ED;
- *state=
_change =3D true;
+ =
*continue_tls_process =3D true;
}=
dmsg(D_TLS_DEBUG, "Outgoing Ciphertext -> Reliab=
le");
}
@@ -2839,7 +2839,6 @@
return true;
}
<=
br>-
static bool=
tls_process_state(struct tls_multi *multi,
@@ -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
+ * i=
s nothing more to process or that further processing
+ * should only be done after the oute=
r loop (sending packets etc.)
+ * has run once more */
+ bool continue_tls_process =3D false;
=
struct key_state *ks =3D &session->key[KS_PRIMARY]; /* pri=
mary key */
/* Initial handshake */<=
/span>
if (ks->state =3D=3D S_INITIAL)
=
{
- state_chan=
ge =3D session_move_pre_start(session, ks, false);
+ continue_tls_process =3D session_mov=
e_pre_start(session, ks, false);
}
=
span>
/* 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 o=
ld X509 env variables */
tls_x509_clear_env(sessio=
n->opt->es);
@@ -2885,7 +2890,7 @@
=
&& reliable_empty(ks->send_reliable))
=
{
session_move_active(multi, session, to_link_so=
cket_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 @@
}
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 *buf =3D &ks->plaintext_read_buf;
if (!buf->len)
{
- if (!read_incoming_tls_plainte=
xt(ks, buf, wakeup, &state_change))
+ if (!read_incoming_tls_plaintext(ks, buf, wakeu=
p, &continue_tls_process))
{
=
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");
}@@ -2988,7 +2993,7 @@
}
=
if (status =3D=3D 1)
{
- state_change =3D true;
<=
span style=3D"color: hsl(120, 100%, 40%);">+ continue_tls_proces=
s =3D true;
dmsg(D_TLS_DEBUG, "Outgoing P=
laintext -> 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=
_process))
{
=
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 (continu=
e_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&qu=
ot;,
- stat=
e_change,
+ =
continue_tls_process,
state_name(ks->st=
ate),
state_name(ks_lame->state), to_link->len,
*wakeu=
p);
- state_chan=
ge =3D tls_process_state(multi, session, to_link, to_link_addr,
<=
span style=3D"color: hsl(0, 100%, 40%);">- =
to_link_socket_info, wakeup);
+ continue_tls_process =3D tls_process_state(multi,=
session, to_link, to_link_addr,
+ to_link_socke=
t_info, wakeup);
if (ks->stat=
e =3D=3D S_ERROR)
{
To view, visit change 452. To unsubscribe, or for help writing mail filter= s, visit settings.