[Openvpn-devel,v2] Change FULL_SYNC macro to no_pending_reliable_packets function

Message ID 20220426132324.76517-1-arne@rfc2549.org
State Accepted
Headers show
Series [Openvpn-devel,v2] Change FULL_SYNC macro to no_pending_reliable_packets function | expand

Commit Message

Arne Schwabe April 26, 2022, 3:23 a.m. UTC
This changes this macro to a better named inline function. This
introduces a slight whitespace problem but the next refactoring will
move the incorrectly intended block to its own function anyway.
---
 src/openvpn/ssl.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Gert Doering April 26, 2022, 3:40 a.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

As discussed on IRC, this is "13/28 v2, first half" (accidentially squashed).

Un-squashing these makes this one much clearer - only FULL_SYNC, and 
it does what it says on the lid.

Quick compile and client test passed.

Your patch has been applied to the master branch.

commit 04c3779922aed541755a20f415e7cb9d717ee7ed
Author: Arne Schwabe
Date:   Tue Apr 26 15:23:23 2022 +0200

     Change FULL_SYNC macro to no_pending_reliable_packets function

     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20220426132324.76517-1-arne@rfc2549.org>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24213.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index bad59f2a1..6c6648afa 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -1774,8 +1774,11 @@  flush_payload_buffer(struct key_state *ks)
 }
 
 /* true if no in/out acknowledgements pending */
-#define FULL_SYNC \
-    (reliable_empty(ks->send_reliable) && reliable_ack_empty(ks->rec_ack))
+static bool
+no_pending_reliable_packets(struct key_state *ks)
+{
+    return (reliable_empty(ks->send_reliable) && reliable_ack_empty(ks->rec_ack));
+}
 
 /*
  * Move the active key to the lame duck key and reinitialize the
@@ -2518,7 +2521,7 @@  tls_process(struct tls_multi *multi,
         }
 
         /* Wait for Initial Handshake ACK */
-        if (ks->state == S_PRE_START && FULL_SYNC)
+        if (ks->state == S_PRE_START && no_pending_reliable_packets(ks))
         {
             ks->state = S_START;
             state_change = true;
@@ -2544,7 +2547,7 @@  tls_process(struct tls_multi *multi,
         if (((ks->state == S_GOT_KEY && !session->opt->server)
              || (ks->state == S_SENT_KEY && session->opt->server)))
         {
-            if (FULL_SYNC)
+            if (no_pending_reliable_packets(ks))
             {
                 ks->established = now;
                 dmsg(D_TLS_DEBUG_MED, "STATE S_ACTIVE");