Browse code

Fix DNS options duplication on PUSH_UPDATE

Commit

2dfc4f ("dns: deal with --dhcp-options when --dns is active")

has removed reset of tuntap DNS options. Due to that, incoming --dns
options are added to existing ones instead of overwriting them.

It has also added a new storage for --dhcp-option. The push-update
code didn't clear it and as a result, incoming --dhcp-option options
were added to existing ones instead of overwriting them.

Fixed by:

- resetting tuntap DNS options (regression from abovementioned commit)
- clearing dhcp options storage in push-update code

GitHub: fixes OpenVPN/openvpn#804

Change-Id: Ife4d8fc5f8e2183e61226d66a76bbaa02c06f787
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Heiko Hund <heiko@openvpn.net>
Message-Id: <20250731122410.12200-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32448.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Lev Stipakov authored on 2025/07/31 21:24:05
Showing 1 changed files
... ...
@@ -3527,7 +3527,13 @@ tuntap_options_postprocess_dns(struct options *o)
3527 3527
 #endif /* if defined(_WIN32) */
3528 3528
 
3529 3529
     /* Copy --dns options to tuntap_options */
3530
+
3530 3531
     const struct dns_domain *d = dns->search_domains;
3532
+    if (d)
3533
+    {
3534
+        tt->domain_search_list_len = 0;
3535
+    }
3536
+
3531 3537
     while (d && tt->domain_search_list_len + 1 < N_SEARCH_LIST_LEN)
3532 3538
     {
3533 3539
         tt->domain_search_list[tt->domain_search_list_len++] = d->name;
... ...
@@ -3538,6 +3544,9 @@ tuntap_options_postprocess_dns(struct options *o)
3538 3538
         msg(M_WARN, "WARNING: couldn't copy all --dns search-domains to TUN/TAP");
3539 3539
     }
3540 3540
 
3541
+    tt->dns_len = 0;
3542
+    tt->dns6_len = 0;
3543
+
3541 3544
     const struct dns_server *s = dns->servers;
3542 3545
     while (s)
3543 3546
     {
... ...
@@ -6212,6 +6221,8 @@ update_option(struct context *c,
6212 6212
             }
6213 6213
             o->disable_nbt = 0;
6214 6214
             o->dhcp_options = 0;
6215
+
6216
+            CLEAR(options->dns_options.from_dhcp);
6215 6217
 #if defined(TARGET_ANDROID)
6216 6218
             o->http_proxy_port = 0;
6217 6219
             o->http_proxy = NULL;