Skip to contentSkip to conversation

Change in openvpn[master]: Preserve --dhcp-option values from local config

Openvpn-devel In review stipa (Code Review) 3 participants 6 messages Sep 12, 2025 – Sep 13, 2025 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): gerrit.1757677796000.I815e68dd5d365743faff2b80783b776d9e8a645c@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1181?usp=email

to review the following change.

Change subject: Preserve --dhcp-option values from local config
......................................................................

Preserve --dhcp-option values from local config

Commit

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

has changed the way how --dhcp-option values are stored. Instead of storing them directly in tuntap_options, they are now stored in dns_options->from_dhcp.

Before connect, we save options before --pull is applied, for that we call clone_dns_options(). However, this routing was missing cloning of from_dhcp struct, and as a result, the values of --dhcp-option from' the local config have been lost.

Fix by adding shallow-copying of dhcp_options to clone_dns_options(). It is safe to do because it only contains fixed-size arrays, scalar types and pointers to the strings which this struct doesn't own.

GitHub: https://github.com/OpenVPN/openvpn/issues/839

Change-Id I815e68dd5d365743faff2b80783b776d9e8a645c

---
M src/openvpn/dns.c

1 file changed, 1 insertion(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/1181/1

src/openvpn/dns.c +1 -0
index 8554089..5421004 100644
@@ -264,6 +264,7 @@
     clone.servers_prepull = clone_dns_servers(o->servers_prepull, gc);
     clone.updown = o->updown;
     clone.updown_flags = o->updown_flags;
+    clone.from_dhcp = o->from_dhcp;
 
     return clone;
 }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1181?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I815e68dd5d365743faff2b80783b776d9e8a645c
Gerrit-Change-Number: 1181
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, stipa.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1181?usp=email )

Change subject: Preserve --dhcp-option values from local config
......................................................................

Patch Set 1: Code-Review+2

(1 comment)

Patchset:

PS1:
I haven't tested it myself, but the change makes sense. We only use this function in two places, first to save the dns options and then to restore them again. Leaving off parts of the struct is pretty clearly wrong.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1181?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I815e68dd5d365743faff2b80783b776d9e8a645c
Gerrit-Change-Number: 1181
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 12 Sep 2025 13:21:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Preserve --dhcp-option values from local config

In reply to a message not in the archive

From: Lev Stipakov <[email protected]...>

Commit

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

has changed the way how --dhcp-option values are stored. Instead of storing them directly in tuntap_options, they are now stored in dns_options->from_dhcp.

Before connect, we save options before --pull is applied, for that we call clone_dns_options(). However, this routing was missing cloning of from_dhcp struct, and as a result, the values of --dhcp-option from' the local config have been lost.

Fix by adding shallow-copying of dhcp_options to clone_dns_options(). It is safe to do because it only contains fixed-size arrays, scalar types and pointers to the strings which this struct doesn't own.

GitHub: https://github.com/OpenVPN/openvpn/issues/839

Change-Id I815e68dd5d365743faff2b80783b776d9e8a645c

---

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/+/1181
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

src/openvpn/dns.c +1 -0
index 8554089..5421004 100644
@@ -264,6 +264,7 @@
     clone.servers_prepull = clone_dns_servers(o->servers_prepull, gc);
     clone.updown = o->updown;
     clone.updown_flags = o->updown_flags;
+    clone.from_dhcp = o->from_dhcp;
 
     return clone;
 }
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Preserve --dhcp-option values from local config

So, I tried to reproduce this on Linux, opened a new GH issue (840), and after discussion with Lev came to the conclusion that this is the same problem after all - #839 talks on "upon interface reconnection", but both for Lev's tests on Windows and for my tests on Linux with --dns-updown, it did not work on the initial connect either (o->dhcp_options.servers is NULL, so "nothing is attempted").

With the patch it works.

Added a test to my extended t_client set to ensure we will not break this again...

As requested, I have reworded the commit message slightly. Some unrelated words escaped :-)

Your patch has been applied to the master branch.

commit 3cc7a9eb2666722889d1c9ce739bb0bdaa23b308

Author: Lev Stipakov
Date:   Fri Sep 12 15:22:35 2025 +0200
     Preserve --dhcp-option values from local config

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg32879.html
     URL: https://gerrit.openvpn.net/c/openvpn/+/1181
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1181?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: Preserve --dhcp-option values from local config
......................................................................

Preserve --dhcp-option values from local config

Commit

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

has changed the way how --dhcp-option values are stored. Instead of storing them directly in tuntap_options, they are now stored in dns_options->from_dhcp.

Before connect, we save options before --pull is applied, and for that we call clone_dns_options(). However, this was missing to clone the "from_dhcp" struct, and as a result, the values of --dhcp-option from the local config have been lost.

Fix by adding shallow-copying of dhcp_options to clone_dns_options(). It is safe to do because it only contains fixed-size arrays, scalar types and pointers to the strings which this struct doesn't own.

Github: closes OpenVPN/openvpn#839
Github: closes OpenVPN/openvpn#840

Change-Id I815e68dd5d365743faff2b80783b776d9e8a645c

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32879.html
URL: https://gerrit.openvpn.net/c/openvpn/+/1181

---
M src/openvpn/dns.c

1 file changed, 1 insertion(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/1181/2

src/openvpn/dns.c +1 -0
index 8554089..5421004 100644
@@ -264,6 +264,7 @@
     clone.servers_prepull = clone_dns_servers(o->servers_prepull, gc);
     clone.updown = o->updown;
     clone.updown_flags = o->updown_flags;
+    clone.from_dhcp = o->from_dhcp;
 
     return clone;
 }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1181?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I815e68dd5d365743faff2b80783b776d9e8a645c
Gerrit-Change-Number: 1181
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1181?usp=email )

Change subject: Preserve --dhcp-option values from local config
......................................................................

Preserve --dhcp-option values from local config

Commit

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

has changed the way how --dhcp-option values are stored. Instead of storing them directly in tuntap_options, they are now stored in dns_options->from_dhcp.

Before connect, we save options before --pull is applied, and for that we call clone_dns_options(). However, this was missing to clone the "from_dhcp" struct, and as a result, the values of --dhcp-option from the local config have been lost.

Fix by adding shallow-copying of dhcp_options to clone_dns_options(). It is safe to do because it only contains fixed-size arrays, scalar types and pointers to the strings which this struct doesn't own.

Github: closes OpenVPN/openvpn#839
Github: closes OpenVPN/openvpn#840

Change-Id I815e68dd5d365743faff2b80783b776d9e8a645c

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32879.html
URL: https://gerrit.openvpn.net/c/openvpn/+/1181

---
M src/openvpn/dns.c

1 file changed, 1 insertion(+), 0 deletions(-)
src/openvpn/dns.c +1 -0
index 8554089..5421004 100644
@@ -264,6 +264,7 @@
     clone.servers_prepull = clone_dns_servers(o->servers_prepull, gc);
     clone.updown = o->updown;
     clone.updown_flags = o->updown_flags;
+    clone.from_dhcp = o->from_dhcp;
 
     return clone;
 }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1181?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I815e68dd5d365743faff2b80783b776d9e8a645c
Gerrit-Change-Number: 1181
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged