Skip to contentSkip to conversation

Indicate that a client is in pull mode in IV_PROTO

PATCH Superseded Arne Schwabe 4 participants 7 messages Jul 20, 2020 – Jul 22, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]...

#1 lore raw

PATCH v2 1/9 Indicate that a client is in pull mode in IV_PROTO

This allows us to skip waiting for the first PUSH_REQUEST message from the client to send the response.

This changes the interpretation of IV_PROTO from a scalar to a bitfield Since we only have IV_PROTO=2 defined so far and will support DATA_V2 this should not make any problem. This avoid adding another IV_xxx variable that takes valuable space in the protocol frame.

Patch V2: Use bitmask for IV_PROTO_DATA_V2 and add more documentation.

---
 doc/man-sections/server-options.rst |  6 +++++-
 src/openvpn/multi.c                 | 12 ++++++++++--
 src/openvpn/ssl.c                   | 15 +++++++++++++--
 src/openvpn/ssl.h                   | 16 ++++++++++++++++
 4 files changed, 44 insertions(+), 5 deletions(-)
doc/man-sections/server-options.rst +5 -1
index c8e9fc61..e24cb135 100644
@@ -464,9 +464,13 @@ fast hardware. SSL/TLS authentication must be used in this mode.
   :code:`IV_LZ4=1`
         If the client supports LZ4 compressions.
 
-  :code:`IV_PROTO=2`
+  :code:`IV_PROTO=2` (bit 2)
         If the client supports peer-id floating mechanism
 
+  :code:`IV_PROTO=4` (bit 3)
+        When the client expects a push-reply and the server may
+        send this reply without waiting for a push-request first.
+
   :code:`IV_NCP=2`
         Negotiable ciphers, client supports ``--cipher`` pushed by
         the server, a value of 2 or greater indicates client supports
src/openvpn/multi.c +10 -2
index d9456f34..cb950db5 100644
@@ -1792,10 +1792,18 @@ multi_client_set_protocol_options(struct context *c)
     {
         int proto = 0;
         int r = sscanf(optstr, "IV_PROTO=%d", &proto);
-        if ((r == 1) && (proto >= 2))
+        if (r == 1)
         {
-            tls_multi->use_peer_id = true;
+            if (proto & IV_PROTO_DATA_V2)
+            {
+                tls_multi->use_peer_id = true;
+            }
+            if (proto & IV_PROTO_REQUEST_PUSH)
+            {
+                c->c2.push_request_received = true;
+            }
         }
+
     }
 
     /* Select cipher if client supports Negotiable Crypto Parameters */
src/openvpn/ssl.c +13 -2
index 54a23011..04d78a81 100644
@@ -2299,8 +2299,19 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
         buf_printf(&out, "IV_PLAT=win\n");
 #endif
 
-        /* support for P_DATA_V2 */
-        buf_printf(&out, "IV_PROTO=2\n");
+        /* support for P_DATA_V2*/
+        int iv_proto = IV_PROTO_DATA_V2;
+
+        /* support for receiving push_reply before sending
+         * push request, also signal that the client wants
+         * to get push-reply messages without without requiring a round
+         * trip for a push request message*/
+        if(session->opt->pull)
+        {
+            iv_proto |= IV_PROTO_REQUEST_PUSH;
+        }
+
+        buf_printf(&out, "IV_PROTO=%d\n", iv_proto);
 
         /* support for Negotiable Crypto Parameters */
         if (session->opt->ncp_enabled
src/openvpn/ssl.h +16 -0
index 58a9b0d4..81f8810e 100644
@@ -99,6 +99,22 @@
 /* Maximum length of OCC options string passed as part of auth handshake */
 #define TLS_OPTIONS_LEN 512
 
+/* Definitions of the bits in the IV_PROTO bitfield
+ *
+ * In older OpenVPN versions this used as comparision
+ * IV_PROTO >= 2 to determine if DATA_V2 is supported.
+ * Therefore any client announcing any of the flags must
+ * also announce IV_PROTO_DATA_V2. We also treat bit 0
+ * as reserved for this reason */
+
+/** Support P_DATA_V2 */
+#define IV_PROTO_DATA_V2        (1<<1)
+
+/** Assume client will send a push request and server does not need
+ * to wait for a push-request to send a push-reply */
+#define IV_PROTO_REQUEST_PUSH   (1<<2)
+
+
 /* Default field in X509 to be username */
 #define X509_USERNAME_FIELD_DEFAULT "CN"
 
Signature · 1 line
2.26.2
#2 lore raw

Hi,

Quoted 26 lines · Arne Schwabe

This allows us to skip waiting for the first PUSH_REQUEST message from the client to send the response.

This changes the interpretation of IV_PROTO from a scalar to a bitfield Since we only have IV_PROTO=2 defined so far and will support DATA_V2 this should not make any problem. This avoid adding another IV_xxx variable that takes valuable space in the protocol frame.

Patch V2: Use bitmask for IV_PROTO_DATA_V2 and add more documentation.

---
 doc/man-sections/server-options.rst |  6 +++++-
 src/openvpn/multi.c                 | 12 ++++++++++--
 src/openvpn/ssl.c                   | 15 +++++++++++++--
 src/openvpn/ssl.h                   | 16 ++++++++++++++++
 4 files changed, 44 insertions(+), 5 deletions(-)
doc/man-sections/server-options.rst +0 -0
index c8e9fc61..e24cb135 100644
@@ -464,9 +464,13 @@ fast hardware. SSL/TLS authentication must be used in this mode.
   :code:`IV_LZ4=1`

doc/man-sections/server-options.rst fast hardware. SSL/TLS authentication must be used in this mode. · line 473

Quoted 10 lines
doc/man-sections/server-options.rst +5 -1
         If the client supports LZ4 compressions.
 
-  :code:`IV_PROTO=2`
+  :code:`IV_PROTO=2` (bit 2)
         If the client supports peer-id floating mechanism
 
+  :code:`IV_PROTO=4` (bit 3)
+        When the client expects a push-reply and the server may
+        send this reply without waiting for a push-request first.
+

Maybe it's just me, but documenting a bitfield this way is a bit counter-intuitive. From the doc it seems to me that IV_PROTO can either have value "2" or value "4", not a combination of the two.

Maybe it's better to have something like:

IV_PROTO
- bit 2: ....
- bit 3: .....

So it's clear that both bits can be used when needed?
An alternative would be to explicitly mention that both values/bits can be used at the same time.

Opinions?

cheers,

Quoted 82 lines
doc/man-sections/server-options.rst +0 -0
   :code:`IV_NCP=2`
         Negotiable ciphers, client supports ``--cipher`` pushed by
         the server, a value of 2 or greater indicates client supports
src/openvpn/multi.c +10 -2
index d9456f34..cb950db5 100644
@@ -1792,10 +1792,18 @@ multi_client_set_protocol_options(struct context *c)
     {
         int proto = 0;
         int r = sscanf(optstr, "IV_PROTO=%d", &proto);
-        if ((r == 1) && (proto >= 2))
+        if (r == 1)
         {
-            tls_multi->use_peer_id = true;
+            if (proto & IV_PROTO_DATA_V2)
+            {
+                tls_multi->use_peer_id = true;
+            }
+            if (proto & IV_PROTO_REQUEST_PUSH)
+            {
+                c->c2.push_request_received = true;
+            }
         }
+
     }
 
     /* Select cipher if client supports Negotiable Crypto Parameters */
src/openvpn/ssl.c +13 -2
index 54a23011..04d78a81 100644
@@ -2299,8 +2299,19 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
         buf_printf(&out, "IV_PLAT=win\n");
 #endif
 
-        /* support for P_DATA_V2 */
-        buf_printf(&out, "IV_PROTO=2\n");
+        /* support for P_DATA_V2*/
+        int iv_proto = IV_PROTO_DATA_V2;
+
+        /* support for receiving push_reply before sending
+         * push request, also signal that the client wants
+         * to get push-reply messages without without requiring a round
+         * trip for a push request message*/
+        if(session->opt->pull)
+        {
+            iv_proto |= IV_PROTO_REQUEST_PUSH;
+        }
+
+        buf_printf(&out, "IV_PROTO=%d\n", iv_proto);
 
         /* support for Negotiable Crypto Parameters */
         if (session->opt->ncp_enabled
src/openvpn/ssl.h +16 -0
index 58a9b0d4..81f8810e 100644
@@ -99,6 +99,22 @@
 /* Maximum length of OCC options string passed as part of auth handshake */
 #define TLS_OPTIONS_LEN 512
 
+/* Definitions of the bits in the IV_PROTO bitfield
+ *
+ * In older OpenVPN versions this used as comparision
+ * IV_PROTO >= 2 to determine if DATA_V2 is supported.
+ * Therefore any client announcing any of the flags must
+ * also announce IV_PROTO_DATA_V2. We also treat bit 0
+ * as reserved for this reason */
+
+/** Support P_DATA_V2 */
+#define IV_PROTO_DATA_V2        (1<<1)
+
+/** Assume client will send a push request and server does not need
+ * to wait for a push-request to send a push-reply */
+#define IV_PROTO_REQUEST_PUSH   (1<<2)
+
+
 /* Default field in X509 to be username */
 #define X509_USERNAME_FIELD_DEFAULT "CN"
 
Signature · 1 line
Antonio Quartulli
#3 lore raw

PATCH v3 1/9 Indicate that a client is in pull mode in IV_PROTO

This allows us to skip waiting for the first PUSH_REQUEST message from the client to send the response.

This changes the interpretation of IV_PROTO from a scalar to a bitfield Since we only have IV_PROTO=2 defined so far and will support DATA_V2 this should not make any problem. This avoid adding another IV_xxx variable that takes valuable space in the protocol frame.

Patch V2: Use bitmask for IV_PROTO_DATA_V2 and add more documentation.

Patch V3: Rewrite IV_PROTO paragraph in man page, incoperate spelling fixes
by tincanteksup.

---
 doc/man-sections/server-options.rst | 10 ++++++++--
 src/openvpn/multi.c                 | 12 ++++++++++--
 src/openvpn/ssl.c                   | 15 +++++++++++++--
 src/openvpn/ssl.h                   | 16 ++++++++++++++++
 4 files changed, 47 insertions(+), 6 deletions(-)
doc/man-sections/server-options.rst +8 -2
index c8e9fc61..babf33d3 100644
@@ -464,8 +464,14 @@ fast hardware. SSL/TLS authentication must be used in this mode.
   :code:`IV_LZ4=1`
         If the client supports LZ4 compressions.
 
-  :code:`IV_PROTO=2`
-        If the client supports peer-id floating mechanism
+  :code:`IV_PROTO`
+    Details about protocol extensions that the peer supports. The
+    variable is a bitfield and the bits are defined as follows
+    (starting a bit 0 for the first (unused) bit:
+
+    - bit 1: The peer supports peer-id floating mechanism
+    - bit 2: The client expects a push-reply and the server may
+      send this reply without waiting for a push-request first.
 
   :code:`IV_NCP=2`
         Negotiable ciphers, client supports ``--cipher`` pushed by
src/openvpn/multi.c +10 -2
index 2ae9c03e..b83a0f06 100644
@@ -1792,10 +1792,18 @@ multi_client_set_protocol_options(struct context *c)
     {
         int proto = 0;
         int r = sscanf(optstr, "IV_PROTO=%d", &proto);
-        if ((r == 1) && (proto >= 2))
+        if (r == 1)
         {
-            tls_multi->use_peer_id = true;
+            if (proto & IV_PROTO_DATA_V2)
+            {
+                tls_multi->use_peer_id = true;
+            }
+            if (proto & IV_PROTO_REQUEST_PUSH)
+            {
+                c->c2.push_request_received = true;
+            }
         }
+
     }
 
     /* Select cipher if client supports Negotiable Crypto Parameters */
src/openvpn/ssl.c +13 -2
index 54a23011..04d78a81 100644
@@ -2299,8 +2299,19 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
         buf_printf(&out, "IV_PLAT=win\n");
 #endif
 
-        /* support for P_DATA_V2 */
-        buf_printf(&out, "IV_PROTO=2\n");
+        /* support for P_DATA_V2*/
+        int iv_proto = IV_PROTO_DATA_V2;
+
+        /* support for receiving push_reply before sending
+         * push request, also signal that the client wants
+         * to get push-reply messages without without requiring a round
+         * trip for a push request message*/
+        if(session->opt->pull)
+        {
+            iv_proto |= IV_PROTO_REQUEST_PUSH;
+        }
+
+        buf_printf(&out, "IV_PROTO=%d\n", iv_proto);
 
         /* support for Negotiable Crypto Parameters */
         if (session->opt->ncp_enabled
src/openvpn/ssl.h +16 -0
index 58a9b0d4..0da16974 100644
@@ -99,6 +99,22 @@
 /* Maximum length of OCC options string passed as part of auth handshake */
 #define TLS_OPTIONS_LEN 512
 
+/* Definitions of the bits in the IV_PROTO bitfield
+ *
+ * In older OpenVPN versions this used in a comparison
+ * IV_PROTO >= 2 to determine if DATA_V2 is supported.
+ * Therefore any client announcing any of the flags must
+ * also announce IV_PROTO_DATA_V2. We also treat bit 0
+ * as reserved for this reason */
+
+/** Support P_DATA_V2 */
+#define IV_PROTO_DATA_V2        (1<<1)
+
+/** Assume client will send a push request and server does not need
+ * to wait for a push-request to send a push-reply */
+#define IV_PROTO_REQUEST_PUSH   (1<<2)
+
+
 /* Default field in X509 to be username */
 #define X509_USERNAME_FIELD_DEFAULT "CN"
 
Signature · 1 line
2.26.2
#4 lore raw

1x spelling 1x grammar

Quoted 8 lines · Arne Schwabe

This allows us to skip waiting for the first PUSH_REQUEST message from the client to send the response.

This changes the interpretation of IV_PROTO from a scalar to a bitfield Since we only have IV_PROTO=2 defined so far and will support DATA_V2 this should not make any problem. This avoid adding another IV_xxx variable that takes valuable space in the protocol frame.

Quoted 6 lines

Patch V2: Use bitmask for IV_PROTO_DATA_V2 and add more documentation.

Patch V3: Rewrite IV_PROTO paragraph in man page, incoperate spelling fixes
by tincanteksup.

incoperate -> incorporate =]

Please feel free use my full details:
Richard Bonhomme <[email protected]...>

Quoted 86 lines
---
  doc/man-sections/server-options.rst | 10 ++++++++--
  src/openvpn/multi.c                 | 12 ++++++++++--
  src/openvpn/ssl.c                   | 15 +++++++++++++--
  src/openvpn/ssl.h                   | 16 ++++++++++++++++
  4 files changed, 47 insertions(+), 6 deletions(-)
doc/man-sections/server-options.rst +8 -2
index c8e9fc61..babf33d3 100644
@@ -464,8 +464,14 @@ fast hardware. SSL/TLS authentication must be used in this mode.
    :code:`IV_LZ4=1`
          If the client supports LZ4 compressions.
 
-  :code:`IV_PROTO=2`
-        If the client supports peer-id floating mechanism
+  :code:`IV_PROTO`
+    Details about protocol extensions that the peer supports. The
+    variable is a bitfield and the bits are defined as follows
+    (starting a bit 0 for the first (unused) bit:
+
+    - bit 1: The peer supports peer-id floating mechanism
+    - bit 2: The client expects a push-reply and the server may
+      send this reply without waiting for a push-request first.
 
    :code:`IV_NCP=2`
          Negotiable ciphers, client supports ``--cipher`` pushed by
src/openvpn/multi.c +10 -2
index 2ae9c03e..b83a0f06 100644
@@ -1792,10 +1792,18 @@ multi_client_set_protocol_options(struct context *c)
      {
          int proto = 0;
          int r = sscanf(optstr, "IV_PROTO=%d", &proto);
-        if ((r == 1) && (proto >= 2))
+        if (r == 1)
          {
-            tls_multi->use_peer_id = true;
+            if (proto & IV_PROTO_DATA_V2)
+            {
+                tls_multi->use_peer_id = true;
+            }
+            if (proto & IV_PROTO_REQUEST_PUSH)
+            {
+                c->c2.push_request_received = true;
+            }
          }
+
      }
 
      /* Select cipher if client supports Negotiable Crypto Parameters */
src/openvpn/ssl.c +13 -2
index 54a23011..04d78a81 100644
@@ -2299,8 +2299,19 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
          buf_printf(&out, "IV_PLAT=win\n");
  #endif
 
-        /* support for P_DATA_V2 */
-        buf_printf(&out, "IV_PROTO=2\n");
+        /* support for P_DATA_V2*/
+        int iv_proto = IV_PROTO_DATA_V2;
+
+        /* support for receiving push_reply before sending
+         * push request, also signal that the client wants
+         * to get push-reply messages without without requiring a round
+         * trip for a push request message*/
+        if(session->opt->pull)
+        {
+            iv_proto |= IV_PROTO_REQUEST_PUSH;
+        }
+
+        buf_printf(&out, "IV_PROTO=%d\n", iv_proto);
 
          /* support for Negotiable Crypto Parameters */
          if (session->opt->ncp_enabled
src/openvpn/ssl.h +0 -0
index 58a9b0d4..0da16974 100644

src/openvpn/ssl.h line 104

Quoted 6 lines
src/openvpn/ssl.h +3 -0
@@ -99,6 +99,22 @@
  /* Maximum length of OCC options string passed as part of auth handshake */
  #define TLS_OPTIONS_LEN 512
 
+/* Definitions of the bits in the IV_PROTO bitfield
+ *
+ * In older OpenVPN versions this used in a comparison

In older OpenVPN versions this used in a comparison -> In older OpenVPN versions this is used in a comparison

Quoted 17 lines
src/openvpn/ssl.h +13 -0
+ * IV_PROTO >= 2 to determine if DATA_V2 is supported.
+ * Therefore any client announcing any of the flags must
+ * also announce IV_PROTO_DATA_V2. We also treat bit 0
+ * as reserved for this reason */
+
+/** Support P_DATA_V2 */
+#define IV_PROTO_DATA_V2        (1<<1)
+
+/** Assume client will send a push request and server does not need
+ * to wait for a push-request to send a push-reply */
+#define IV_PROTO_REQUEST_PUSH   (1<<2)
+
+
  /* Default field in X509 to be username */
  #define X509_USERNAME_FIELD_DEFAULT "CN"
 
#5 lore raw
In reply to Arne Schwabe

Hi,

Quoted 8 lines · Arne Schwabe

This allows us to skip waiting for the first PUSH_REQUEST message from the client to send the response.

This changes the interpretation of IV_PROTO from a scalar to a bitfield Since we only have IV_PROTO=2 defined so far and will support DATA_V2 this should not make any problem. This avoid adding another IV_xxx variable that takes valuable space in the protocol frame.

Quoted 8 lines

Patch V2: Use bitmask for IV_PROTO_DATA_V2 and add more documentation.

Patch V3: Rewrite IV_PROTO paragraph in man page, incoperate spelling fixes
by tincanteksup.

Thanks a lot for all the fixes. Looks good to me now.

Signature · 1 line
Antonio Quartulli
Acked-by on v3 1/9
#6 lore raw
In reply to Arne Schwabe

Stared at code, loooks good.

Tested the client side against an unpatched server -> works (which is not surprising, but worth a test).

Then patched the server, tested the patched client again -> works \o/

Jul 22 10:09:15 gentoo tun-tcp-p2mp[5572]: 194.97.140.21:50479 peer info: IV_PROTO=6
Jul 22 10:09:15 gentoo tun-tcp-p2mp[5572]: ... SENT CONTROL [cron2-freebsd-tc-amd64]: 'PUSH_REPLY,...'
Jul 22 10:09:17 gentoo tun-tcp-p2mp[5572]: ... PUSH: Received control message: 'PUSH_REQUEST'

(saves 1-2 seconds - coarse timers on the client side...)

The client side state machine is not truly convincing me yet, though - while this works as it is, the client does not properly register that it already *has* a PUSH_REPLY, so keeps sending PUSH_REQUESTS until the server gives in after 30s (NO-SOUP debounce timer) and sends another PUSH_REPLY:

2020-07-22 10:14:26 [server] Peer Connection Initiated with [AF_INET6]2001:608:0:814::f000:11:51198
2020-07-22 10:14:26 PUSH: Received control message: 'PUSH_REPLY,route 10.204.0.0 ...'
[tun/route init stuff, crypto init, ...]
2020-07-22 10:14:26 Initialization Sequence Completed
2020-07-22 10:14:27 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
2020-07-22 10:14:32 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
2020-07-22 10:14:37 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
2020-07-22 10:14:42 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
2020-07-22 10:14:47 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
2020-07-22 10:14:52 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
2020-07-22 10:14:57 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
2020-07-22 10:14:57 PUSH: Received control message: 'PUSH_REPLY,route 10.204.0.0 ...

I decided to keep the patch and improve on the client side later :-) - and *then* ran the full test with 2.2/2.3/2.4/master(patched) against the same server, and AGES later...

22...
Test sets succeeded: 1 2 3 4 6 8.
Test sets failed: none.
..
master...
Test sets succeeded: 1 1a 1b 1c 1d 1e 2 2a 2b 2c 2d 2e 2f 3 4 5 5a 5b 5c 5v1 5v2 5v3 5w1 5w2 5w3 5w4 5x1 5x2 5x3 5x4 6 7 7x 8 8a 9 4b. Test sets failed: none.

My RTTs are too low to make a difference wrt packets RTTs, but the "coarse timer on client" delay alone makes this an improvement.

Your patch has been applied to the master branch.

commit c290df558f8df995f1eeb3ddbf408508a455273e

Author: Arne Schwabe
Date:   Tue Jul 21 18:38:11 2020 +0200
     Indicate that a client is in pull mode in IV_PROTO

     Signed-off-by: Arne Schwabe <[email protected]...>
     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg20525.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#7 lore raw
In reply to Arne Schwabe

Hi,

Quoted 95 lines · Arne Schwabe

This allows us to skip waiting for the first PUSH_REQUEST message from the client to send the response.

This changes the interpretation of IV_PROTO from a scalar to a bitfield Since we only have IV_PROTO=2 defined so far and will support DATA_V2 this should not make any problem. This avoid adding another IV_xxx variable that takes valuable space in the protocol frame.

Patch V2: Use bitmask for IV_PROTO_DATA_V2 and add more documentation.

---
  doc/man-sections/server-options.rst |  6 +++++-
  src/openvpn/multi.c                 | 12 ++++++++++--
  src/openvpn/ssl.c                   | 15 +++++++++++++--
  src/openvpn/ssl.h                   | 16 ++++++++++++++++
  4 files changed, 44 insertions(+), 5 deletions(-)
doc/man-sections/server-options.rst +5 -1
index c8e9fc61..e24cb135 100644
@@ -464,9 +464,13 @@ fast hardware. SSL/TLS authentication must be used in this mode.
    :code:`IV_LZ4=1`
          If the client supports LZ4 compressions.
 
-  :code:`IV_PROTO=2`
+  :code:`IV_PROTO=2` (bit 2)
          If the client supports peer-id floating mechanism
 
+  :code:`IV_PROTO=4` (bit 3)
+        When the client expects a push-reply and the server may
+        send this reply without waiting for a push-request first.
+
    :code:`IV_NCP=2`
          Negotiable ciphers, client supports ``--cipher`` pushed by
          the server, a value of 2 or greater indicates client supports
src/openvpn/multi.c +10 -2
index d9456f34..cb950db5 100644
@@ -1792,10 +1792,18 @@ multi_client_set_protocol_options(struct context *c)
      {
          int proto = 0;
          int r = sscanf(optstr, "IV_PROTO=%d", &proto);
-        if ((r == 1) && (proto >= 2))
+        if (r == 1)
          {
-            tls_multi->use_peer_id = true;
+            if (proto & IV_PROTO_DATA_V2)
+            {
+                tls_multi->use_peer_id = true;
+            }
+            if (proto & IV_PROTO_REQUEST_PUSH)
+            {
+                c->c2.push_request_received = true;
+            }
          }
+
      }
 
      /* Select cipher if client supports Negotiable Crypto Parameters */
src/openvpn/ssl.c +13 -2
index 54a23011..04d78a81 100644
@@ -2299,8 +2299,19 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
          buf_printf(&out, "IV_PLAT=win\n");
  #endif
 
-        /* support for P_DATA_V2 */
-        buf_printf(&out, "IV_PROTO=2\n");
+        /* support for P_DATA_V2*/
+        int iv_proto = IV_PROTO_DATA_V2;
+
+        /* support for receiving push_reply before sending
+         * push request, also signal that the client wants
+         * to get push-reply messages without without requiring a round
+         * trip for a push request message*/
+        if(session->opt->pull)
+        {
+            iv_proto |= IV_PROTO_REQUEST_PUSH;
+        }
+
+        buf_printf(&out, "IV_PROTO=%d\n", iv_proto);
 
          /* support for Negotiable Crypto Parameters */
          if (session->opt->ncp_enabled
src/openvpn/ssl.h +0 -0
index 58a9b0d4..81f8810e 100644

src/openvpn/ssl.h line 104

Quoted 6 lines
src/openvpn/ssl.h +3 -0
@@ -99,6 +99,22 @@
  /* Maximum length of OCC options string passed as part of auth handshake */
  #define TLS_OPTIONS_LEN 512
 
+/* Definitions of the bits in the IV_PROTO bitfield
+ *
+ * In older OpenVPN versions this used as comparision

comparision -> comparison

Also, paragraph are not make sense to me .. ?

Quoted 17 lines
src/openvpn/ssl.h +13 -0
+ * IV_PROTO >= 2 to determine if DATA_V2 is supported.
+ * Therefore any client announcing any of the flags must
+ * also announce IV_PROTO_DATA_V2. We also treat bit 0
+ * as reserved for this reason */
+
+/** Support P_DATA_V2 */
+#define IV_PROTO_DATA_V2        (1<<1)
+
+/** Assume client will send a push request and server does not need
+ * to wait for a push-request to send a push-reply */
+#define IV_PROTO_REQUEST_PUSH   (1<<2)
+
+
  /* Default field in X509 to be username */
  #define X509_USERNAME_FIELD_DEFAULT "CN"