Skip to contentSkip to conversation

signal --dns support in peer info

PATCH Superseded Heiko Hund 4 participants 10 messages May 12, 2022 – Jun 28, 2022

lore
Share & tools
lore

Heiko Hund

author
#0 lore raw

PATCH 1/1 signal --dns support in peer info

Have clients set a bit in IV_PROTO, so that servers can make an informed decision on whether to push --dns to the client. While unknown options are ignored by clients when pushed, they generate a warning in the log. That can be circumvented by server backends by checking if bit 7 is set.

---
 src/openvpn/ssl.c | 4 ++--
 src/openvpn/ssl.h | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)
src/openvpn/ssl.c +2 -2
index 61dea996..12f51150 100644
@@ -1937,8 +1937,8 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
     /* These are the IV variable that are sent to peers in p2p mode */
     if (session->opt->push_peer_info_detail > 0)
     {
-        /* support for P_DATA_V2 */
-        int iv_proto = IV_PROTO_DATA_V2;
+        /* support for P_DATA_V2 and the --dns option */
+        int iv_proto = IV_PROTO_DATA_V2 & IV_PROTO_DNS_OPTION;
 
         /* support for receiving push_reply before sending
          * push request, also signal that the client wants
src/openvpn/ssl.h +3 -0
index 0ba86d3e..c8802707 100644
@@ -93,6 +93,9 @@
  * result. */
 #define IV_PROTO_NCP_P2P         (1<<5)
 
+/** Supports the --dns option introduced in version 2.6 */
+#define IV_PROTO_DNS_OPTION      (1<<6)
+
 /* Default field in X509 to be username */
 #define X509_USERNAME_FIELD_DEFAULT "CN"
 
Signature · 1 line
2.32.0
Acked-by on v1 1/1
#1 lore raw

Am 13.05.2022 um 01:11 schrieb Heiko Hund:

Quoted 4 lines

Have clients set a bit in IV_PROTO, so that servers can make an informed decision on whether to push --dns to the client. While unknown options are ignored by clients when pushed, they generate a warning in the log. That can be circumvented by server backends by checking if bit 7 is set.

#2 lore raw

Am 13.05.2022 um 09:14 schrieb Arne Schwabe:

Quoted 8 lines

Am 13.05.2022 um 01:11 schrieb Heiko Hund:

Quoted 4 lines

Have clients set a bit in IV_PROTO, so that servers can make an informed decision on whether to push --dns to the client. While unknown options are ignored by clients when pushed, they generate a warning in the log. That can be circumvented by server backends by checking if bit 7 is set.

I retract my ACK. David noticed that the & in the patch should be an | and I didn't look closely enough.

author
#3 lore raw
Quoted 11 lines · On Freitag, 13. Mai 2022 09:17:49 CEST Arne Schwabe wrote:

Am 13.05.2022 um 09:14 schrieb Arne Schwabe:

Quoted 7 lines

Am 13.05.2022 um 01:11 schrieb Heiko Hund:

Quoted 4 lines

Have clients set a bit in IV_PROTO, so that servers can make an informed decision on whether to push --dns to the client. While unknown options are ignored by clients when pushed, they generate a warning in the log. That can be circumvented by server backends by checking if bit 7 is set.

I retract my ACK. David noticed that the & in the patch should be an | and I didn't look closely enough.

Quite stupid, v2 incoming.

author
#4 lore raw

PATCH v2 1/1 signal --dns support in peer info

In reply to Heiko Hund

Have clients set a bit in IV_PROTO, so that servers can make an informed decision on whether to push --dns to the client. While unknown options are ignored by clients when pushed, they generate a warning in the log. That can be circumvented by server backends by checking if bit 7 is set.

---
 src/openvpn/ssl.c | 3 +++
 src/openvpn/ssl.h | 3 +++
 2 files changed, 6 insertions(+)
src/openvpn/ssl.c +3 -0
index 61dea996..24d7f3f4 100644
@@ -1940,6 +1940,9 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
         /* support for P_DATA_V2 */
         int iv_proto = IV_PROTO_DATA_V2;
 
+        /* support for the --dns option */
+        iv_proto |= IV_PROTO_DNS_OPTION;
+
         /* 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
src/openvpn/ssl.h +3 -0
index 0ba86d3e..c8802707 100644
@@ -93,6 +93,9 @@
  * result. */
 #define IV_PROTO_NCP_P2P         (1<<5)
 
+/** Supports the --dns option introduced in version 2.6 */
+#define IV_PROTO_DNS_OPTION      (1<<6)
+
 /* Default field in X509 to be username */
 #define X509_USERNAME_FIELD_DEFAULT "CN"
 
Signature · 1 line
2.32.0
Acked-by on v2 1/1
#5 lore raw
Quoted 30 lines · Heiko Hund

Have clients set a bit in IV_PROTO, so that servers can make an informed decision on whether to push --dns to the client. While unknown options are ignored by clients when pushed, they generate a warning in the log. That can be circumvented by server backends by checking if bit 7 is set.

---
  src/openvpn/ssl.c | 3 +++
  src/openvpn/ssl.h | 3 +++
  2 files changed, 6 insertions(+)
src/openvpn/ssl.c +3 -0
index 61dea996..24d7f3f4 100644
@@ -1940,6 +1940,9 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
          /* support for P_DATA_V2 */
          int iv_proto = IV_PROTO_DATA_V2;
 
+        /* support for the --dns option */
+        iv_proto |= IV_PROTO_DNS_OPTION;
+
          /* 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
src/openvpn/ssl.h +0 -0
index 0ba86d3e..c8802707 100644

src/openvpn/ssl.h line 101

Quoted 9 lines
src/openvpn/ssl.h +3 -0
@@ -93,6 +93,9 @@
   * result. */
  #define IV_PROTO_NCP_P2P         (1<<5)
 
+/** Supports the --dns option introduced in version 2.6 */
+#define IV_PROTO_DNS_OPTION      (1<<6)
+
  /* Default field in X509 to be username */
  #define X509_USERNAME_FIELD_DEFAULT "CN"
 

Only glared on the code and compile tested. LGTM.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#6 lore raw

Am 13.05.22 um 13:22 schrieb David Sommerseth:

Quoted 41 lines · Heiko Hund
Quoted 30 lines

Have clients set a bit in IV_PROTO, so that servers can make an informed decision on whether to push --dns to the client. While unknown options are ignored by clients when pushed, they generate a warning in the log. That can be circumvented by server backends by checking if bit 7 is set.

---
  src/openvpn/ssl.c | 3 +++
  src/openvpn/ssl.h | 3 +++

  2 files changed, 6 insertions(+)
src/openvpn/ssl.c +3 -0
index 61dea996..24d7f3f4 100644
@@ -1940,6 +1940,9 @@ push_peer_info(struct buffer *buf, struct 
 tls_session *session)
           /* support for P_DATA_V2 */
           int iv_proto = IV_PROTO_DATA_V2;
+        /* support for the --dns option */
+        iv_proto |= IV_PROTO_DNS_OPTION;
+
           /* 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
src/openvpn/ssl.h +0 -0
index 0ba86d3e..c8802707 100644

src/openvpn/ssl.h line 99

Quoted 7 lines
src/openvpn/ssl.h +3 -0
@@ -93,6 +93,9 @@
    * result. */
   #define IV_PROTO_NCP_P2P         (1<<5)
+/** Supports the --dns option introduced in version 2.6 */
+#define IV_PROTO_DNS_OPTION      (1<<6)
+
   /* Default field in X509 to be username */
   #define X509_USERNAME_FIELD_DEFAULT "CN"

Only glared on the code and compile tested.  LGTM.

Quoted 1 line

To be honest, I requested this flag but I don't think this is really what I want/need any more. I wanted to have a flag that tells me as a server that I can push --dns options instead of --dhcp-options and accept the client to evaluate them.

But after some digging, I found that on platforms where dhcp-option is NOT parsed by openvpn itself (so anything but Android and Windows) and scripts are used to set DNS, these scripts will always use dhcp-options as they rely on foreign_option support. So they end up with no DNS configuration if only --dns is pushed and using --dhcp-option options if both are pushed unless the script is updated.

I think having clear preference and not knowing will make debugging logs from 3rd parties that have both --dns and --dhcp-option in them quite tedious.

So this flag doesn't really do what I expected it to promose (This client will accept --dns and use them)

Arne

#7 lore raw

Hi,

Quoted 2 lines · Arne Schwabe

So this flag doesn't really do what I expected it to promose (This client will accept --dns and use them)

So you want something that goes hand in hand with code to actually "do something with it", like

+#if defined(TARGET_WINDOWS)||defined(TARGET_ANDROID)
+ /* we have full backend support for --dns options */
+ iv_proto |= IV_PROTO_DNS_OPTION;
+#endif

and whenever a platform gets a "real" implementation, be it "openvpn provided --up script parsing the correct variables" or "NM plugin" or "directly implemented by magic", we add it to that list?

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#8 lore raw
In reply to Arne Schwabe
Quoted 8 lines · Arne Schwabe

Am 13.05.22 um 13:22 schrieb David Sommerseth:

Quoted 7 lines · Heiko Hund
Quoted 6 lines

Have clients set a bit in IV_PROTO, so that servers can make an informed decision on whether to push --dns to the client. While unknown options are ignored by clients when pushed, they generate a warning in the log. That can be circumvented by server backends by checking if bit 7 is set.

[...snip...]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+        /* support for the --dns option */
+        iv_proto |= IV_PROTO_DNS_OPTION;
+

[...snip...]

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
src/openvpn/ssl.h +2 -0
+#define IV_PROTO_DNS_OPTION      (1<<6)
+

[...snip...]

Quoted 3 lines

To be honest, I requested this flag but I don't think this is really what I want/need any more. I wanted to have a flag that tells me as a server that I can push --dns options instead of --dhcp-options and accept the client to evaluate them.

But after some digging, I found that on platforms where dhcp-option is NOT parsed by openvpn itself (so anything but Android and Windows) and scripts are used to set DNS, these scripts will always use dhcp-options as they rely on foreign_option support. So they end up with no DNS configuration if only --dns is pushed and using --dhcp-option options if both are pushed unless the script is updated.

As I remember it, this wasn't initially about Android and Windows clients. It was about the server pushing both --dhcp-option DNS and --dns at the same time, and that OpenVPN 2.5 and older clients would complain about --dns option warnings. By signalling to a server who wants to avoid this (like the Access Server), the server can chose if it wants to send --dns or --dhcp-options, based on this flag.

Right?

That the client side isn't parsing --dns options properly is to my understanding a different issue, which also needs a solution. And if my memory isn't completely corrupted, we had some brief talks about v2.6 clients adding some kind of "conversion" from --dns to --dhcp-options *data* for scripts/plug-ins - but only in a simplistic best-effort approach. If the strict --dhcp-option behavior is needed, that can be used with v2.6 clients for the time being if --dns causes troubles.

But if both --dns and --dhcp-options are used, and the --dhcp-option provides a setting --dns support, --dns should take precedence.

This should also work fine, as the --dns option is far more flexible in what it supports, while --dhcp-options are just simpler by design - and designed around a lesser dynamic Internet world.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#9 lore raw
In reply to Heiko Hund

We had the ACK for this since a long time, but then had discussions on "is this what we really want", leading to the "DNS foreign option" patch committed just now - so after checking with Arne, this is now making sense for the server side intent ("if IV_PROTO contains the DNS bit, the server can stop pushing dhcp-options, because --dns will do all the job, and more, even for old-style platforms").

The patch itself is trivially correct "the bit is unique, and it is added" :-)

Your patch has been applied to the master branch.

commit 1f7f7d2a8943b5e33f86f208cce8f5d10c91a8f4

Author: Heiko Hund
Date:   Fri May 13 11:37:40 2022 +0200
     signal --dns support in peer info

     Signed-off-by: Heiko Hund <[email protected]...>
     Acked-by: David Sommerseth <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24350.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering