Couple of fixes
cover Couple of fixes
Hi!
First patch fixes long delays when setting IPv4 DNS using netsh without interactive service by adding "validate=no" to netsh invocation.
I've noticed that issue while testing wintun, as it is setup using netsh.
All other variants, IPv6 DNS without interactive service and IPv4/IPv6 DNS with interactive service, have validation already turned off.
Change is adapted from code by commit 786e06a.
It is necessary to make sure that argument is added only for DNS and not WINS, thus additional check is made (is_dns).
Second patch was necessary, at least for me, because build process was unable to perform linking, with the following output:
/usr/bin/x86_64-w64-mingw32-ld: forward.o:forward.c:(.text+0x5fec):
undefined reference to `tuntap_is_wintun'/usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x8a4): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x1362): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x1379): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: mudp.o:mudp.c:(.text+0x536): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mudp.o:mudp.c:(.text+0xf53): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: openvpn.o:openvpn.c:(.text+0x1b6): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: openvpn.o:openvpn.c:(.text+0x261): undefined reference to `tuntap_is_wintun'
collect2: error: ld returned 1 exit status
After declaring both functions as static linking worked.
I'm using Ubuntu 19.04 with mingw-w64 from official repository (version 6.0.0-3) and for build process script generic/build from openvpn-build repository.
It is also worth noting that similar function tuntap_defined() with same signature (static inline bool) already exists in the same header file, so this change should be safe.
Domagoj Pensa (2):
Skip DNS address validation
Fix linking issues on MinGW
src/openvpn/tun.c | 9 +++++++++ src/openvpn/tun.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.0
PATCH 1/2 Skip DNS address validation
When adding IPv4 DNS servers without interactive service use "validate=no", on Windows 7 and higher, to skip time consuming automatic address validation, that is on by default.
Fix uses adapted code from commit 786e06a
--- src/openvpn/tun.c | 9 +++++++++ 1 file changed, 9 insertions(+)
src/openvpn/tun.c +9 -0
@@ -5216,6 +5216,7 @@ netsh_ifconfig_options(const char *type,struct gc_arena gc =gc_new ();struct argv argv =argv_new ();bool delete_first = false; +bool is_dns = !strcmp (type,"dns" );/* first check if we should delete existing DNS/WINS settings from TAP interface */ if (test_first)
@@ -5259,6 +5260,14 @@ netsh_ifconfig_options(const char *type, type, flex_name, print_in_addr_t(addr_list[i], 0, &gc)); + +/* disable slow address validation on Windows 7 and higher */ +/* only for DNS */ +if (is_dns &&win32_version_info () >=WIN_7 ) + { +argv_printf_cat (&argv,"%s" ,"validate=no" ); + } +netsh_command (&argv,2 ,M_FATAL ); ++count;
Signature · 1 line
2.25.0
Re: [Openvpn-devel] [PATCH 1/2] Skip DNS address validation
Hi,
Built and tested with msvc, works as expected - "validate=no" is added to netsh command line.
There is a similar commit in Simon's repo (not yet sent to ml) :
https://github.com/rozmansi/openvpn/commit/6b746cb0bf72a75e9963cc1a037c18cfb856702a
I haven't noticed any slowness on my machine, but since fix has been implemented separately
by two persons and there is similar code for ipv6, I am ok with that.
Re: [Openvpn-devel] [PATCH 1/2] Skip DNS address validation
Hi,
Quoted 5 lines · Lev Stipakov
Hi,
Built and tested with msvc, works as expected - "validate=no" is added to netsh command line.
Quoted 7 lines
There is a similar commit in Simon's repo (not yet sent to ml) : https://github.com/rozmansi/openvpn/commit/6b746cb0bf72a75e9963cc1a037c18cfb856702a
I haven't noticed any slowness on my machine, but since fix has been implemented separately by two persons and there is similar code for ipv6, I am ok with that.
Acked-by Lev Stipakov <[email protected]...>
We explicitly added validate=no for IPv6 in
commit 786e06ade9f5dfad8ac360499187fa8e536d15cb
for the same reason as in this patch. The ipv4 DNS code belongs to an era when this
option was not available.
ACK from me too.
Selva
Quoted 6 lines
Acked-by Lev Stipakov <[email protected]...>_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH 1/2] Skip DNS address validation
In reply to Domagoj PensaHi,
My thoughts exactly: as Lev pointed out:
https://github.com/rozmansi/openvpn/commit/6b746cb0bf72a75e9963cc1a037c18cfb
856702a
Domagoj, if it's not too much for you, maybe document the reason why DNS validation is so slow in the commit message. My wording went like this:
Quoted 3 lines
DNS validation usually fails, as the pushed routes should be added first to make DNS servers not part of the OpenVPN subnet reachable before instructing Windows to use them.
Maybe Gert can update the commit message when applying?
One day somebody might revert that DNS validation back to default, as the long-term shot would be to upgrade the OpenVPN to setup routes first, then configure DNS servers.
But then there's ValdikSS with thousands of routes in his .ovpn setup...
Best regards,
Simon
Re: [Openvpn-devel] [PATCH 1/2] Skip DNS address validation
Hi!
Quoted 8 lines · Simon Rozman
Hi,
My thoughts exactly: as Lev pointed out:
https://github.com/rozmansi/openvpn/commit/6b746cb0bf72a75e9963cc1a037c18cfb
856702aAcked-by Simon Rozman <[email protected]...>
Quoted 8 lines
Domagoj, if it's not too much for you, maybe document the reason why DNS validation is so slow in the commit message. My wording went like this:
Quoted 3 lines
DNS validation usually fails, as the pushed routes should be added first to make DNS servers not part of the OpenVPN subnet reachable before instructing Windows to use them.
Maybe Gert can update the commit message when applying?
Absolutely, Gert can add your additional description in the commit.
Regards,
Domagoj
Re: [Openvpn-devel] [PATCH 1/2] Skip DNS address validation
In reply to Domagoj PensaHi!
My I ask if there is anything else I can (or should) do regarding this patch? Perhaps send patch again with revised/updated description as suggested by Simon?
Thank you!
Regards,
Domagoj
[Openvpn-devel] [PATCH applied] Re: Skip DNS address validation
In reply to Domagoj PensaYour patch has been applied to the master branch.
Sorry for the delay, it's been a very busy month.
I have not done any testing besides "test compile", but the code looks good and I trust Lev and Silva here.
commit 04f4b4feec2790b620419bdc4fa2c7ae4f2451bd
Author: Domagoj Pensa Date: Wed Feb 5 13:46:14 2020 +0100
Skip DNS address validation
Signed-off-by: Domagoj Pensa <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Acked-by: Selva Nair <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg19355.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH applied] Re: Skip DNS address validation
Quoted 4 lines · Gert Doering
Your patch has been applied to the master branch.
Sorry for the delay, it's been a very busy month.
No problem at all.
Thank you for applying patch! :)
Regards,
Domagoj
PATCH 2/2 Fix linking issues on MinGW
In reply to Domagoj PensaMinGW linking fails for several files due to a missing "static" declaration in functions tuntap_is_wintun() and tuntap_ring_empty().
--- src/openvpn/tun.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/openvpn/tun.h +2 -2
@@ -224,13 +224,13 @@ tuntap_defined(const struct tuntap *tt) }#ifdef _WIN32 -inline bool +static inline bool tuntap_is_wintun (struct tuntap *tt) {return tt && tt->windows_driver ==WINDOWS_DRIVER_WINTUN ; } -inline bool +static inline bool tuntap_ring_empty (struct tuntap *tt) {return tuntap_is_wintun (tt) && (tt->wintun_send_ring->head == tt->wintun_send_ring->tail);
Signature · 1 line
2.25.0
Re: [Openvpn-devel] [PATCH 2/2] Fix linking issues on MinGW
Hi,
Quoted 2 lines · Domagoj Pensa
MinGW linking fails for several files due to a missing "static" declaration in functions
tuntap_is_wintun()andtuntap_ring_empty().
It does not fail for us. So what MinGW version on what OS are you using to exhibit this error?
(The change might still make sense, but the explanation does not make much sense - exporting a function which is not needed "outside" should never cause a link fail)
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]...Re: [Openvpn-devel] [PATCH 2/2] Fix linking issues on MinGW
Hi!
Quoted 8 lines · Gert Doering
Hi,
Quoted 2 lines · Domagoj Pensa
MinGW linking fails for several files due to a missing "static" declaration in functions
tuntap_is_wintun()andtuntap_ring_empty().It does not fail for us. So what MinGW version on what OS are you using to exhibit this error?
I've mentioned that in first mail:
I'm using Ubuntu 19.04 with mingw-w64 from official repository (version 6.0.0-3) and for build process script generic/build from openvpn-build repository.
I've also included linker output same mail:
/usr/bin/x86_64-w64-mingw32-ld: forward.o:forward.c:(.text+0x5fec):
undefined reference to `tuntap_is_wintun'/usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x8a4): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x1362): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x1379): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: mudp.o:mudp.c:(.text+0x536): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mudp.o:mudp.c:(.text+0xf53): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: openvpn.o:openvpn.c:(.text+0x1b6): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: openvpn.o:openvpn.c:(.text+0x261): undefined reference to `tuntap_is_wintun'
collect2: error: ld returned 1 exit status
Here are versions for some tools from that package:
$ /usr/bin/x86_64-w64-mingw32-ld -v GNU ld (GNU Binutils) 2.32
$ x86_64-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=x86_64-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/lto-wrapper Target: x86_64-w64-mingw32 Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --with-headers=/usr/x86_64-w64-mingw32/include --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --with-plugin-ld --enable-threads=win32 --program-suffix=-win32 --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld --enable-libatomic Thread model: win32 gcc version 8.3-win32 20190406 (GCC)
Domagoj
Re: [Openvpn-devel] [PATCH 2/2] Fix linking issues on MinGW
Hi!
Quoted 8 lines · Gert Doering
Hi,
Quoted 2 lines · Domagoj Pensa
MinGW linking fails for several files due to a missing "static" declaration in functions
tuntap_is_wintun()andtuntap_ring_empty().It does not fail for us. So what MinGW version on what OS are you using to exhibit this error?
I've mentioned that in first mail:
I'm using Ubuntu 19.04 with mingw-w64 from official repository (version 6.0.0-3) and for build process script generic/build from openvpn-build repository.
I've also included linker output same mail:
/usr/bin/x86_64-w64-mingw32-ld: forward.o:forward.c:(.text+0x5fec):
undefined reference to `tuntap_is_wintun'/usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x8a4): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x1362): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mtcp.o:mtcp.c:(.text+0x1379): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: mudp.o:mudp.c:(.text+0x536): undefined reference to tuntap_is_wintun' /usr/bin/x86_64-w64-mingw32-ld: mudp.o:mudp.c:(.text+0xf53): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: openvpn.o:openvpn.c:(.text+0x1b6): undefined reference to tuntap_ring_empty' /usr/bin/x86_64-w64-mingw32-ld: openvpn.o:openvpn.c:(.text+0x261): undefined reference to `tuntap_is_wintun'
collect2: error: ld returned 1 exit status
Here are versions for some tools from that package:
$ /usr/bin/x86_64-w64-mingw32-ld -v GNU ld (GNU Binutils) 2.32
$ x86_64-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=x86_64-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/lto-wrapper Target: x86_64-w64-mingw32 Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --with-headers=/usr/x86_64-w64-mingw32/include --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --with-plugin-ld --enable-threads=win32 --program-suffix=-win32 --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld --enable-libatomic Thread model: win32 gcc version 8.3-win32 20190406 (GCC)
Domagoj
A message that is not in the archive (sent off-list or not yet received): [email protected]...
PATCH 2/2 Fix linking issues on MinGW
---------- Forwarded message ---------
From: Selva Nair <[email protected]...>
Date: Wed, Feb 5, 2020 at 10:16 AM
Subject: Re: [Openvpn-devel] [PATCH 2/2] Fix linking issues on MinGW
To: Domagoj Pensa <[email protected]...>
Cc: Gert Doering <[email protected]...>
Hi,
Quoted 11 lines · Domagoj Pensa
Hi!
Quoted 7 lines · Gert Doering
Hi,
Quoted 2 lines · Domagoj Pensa
MinGW linking fails for several files due to a missing "static" declaration in functions
tuntap_is_wintun()andtuntap_ring_empty().
Are you building without optimization? Please try using the latest openvpn-build (or just add -O2 to complier options).
I suspect this is caused by the fact that gcc does not inline when optimization is not on, but also not generating exported code in that case. Inline implementation in gcc has so many subtleties, so not sure whether this is a compiler bug or "feature".
Adding a static appears to be not a bad solution as gcc will emit external code for static inline functions only if necessary.
Selva
Re: [Openvpn-devel] Fwd: [PATCH 2/2] Fix linking issues on MinGW
Hi,
Quoted 2 lines · Selva Nair
Are you building without optimization? Please try using the latest openvpn-build (or just add -O2 to complier options).
Yes, that was it!
When Lev said that he doesn't have problems with build, I've noticed that he is using script build-complete from windows-nsis.
I didn't want installer build, just binaries, so I followed instructions from README and generic/README and thus I used generic/build.
But that doesn't include -O2 and I get mentioned error when linking.
In windows-nsis/build-complete there are additional flags "-O2 -flto" and that's why Lev doesn't have issues and we are using same tools and OS versions.
Those additional flags where added by Lev in commit 3eb61bb in openvpn-build.
Problem solved, now I know for the future.
But still it would be nice to somehow "fix" this for others, by either updating READMEs, adding -O2 to generic/build script or apply patch I've sent that helped me and links with optimization off.
Maybe doing all that won't be bad.
Thank you all!
Domagoj
Lev Stipakov
Acked-byRe: [Openvpn-devel] Fwd: [PATCH 2/2] Fix linking issues on MinGW
Hi,
Good catch. "Inline" generates inline definition and if we don't do inlining
(by not specifying O2), linker doesn't see it and prints an error. Apparently MSVC
is lax on that.
Checking source code, most (if all?) or inline methods are static.
Obviously we want our code to compile without O2, so ACK from me.
ke 5. helmik. 2020 klo 17.41 Domagoj Pensa ([email protected]...) kirjoitti:
Quoted 42 lines
Hi,
Quoted 2 lines · Selva Nair
Are you building without optimization? Please try using the latest openvpn-build (or just add -O2 to complier options).
Yes, that was it!
When Lev said that he doesn't have problems with build, I've noticed that he
is using script build-complete from windows-nsis.I didn't want installer build, just binaries, so I followed instructions from README and generic/README and thus I used generic/build.
But that doesn't include -O2 and I get mentioned error when linking.
In windows-nsis/build-complete there are additional flags "-O2 -flto" and that's why Lev doesn't have issues and we are using same tools and OS versions.
Those additional flags where added by Lev in commit 3eb61bb in openvpn-build.
Problem solved, now I know for the future.
But still it would be nice to somehow "fix" this for others, by either updating READMEs, adding -O2 to generic/build script or apply patch I've sent that helped me and links with optimization off.
Maybe doing all that won't be bad.
Thank you all!
Domagoj
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Signature · 1 line
-Lev
[Openvpn-devel] [PATCH applied] Re: Fix linking issues on MinGW
In reply to Domagoj PensaYour patch has been applied to the master branch.
I have slightly modified the commit message to explain the underlying issue better ("if compiled without -O2"). No change code-wise to your patch. Makes sense :-)
commit 5822e52c6b0f86f9e4de946f9fb1374c6fad95f1
Author: Domagoj Pensa Date: Wed Feb 5 13:46:15 2020 +0100
Fix linking issues on MinGW
Signed-off-by: Domagoj Pensa <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg19356.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering