[Openvpn-devel,v1] Make --dns options apply for tap-windows6 driver

Message ID 20231115120623.6442-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v1] Make --dns options apply for tap-windows6 driver | expand

Commit Message

Gert Doering Nov. 15, 2023, 12:06 p.m. UTC
From: Lev Stipakov <lev@openvpn.net>

When tap-windows6 driver is used, both --dhcp-option and
--dns options are applied with DHCP. When processing --dns options,
we don't set "tuntap_options.dhcp_options" member, which is required
for DHCP string to be sent to the driver. As a result, --dns options
are not applied at all.

Fix by adding missing assignment of tuntap_options.dhcp_options.

Fixes https://github.com/OpenVPN/openvpn/issues/447

Change-Id: I24f43ad319bd1ca530fe17442d02a97412eb75c7
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/427
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>

Comments

Gert Doering Nov. 15, 2023, 2:45 p.m. UTC | #1
Haven't tested this for real, but it looks very reasonable.  Just inject
the proper flag on "--dns", the backend data structures are already
filled, we just didn't know that we should use them.

Sanity tested via GHA build.

Your patch has been applied to the master and release/2.6 branch 
(bugfix, --dns functionality not working right on Windows).

commit 60def50420b050e628f4388e3c9ff771eb70a549 (master)
commit 0acba3cc64064841224f7ea4484e4d9715a42897 (HEAD -> release/2.6)
Author: Lev Stipakov
Date:   Wed Nov 15 13:06:23 2023 +0100

     Make --dns options apply for tap-windows6 driver

     Signed-off-by: Lev Stipakov <lev@openvpn.net>
     Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
     Message-Id: <20231115120623.6442-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27402.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index b88fea9..abd2e0c 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -1364,6 +1364,8 @@ 
         {
             msg(M_WARN, "WARNING: couldn't copy all --dns search-domains to --dhcp-option");
         }
+
+        tt->dhcp_options |= DHCP_OPTIONS_DHCP_REQUIRED;
     }
 
     if (dns->servers)
@@ -1401,6 +1403,7 @@ 
         {
             msg(M_WARN, "WARNING: couldn't copy all --dns server addresses to --dhcp-option");
         }
+        tt->dhcp_options |= DHCP_OPTIONS_DHCP_OPTIONAL;
     }
 }
 #else /* if defined(_WIN32) || defined(TARGET_ANDROID) */