From: "stipa (Code Review)" Date: Fri, 18 Jul 2025 12:57:47 +0000 References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <3225cb5d56552d1291bd3d8136b04afcfbef7a27-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="VRpP16Ft0l8="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Fix broken DHCP options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --VRpP16Ft0l8= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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/+/1090?usp=3Demail to review the following change. Change subject: Fix broken DHCP options ...................................................................... Fix broken DHCP options Commit 2dfc4f ("dns: deal with --dhcp-options when --dns is active") broke support for --dhcp-options. It removed the setting of the DHCP_OPTIONS_DHCP_OPTIONAL flag for some DHCP options. This flag is required for those options to be applied correctly, as it is used when building the DHCP options string that is passed to the TAP driver. This commit fixes the issue by restoring the setting of this flag. GitHub: #791 Change-Id: I0d75efcceb826d06e74abd003d5377468ff9fe3b Signed-off-by: Lev Stipakov --- M src/openvpn/options.c 1 file changed, 13 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/90/1090/1 diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0662b49..4ba9243 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -8310,9 +8310,12 @@ #endif VERIFY_PERMISSION(OPT_P_DHCPDNS); + bool dhcp_optional =3D false; + if ((streq(p[1], "DOMAIN") || streq(p[1], "ADAPTER_DOMAIN_SUFFIX")= ) && p[2] && !p[3]) { dhcp->domain =3D p[2]; + dhcp_optional =3D true; } else if (streq(p[1], "DOMAIN-SEARCH") && p[2] && !p[3]) { @@ -8325,6 +8328,7 @@ msg(msglevel, "--dhcp-option %s: maximum of %d search entr= ies can be specified", p[1], N_SEARCH_LIST_LEN); } + dhcp_optional =3D true; } else if ((streq(p[1], "DNS") || streq(p[1], "DNS6")) && p[2] && !p= [3] && (!strstr(p[2], ":") || ipv6_addr_safe(p[2]))) @@ -8336,6 +8340,7 @@ else { dhcp_option_address_parse("DNS", p[2], dhcp->dns, &dhcp->d= ns_len, msglevel); + dhcp_optional =3D true; } } #if defined(_WIN32) || defined(TARGET_ANDROID) @@ -8359,6 +8364,7 @@ else if (streq(p[1], "WINS") && p[2] && !p[3]) { dhcp_option_address_parse("WINS", p[2], o->wins, &o->wins_len,= msglevel); + o->dhcp_options |=3D DHCP_OPTIONS_DHCP_OPTIONAL; } else if (streq(p[1], "NTP") && p[2] && !p[3]) { @@ -8390,6 +8396,13 @@ #else /* if defined(_WIN32) || defined(TARGET_ANDROID) */ setenv_foreign_option(options, (const char **)p, 3, es); #endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ + + if (dhcp_optional) + { +#if defined(_WIN32) || defined(TARGET_ANDROID) + o->dhcp_options |=3D DHCP_OPTIONS_DHCP_OPTIONAL; +#endif + } } #ifdef _WIN32 else if (streq(p[0], "show-adapters") && !p[1]) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1090?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I0d75efcceb826d06e74abd003d5377468ff9fe3b Gerrit-Change-Number: 1090 Gerrit-PatchSet: 1 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --VRpP16Ft0l8= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

stipa would like plaisthos and flichtenheld to review t= his change.

V= iew Change

Fix broken DHCP options

Commit

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

broke sup= port for --dhcp-options. It removed the setting of the
DHCP_OPTIONS_DHCP= _OPTIONAL flag for some DHCP options. This flag is
required for those op= tions to be applied correctly, as it is used
when building the DHCP opti= ons string that is passed to the TAP driver.

This commit fixes the i= ssue by restoring the setting of this flag.

GitHub: #791

Chan= ge-Id: I0d75efcceb826d06e74abd003d5377468ff9fe3b
Signed-off-by: Lev Stip= akov <lev@...515...>
---
M src/openvpn/options.c
1 file chan= ged, 13 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openv=
pn.net:29418/openvpn refs/changes/90/1090/1
diff --git a/src/openvp=
n/options.c b/src/openvpn/options.c
index 0662b49..4ba9243 = 100644
--- a/src/openvpn/options.c
+++ b/sr= c/openvpn/options.c
@@ -8310,9 +8310,12 @@
= #endif
VERIFY_PERMISSION(OPT_P_DHCPDNS);
+ bo= ol dhcp_optional =3D false;
+
if ((streq(p[1], "DOMAIN") || s= treq(p[1], "ADAPTER_DOMAIN_SUFFIX")) && p[2] && != p[3])
{
dhcp->doma= in =3D p[2];
+ = dhcp_optional =3D true;
}
= else if (streq(p[1], "DOMAIN-SEARCH") && p[2] &= & !p[3])
{
@@ -8325,6 +8328,7 = @@
msg(msglevel, "--dhcp-option %s: m= aximum of %d search entries can be specified",
= p[1], N_SEARCH_LIST_LEN);
}
+ dhcp_optiona= l =3D true;
}
else if ((s= treq(p[1], "DNS") || streq(p[1], "DNS6")) && p[= 2] && !p[3]
&& (!strstr(p= [2], ":") || ipv6_addr_safe(p[2])))
@@ -8336,6 +8= 340,7 @@
else
{
dhcp_option_address_parse("DNS", = p[2], dhcp->dns, &dhcp->dns_len, msglevel);
+ dhcp_optional =3D true;
}
}
#= if defined(_WIN32) || defined(TARGET_ANDROID)
@@ -8359,6 +8= 364,7 @@
else if (streq(p[1], "WINS") &a= mp;& p[2] && !p[3])
{
= dhcp_option_address_parse("WINS", p[2], o->wins, = &o->wins_len, msglevel);
+ o->dhcp_options |=3D DHCP_OPTIONS_DHCP_OPTIONAL;=
}
else if (streq(p[1], &= quot;NTP") && p[2] && !p[3])
= {
@@ -8390,6 +8396,13 @@
#else /* if defin= ed(_WIN32) || defined(TARGET_ANDROID) */
setenv_fo= reign_option(options, (const char **)p, 3, es);
#endif /* = if defined(_WIN32) || defined(TARGET_ANDROID) */
+
+ if (dhcp_optional)
+ {
+#if defined(_WIN32) || defined(TARGET_ANDROID)
+ o->dhcp_options |=3D DHCP_= OPTIONS_DHCP_OPTIONAL;
+ }<= /span>
}
#ifdef _WIN32
= else if (streq(p[0], "show-adapters") && !p[1])

To view, visit change 1090. To unsubscribe, or for h= elp writing mail filters, visit settings.

=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0d75efcceb826d06e74abd003d5= 377468ff9fe3b
Gerrit-Change-Number: 1090
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--VRpP16Ft0l8=--