]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
20 months agoAdjust Linux+FreeBSD DCO device name handling to 'non DCO linux style'
Gert Doering [Mon, 29 Aug 2022 19:01:24 +0000 (21:01 +0200)] 
Adjust Linux+FreeBSD DCO device name handling to 'non DCO linux style'

On Linux, tun devices are created according to the following algorithm
  --dev tun    -> try tun0, tun1, ... tun255, use first free
  --dev anything -> create a TUN device named "anything"
(as long as "anything" is not "null" or "tap[N]")

DCO was following the "other platform convention", where everything
not having a digit was iterated ("--dev tun-home" -> "tun-home0") -
which does not work for classic tun/tap devices on the BSDs anyway,
so is not the best model.

Adjust open_tun_dco_generic() to document expected behaviour and
do the thing.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220829190124.2636045-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25134.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco-win: update GH Actions config file
Antonio Quartulli [Fri, 26 Aug 2022 08:41:11 +0000 (10:41 +0200)] 
dco-win: update GH Actions config file

In order to build OpenVPN with DCO support on Windows there is no need
to pull the full ovpn-dco-win source code, because we now ship the
UAPI header within OpenVPN directly. This also eliminates the need
to specify the DCO_SOURCEDIR var.

At the same time, DCO is always enabled therefore passing --enable-dco
at configure time is not needed anymore.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220826084111.239523-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25120.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoDCO: require valid netbits setting for non-primary iroutes.
Gert Doering [Sat, 20 Aug 2022 14:01:24 +0000 (16:01 +0200)] 
DCO: require valid netbits setting for non-primary iroutes.

The existing DCO code had extra logic for "if this is not
MR_WITH_NETBITS, set 32/128 as address length", but only for
iroute addition.  For iroute deletion, this was missing, and
subsequently iroute deletion for IPv4 host routes failed on
FreeBSD DCO (commit 3433577a99).

Iroute handling differenciates between "primary" iroutes (coming
from anm IP pool or ccd/ifconfig-push), and "non-primary" iroutes,
coming from --iroute and --iroute-ipv6 statements in per-client config.

"Primary" iroutes always use "-1" for their netbits, but since these
are not installed via DCO, this is of no concern here.  Whether these
can and should be changed needs further study on internal route
learning and cleanup.

Refactor options.c and multi.c to ensure that netbits is always set
for non-primary iroutes - and ASSERT() on this in the DCO path, so we can
find out if there might be other code violating this.

Change options.c::option_iroute() to always set netbits=32 for IPv4
host routes (options_iroute_ipv6() never differenciated).  Since
netmask_to_netbits() also insists on "-1" for host routes, change
to netmask_to_netbits2().

Remove all the extra MR_WITH_NETBITS logic from dco.c, where it should
have never appeared.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220820140124.11325-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25044.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoFix declaration of pubkeys in test_provider.c in MSVC builds
Arne Schwabe [Wed, 24 Aug 2022 16:57:18 +0000 (18:57 +0200)] 
Fix declaration of pubkeys in test_provider.c in MSVC builds

  Error: test_provider.c(74): error C2099: initializer is not a constant

Fix this issue by making the const char* to const char[]. This is probably
of one the weird array decay corner cases

I could not find another/better way around this issue.

This error only occurs when building unit tests with windows which our
normal build system does not do but my out of tree cmake build script
tries and fails.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220824165718.102002-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25102.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agot_client.sh: do not require fping6
Frank Lichtenheld [Mon, 22 Aug 2022 14:18:06 +0000 (16:18 +0200)] 
t_client.sh: do not require fping6

fping and fping6 were merged in version 4.0,
released in 2017. Many recent distributions do
not include the compatibility symlink anymore.

So if we find fping but not fping6 do not error
out but assume that fping is capable of IPv6.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220822141806.39406-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25058.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco-win: add documentation to README.dco.md
Antonio Quartulli [Sat, 13 Aug 2022 20:42:21 +0000 (22:42 +0200)] 
dco-win: add documentation to README.dco.md

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220813204224.22576-4-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24921.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco-win: implement ovpn-dco support in P2P Windows code path
Antonio Quartulli [Thu, 25 Aug 2022 13:14:49 +0000 (16:14 +0300)] 
dco-win: implement ovpn-dco support in P2P Windows code path

With this change it is possible to use ovpn-dco-win when running OpenVPN
in client or P2P mode.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220825131449.260-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25108.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoInclude libressl and macOS 12 to macOS github actions
Arne Schwabe [Mon, 22 Aug 2022 18:41:47 +0000 (20:41 +0200)] 
Include libressl and macOS 12 to macOS github actions

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220822184147.281142-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25065.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoGithub Actions: Add libreSSL actions
Arne Schwabe [Mon, 22 Aug 2022 18:41:46 +0000 (20:41 +0200)] 
Github Actions: Add libreSSL actions

Also we don't officially support it, it is nice to know when we break it.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220822184147.281142-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25064.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoHandle EVP_MD_CTX as an opaque struct
Max Fillinger [Thu, 11 Aug 2022 12:07:22 +0000 (14:07 +0200)] 
Handle EVP_MD_CTX as an opaque struct

Building OpenVPN on the latest OpenBSD snapshot failed because EVP_MD_CTX
is an opaque struct in LibreSSL now. Therefore, call md_ctx_new() instead
of declaring them on the stack. When they're not on the stack anymore, we
don't have to call EVP_MD_CTX_init() anymore, but we need to call
EVP_MD_CTX_free() instead of cleanup.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220811120722.29168-2-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24873.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoUpdate openssl_compat.h for newer LibreSSL
Max Fillinger [Mon, 22 Aug 2022 15:40:37 +0000 (17:40 +0200)] 
Update openssl_compat.h for newer LibreSSL

LibreSSL has added some of the functions that are defined here. However,
we still need RSA_F_RSA_OSSL_PRIVATE_ENCRYPT.

v2: Change ifdef condition for RSA_F_RSA_OSSL_PRIVATE_ENCRYPT.
v3: Don't break WolfSSL.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220822154037.44320-1-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/search?l=mid&q=20220822154037.44320-1-maximilian.fillinger@foxcrypto.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agovcpkg: bump baseline version
Lev Stipakov [Sat, 20 Aug 2022 11:27:55 +0000 (14:27 +0300)] 
vcpkg: bump baseline version

This allows us to use newer versions of
dependencies, such as openssl 3.0.2 -> 3.0.5.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220820112755.285-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25042.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoSupport creating iroute route entries on FreeBSD
Kristof Provost [Fri, 12 Aug 2022 13:41:54 +0000 (15:41 +0200)] 
Support creating iroute route entries on FreeBSD

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220812134154.16729-3-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24895.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco-win: use run-time dynamic linking for GetOverlappedResultEx
Lev Stipakov [Sat, 20 Aug 2022 08:47:19 +0000 (11:47 +0300)] 
dco-win: use run-time dynamic linking for GetOverlappedResultEx

This function is available starting from Windows 8. Calling it
"as is" causes startup error on Windows 7.

dco-win driver available on Windows 10 20H1 and newer. On older
systems installer will not show nor install the driver and dco-win code
won't be reached. It is safe to load GetOverlappedResultEx in runtime
and exit in case of error.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220820084719.243-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25038.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoFreeBSD-DCO: repair device iteration to find first free interface.
Gert Doering [Fri, 19 Aug 2022 18:24:39 +0000 (20:24 +0200)] 
FreeBSD-DCO: repair device iteration to find first free interface.

During review/update phase, FreeBSD/DCO's ability to find the first
free tun interface on "--dev tun" got broken, due to two issues:

 - create_interface() called msg(M_ERR|...), which is a fatal error
   and aborts OpenVPN, so "no retry with 'tun1' after 'tun0' failed"

   Change to M_WARN|M_ERRNO (= warning level, add strerror(errno), return).

 - open_tun_dco_generic() expects "-errno" as return value of
   open_tun_dco(), and breaks the loop on -EPERM.  create_interface()
   was returning "-1" instead (ioctl() error signalling), which happens
   to be "-EPERM" on FreeBSD.

   Change create_interface() to return -errno.

While at it, remove logging of errors from dco_freebsd.c::open_tun_dco()
(because all errors from create_interface() would be already logged there),
reducing open_tun_dco() to just a wrapper around create_interface().

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Kristof Provost <kprovost@netgate.com>
Message-Id: <20220819182439.71531-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25034.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoDon't "undo" ifconfig on exit if it wasn't done
Max Fillinger [Wed, 10 Aug 2022 15:30:06 +0000 (17:30 +0200)] 
Don't "undo" ifconfig on exit if it wasn't done

When running with --ifconfig-noexec, OpenVPN does not execute ifconfig,
but on exit, it still tries to "undo" the configuration it would have
done. This patch fixes it by extracting an undo_ifconfig() function from
close_tun(). The undo function is called before close_tun(), but only if
--ifconfig-noexec isn't set. This is symmetric to how open_tun() and
do_ifconfig() are used.

v2: Fix tabs-vs-spaces.
v3: Fix another style mistake.
v4: Move undo_ifconfig{4,6}() out of #ifdef TARGET_LINUX.
v5: Keep ctx argument in close_tun().
v6: Fix bug in non-Linux non-Windows version of undo_ifconfig_ipv6

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220810153006.18860-1-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24860.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoFix auth-token usage with management-def-auth
Selva Nair [Mon, 4 Jul 2022 02:58:40 +0000 (22:58 -0400)] 
Fix auth-token usage with management-def-auth

When auth-token verify succeeds during a reauth, other auth
methods (plugin, script, management) are skipped unless
external-auth is in effect (skip_auth gets set to true).

However, in this case, the status of management-def-auth
(ks->mda_status) stays at its default value of ACF_PENDING
and will never change. This causes TLS keys to go out of sync
and an eventual client disconnect.

Further, a message saying username/password authentication is
"deferred" gets logged which is misleading.
For example:

test/127.0.0.1:35874 TLS: Username/auth-token authentication
    succeeded for username 'test'

followed by

test/127.0.0.1:35874 TLS: Username/Password authentication
    deferred for username 'test' [CN SET]

Fix by setting ks->mda_status to ACF_DISABLED, and do not
set ks->authenticated = KS_AUTH_DEFERRED when skip_auth is true.

Also log a warning message when token is marked as expired on
missing the reneg window.

Reported by: Connor Edwards <connor.edwards@b2c2.com>

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220704025840.2558-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24627.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco-win: check for incompatible options
Antonio Quartulli [Fri, 19 Aug 2022 06:52:50 +0000 (08:52 +0200)] 
dco-win: check for incompatible options

At the moment dco-win doesn't support --persist-tun and --server,
so check for these options at startup time.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220819065250.222590-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25014.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco-win: introduce low-level code for handling ovpn-dco-win in Windows
Antonio Quartulli [Sat, 13 Aug 2022 20:42:18 +0000 (22:42 +0200)] 
dco-win: introduce low-level code for handling ovpn-dco-win in Windows

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20220813204224.22576-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24919.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: move availability check to the end of check_option_conflict() function
Antonio Quartulli [Tue, 2 Aug 2022 13:03:12 +0000 (15:03 +0200)] 
dco: move availability check to the end of check_option_conflict() function

To better arrange the order DCO option conflict messages are printed, we
decided to first perform all needed checks on provided options and, only
at the end, if no conflict was detected, to check if DCO is really
available on the system.

This way a user gets prompted with all warnings about their
configuration first and, when everything is fixed, they will see if DCO
is available or not.

While at it, compress the first check in just one if to make the code
simpler.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220802130312.18871-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24783.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agossl_util: fix prototype style
Antonio Quartulli [Thu, 18 Aug 2022 08:05:50 +0000 (10:05 +0200)] 
ssl_util: fix prototype style

Function prototypes should have the return type on the same line as the
function name itself. Fix this in ssl_util.h.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220818080550.177771-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24983.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco.h: fix return type when DCO is not enabled
Lev Stipakov [Wed, 17 Aug 2022 20:12:23 +0000 (22:12 +0200)] 
dco.h: fix return type when DCO is not enabled

The correct return type for those functions is int,
so adjust return type accordingly for the cases
when DCO is not defined.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220817201223.302-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24968.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco-win: ensure the DCO API is not used when running on Windows
Antonio Quartulli [Sun, 14 Aug 2022 08:51:17 +0000 (10:51 +0200)] 
dco-win: ensure the DCO API is not used when running on Windows

On Windows the high level API should still use the link_socket object to
read and write packets. For this reason, even if dco_installed is true,
we still need to rely on the classic link_socket object.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20220814085117.7128-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24929.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: turn platform config checks into separate function
Timo Rothenpieler [Wed, 17 Aug 2022 21:08:57 +0000 (23:08 +0200)] 
dco: turn platform config checks into separate function

All the checks in there are only relevant during startup, and
specifically the capability check might cause issues when checking a CCD
config later at runtime.

So move them to their own function and call it only during startup.
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220817210857.1558-1-timo@rothenpieler.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24969.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoInclude DCO status in GLOBAL_STATS status v2 output
Arne Schwabe [Sat, 13 Aug 2022 21:11:04 +0000 (23:11 +0200)] 
Include DCO status in GLOBAL_STATS status v2 output

This is allows querying the DCO status from management interface or by
sending SIGUSR2 without doing an error-prone parsing of the startup log.

Also remove comment that serves no purpose anymore.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20220813211104.411554-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24923.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: don't pass VPN IPs to NEW_PEER API in P2P mode
Antonio Quartulli [Mon, 15 Aug 2022 22:39:41 +0000 (00:39 +0200)] 
dco: don't pass VPN IPs to NEW_PEER API in P2P mode

When adding a peer to a P2P interface, the VPN IPs are not really used by
DCO as there is no routing happening in this mode.

For this reason don't pass any VPN IP when adding a new peer in p2p mode.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220815223941.26839-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24940.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoRename OPT_P_IPWIN32 to OPT_P_DHCPDNS and include --dns in it
Arne Schwabe [Wed, 17 Aug 2022 07:59:25 +0000 (09:59 +0200)] 
Rename OPT_P_IPWIN32 to OPT_P_DHCPDNS and include --dns in it

The dns options are very similar to dhcp-option and should fall
under the same option mask. For that rename the OPT_P_IPWIN32 mask
to OPT_P_DHCPDNS and include dns in it.

This effects currently route-nopull which block all host side
network/dns configuration but did not block the new dns option.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220817075925.815184-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24946.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoFix IV_PLAT_VER and UV_ variables sent without push-peer-info
Arne Schwabe [Wed, 17 Aug 2022 13:53:48 +0000 (15:53 +0200)] 
Fix IV_PLAT_VER and UV_ variables sent without push-peer-info

Commit 8c72d7981 changed the push_peer_info_detail to have an
additional level for P2P NCP and shifting most of the other levels
with 1. The check for UV_ and IV_PLAT_VER was not changed accordingly.

Fixes: 8c72d7981 ("Support NCP in pure P2P VPN setups")
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220817135348.844178-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24956.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: disable DCO if --user specified but unable to retain capabilities
Timo Rothenpieler [Wed, 17 Aug 2022 13:18:17 +0000 (15:18 +0200)] 
dco: disable DCO if --user specified but unable to retain capabilities

If run under network manager, OpenVPN starts with uid=0 and
'--user nm-openvpn', but is lacking the CAP_SETPCAP capabilities
to retain CAP_NET_ADMIN after dropping root privileges.

In DCO mode, OpenVPN must have CAP_NET_ADMIN today, always, otherwise
TLS renegotiation / key rotation will not be possible.

So, check at startup, if --user is specified, if CAP_NET_ADMIN is
permitted and CAP_SETPCAP is available.  If either of the capabilities
is missing, disable DCO.  Traditional tun/tap works with "uid=0 on
tun open, and setuid() afterwards".

Long-Term, get NM to enable OpenVPN to run with CAP_NET_ADMIN.

Debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1017379

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Tested-By: Bernhard Schmidt <berni@birkenwald.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220817131817.467-1-timo@rothenpieler.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24952.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoGithub Actions: update used actions
Timo Rothenpieler [Wed, 17 Aug 2022 13:23:02 +0000 (15:23 +0200)] 
Github Actions: update used actions

In the case of the Microsoft action, this fixes security relevant issues
according to their release notes:
https://github.com/microsoft/setup-msbuild/releases

Unfortunately they don't appear to be following the usual scheme of v1
referring to all v1.x.x, but instead v1 just points to v1.0.0.

The primary change with all the Github-Provided actions is the switch to a
more up-to-date NodeJS version (16). Not all that relevant when you just
use the action as is, but on top of that, the old versions are in
low-maintenance mode, and basically are considered obsolete.
Github is actively migrating people to the latest ones via dependabot
wherever they can.
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220817132302.538-1-timo@rothenpieler.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24954.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agotun: properly handle device interface list
Lev Stipakov [Sun, 14 Aug 2022 21:53:03 +0000 (23:53 +0200)] 
tun: properly handle device interface list

Device interface is a path which is used by userspace
to access device. A driver can create one or more device
interfaces and specify "reference string", so that userspace
could enumerate all device interfaces in the list and pick
the corrct one which ends with reference string.

Before our code had an assumption that either driver
creates only one device interface or the "right" interface
is alwways first in the list. As it turned out, that assumtion
does not always hold, so here we iterate through all device
interfaces in the list.

In follow-up dco-win patch we pick the device interface
from the list which ends with specific reference string.

v3: change allocation to use regular gc_malloc() instead of buffer.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220814215303.305-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24938.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: properly name variables
Antonio Quartulli [Sat, 13 Aug 2022 20:42:24 +0000 (22:42 +0200)] 
dco: properly name variables

renamed remote_addrX variables to vpn_addrX to make it clear that they
refer to the address over the VPN/tunnel

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220813204224.22576-7-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24916.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoerror.c: remove unused crash() function
Lev Stipakov [Sat, 13 Aug 2022 21:20:40 +0000 (00:20 +0300)] 
error.c: remove unused crash() function

This has been added in 2006 and as of now not used.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220813212040.113-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24924.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: move message to DCO debug level and reword a bit
Antonio Quartulli [Fri, 12 Aug 2022 13:06:57 +0000 (15:06 +0200)] 
dco: move message to DCO debug level and reword a bit

This message is purely a debug message, so it should go to the
appropriate log level. At the same time make it more clear.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220812130657.29899-11-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24893.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoovpn-dco: print some netlink messages to debug level
Antonio Quartulli [Fri, 12 Aug 2022 13:06:55 +0000 (15:06 +0200)] 
ovpn-dco: print some netlink messages to debug level

Netlink errors detected during dco availability detection are not really
required and can confuse the user.
Have them printed to the dco debug level.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220812130657.29899-9-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24892.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoApply uncrustify changes that were forgotten in the FreeBSD DCO 1/2 patch.
Gert Doering [Sat, 13 Aug 2022 12:44:38 +0000 (14:44 +0200)] 
Apply uncrustify changes that were forgotten in the FreeBSD DCO 1/2 patch.

commit f08fcc2f1eb159 has a few whitespace errors that uncrustify
complained on merge, but due to git handling mistakes, these were not
properly included in the actual commit.  Fix.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodo_close_tun: get rid of one level of indentation
Antonio Quartulli [Sat, 13 Aug 2022 12:04:28 +0000 (14:04 +0200)] 
do_close_tun: get rid of one level of indentation

OpenVPN often uses a multi-indentation pattern with no real gain:

if (a)
{
    if (b)
    {
        ...
    }
}

This approach makes the code harder to read because a lot of space is
eaten by indentation.

Cases like this can be easily converted by negating the first condition
and exiting immediately:

if (!a)
{
    return;
}

if (b)
{
    ...
}

Apply this change to do_close_tun() only for now in order to make the
functiona bit easier to read.

Ideally, this approach should be adopted for other parts of the code as
well.

NOTE: this patch is better viewed with "git show -w" as the real change
is only about 3 lines. The rest is indentation change.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220813120428.6767-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24908.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoovpn-dco: introduce FreeBSD data-channel offload support
Kristof Provost [Fri, 12 Aug 2022 13:41:53 +0000 (15:41 +0200)] 
ovpn-dco: introduce FreeBSD data-channel offload support

Implement data-channel offload for FreeBSD. The implementation and flow
is very similar to that of the Linux DCO support.

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220812134154.16729-2-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24894.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodo_open_tun: restyle 'can preserve TUN' check
Antonio Quartulli [Fri, 12 Aug 2022 13:06:48 +0000 (15:06 +0200)] 
do_open_tun: restyle 'can preserve TUN' check

The current condition checking if the TUN interface was preserved is
dependant on the platform being Android or not. This makes the code
reasonably ugly, especially because uncrustify can't indent properly.

On top of that, we will require an extra condition only for windows+DCO,
which will make the check even uglier.

For this reason, factor out the check in a separate function which can
keep the ifdefs craziness well hidden, while do_open_tun becomes
(a bit) cleaner.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20220812130657.29899-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24884.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoGitHub Actions: Add new libcap-ng-dev dependency
Timo Rothenpieler [Thu, 11 Aug 2022 11:34:22 +0000 (13:34 +0200)] 
GitHub Actions: Add new libcap-ng-dev dependency

Linux builds need this now in order to retain capabilities when dropping
root privileges.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220811113422.451-1-timo@rothenpieler.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24870.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoApply uncrustify changes that were forgotten in the last patch.
Gert Doering [Thu, 11 Aug 2022 11:26:58 +0000 (13:26 +0200)] 
Apply uncrustify changes that were forgotten in the last patch.

commit 2e359a088226ab1e5 has a few whitespace errors that uncrustify
complained on merge, but due to git handling mistakes, these were not
properly included in the actual commit.  Fix.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoLinux: Retain CAP_NET_ADMIN when dropping privileges
Timo Rothenpieler [Sat, 14 May 2022 10:37:17 +0000 (12:37 +0200)] 
Linux: Retain CAP_NET_ADMIN when dropping privileges

On Linux, when dropping privileges, interaction with
the network configuration, such as tearing down routes
or ovpn-dco interfaces will fail when --user/--group are
used.

This patch sets the CAP_NET_ADMIN capability, which grants
the needed privileges during the lifetime of the OpenVPN
process when dropping root privileges.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Reviewed-By: David Sommerseth <davids@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220514103717.235-1-timo@rothenpieler.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24360.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoRemove outdated information from ChangeLog, point at release branches.
Gert Doering [Wed, 10 Aug 2022 08:47:01 +0000 (10:47 +0200)] 
Remove outdated information from ChangeLog, point at release branches.

ChangeLog is not maintained in "master", document as such.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220810084701.13226-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24854.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agotun.c: remove unused gc_arena from init_tun()
Lev Stipakov [Tue, 9 Aug 2022 07:22:20 +0000 (10:22 +0300)] 
tun.c: remove unused gc_arena from init_tun()

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220809072220.255-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24851.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoconfig-version.h: remove unused includes
Frank Lichtenheld [Mon, 8 Aug 2022 08:54:11 +0000 (10:54 +0200)] 
config-version.h: remove unused includes

We only need to include this when we want the
git version.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220808085411.9159-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24839.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoCleanup: get rid of 'dynamic' argument of open_tun_generic()
Gert Doering [Sun, 7 Aug 2022 19:35:35 +0000 (21:35 +0200)] 
Cleanup: get rid of 'dynamic' argument of open_tun_generic()

All callers of open_tun_generic() always set dynamic=true - so just
get rid of it.  While at it, move "int i" into the for() loop.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20220807193535.15377-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24838.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: turn supported ciphers list into a function
Antonio Quartulli [Sun, 7 Aug 2022 10:04:04 +0000 (12:04 +0200)] 
dco: turn supported ciphers list into a function

Other platforms may need more complex logic to decide whether a cipher
is supported or not, therefore turn hardcoded list into a function that
can be implemented by each platform independently.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20220807100404.8618-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24835.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: disable DCO if --allow-compress yes/asym was specified
Antonio Quartulli [Sun, 7 Aug 2022 09:53:29 +0000 (11:53 +0200)] 
dco: disable DCO if --allow-compress yes/asym was specified

Allowing compression means that we may accept a pushable compress
setting.
This scenario can't work with DCO therefore disable it when compression
is allowed.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220807095329.28819-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24834.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoopenvpnmsica: remove OpenVPNService state check code
Lev Stipakov [Thu, 28 Jul 2022 11:17:12 +0000 (14:17 +0300)] 
openvpnmsica: remove OpenVPNService state check code

This code reads the state of OpenVPNService,
such as startup mode and running, and sets MSI
property value. If that property is set, installer
selects OpenVPNService as a feature to be installed.

This has been superseded by change in installer:

  https://github.com/OpenVPN/openvpn-build/pull/261

which, in addition to checking the state of OpenVPNService,
applies that state to the newly installed service.

  - by default, OpenVPNService feature is now checked
and service is installed

  - in clean installation, service startup mode is set to "manual"
and service is not started

  - in upgrade, installer preserves the service state, such
as startup mode and started/stopped

With all those changes to installer, we don't need this code
in openvpnmsica.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20220728111712.94-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24752.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoReduce usage of __DATE__
Frank Lichtenheld [Thu, 4 Aug 2022 15:03:01 +0000 (17:03 +0200)] 
Reduce usage of __DATE__

To increase the reproducibility of builds
we shouldn't use __DATE__. However, for
the development builds there is some demand
for leaving this in.

So as suggested by Gert Doering go for a
compromise where we only use __DATE__ if
we also include the git information. This
will remove this information from release
builds, but not from builds done directly
from the git checkout.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220804150301.62856-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24807.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: perform pull options check only if we pulled any option
Antonio Quartulli [Fri, 5 Aug 2022 15:08:37 +0000 (17:08 +0200)] 
dco: perform pull options check only if we pulled any option

The do_deferred_options() function is invoked also on the server side in
order to process all negotiated bits.

However, in this case we should not perform any pull options check, as
it's required only on the client side.

Move check within the "if (options.pull)" block to ensure we perform the
check only when required.

Reported-By: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220805150837.8169-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24824.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: implement dco support for p2mp/server code path
Antonio Quartulli [Fri, 5 Aug 2022 06:45:55 +0000 (08:45 +0200)] 
dco: implement dco support for p2mp/server code path

This change introduces ovpn-dco support along the p2mp/server code path.
Some code seems to be duplicate of the p2p version, but details are
different, so it couldn't be shared.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220805064555.13385-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24811.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoBreak 'try 256 dco devices' loop on EPERM
Gert Doering [Thu, 4 Aug 2022 08:25:02 +0000 (10:25 +0200)] 
Break 'try 256 dco devices' loop on EPERM

If we get a permission denied error on one DCO device, trying 255 more
times will not succeed, and just fill the log file with errors.

Also, remove the msg() call there because it was at debug level
(needed --verb 4 to be seen), didn't see the correct errno, and the
sitnl code already prints the error.

v2: use "else if"

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220804082502.1750074-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24799.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: add documentation for ovpn-dco-linux
Antonio Quartulli [Fri, 5 Aug 2022 09:37:03 +0000 (11:37 +0200)] 
dco: add documentation for ovpn-dco-linux

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220805093703.27940-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24817.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: implement dco support for p2p/client code path
Antonio Quartulli [Thu, 4 Aug 2022 07:14:01 +0000 (09:14 +0200)] 
dco: implement dco support for p2p/client code path

With this change we introduce ovpn-dco support only along the p2p/client
code path. Server codebase is still unchanged.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220804071401.12410-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24798.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: check that pulled options are compatible
Antonio Quartulli [Thu, 4 Aug 2022 06:40:16 +0000 (08:40 +0200)] 
dco: check that pulled options are compatible

A server may push options that are not compatible with DCO.
In this case we should log a message and bail out.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220804064016.20414-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24797.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agopush: fix compilation with --disable-management and --enable-werror
Antonio Quartulli [Wed, 3 Aug 2022 15:40:49 +0000 (17:40 +0200)] 
push: fix compilation with --disable-management and --enable-werror

The authfail_extended and buf variables are only used when
ENABLE_MANAGEMENT is defined. However, they are currently declared
outside of any ifdefs, thus triggering a warning.

Move the declaration of these 2 down, right before their usage (within
the existing "#ifdef ENABLE_MANAGEMENT" block.

Fixes: ("Cleanup receive_auth_failed and simplify method")
Cc: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220803154049.1213-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24792.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: split option parsing routines
Antonio Quartulli [Wed, 3 Aug 2022 09:50:12 +0000 (11:50 +0200)] 
dco: split option parsing routines

DCO will try to install keys upon generating them, however, this happens
when parsing pushed cipher options (due to NCP).

For this reason we need to postpone parsing pushed cipher options to
*after* the tunnel interface has been opened, otherwise we would have
no DCO netdev object to operate on.

At the same time we split the parsing code, so that we can ensure that
the NEW_PEER call can happen after the received peer-id has been parsed
(it is required by all DCO API calls).

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220803095012.24975-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24789.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: periodically check and possibly rotate/delete keys
Antonio Quartulli [Tue, 2 Aug 2022 15:16:04 +0000 (17:16 +0200)] 
dco: periodically check and possibly rotate/delete keys

Data channel keys are periodically regenerated and installed in ovpn-dco.
However, there is a certain moment when keys are rotated in order
to elect the new primary one.

Check the key status in userspace so that kernelspace can be informed as
well when rotations happen.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220802151604.2801-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24785.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoCleanup receive_auth_failed and simplify method
Arne Schwabe [Fri, 20 May 2022 21:32:48 +0000 (23:32 +0200)] 
Cleanup receive_auth_failed and simplify method

This simplifies the buffer handling in the method and adds a quick
return instead of wrapping the whole method in a if (pull) block

Patch V2: remove uncessary ifdef/endif and unnecassary block
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220520213250.3126372-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24412.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoAllow a few levels of recursion in virtual_output_callback()
Selva Nair [Thu, 28 Jul 2022 03:45:08 +0000 (23:45 -0400)] 
Allow a few levels of recursion in virtual_output_callback()

Without this, replies to commands from the management client
are sometimes lost if the server is writing when a command
comes in and leads to a recursive call to this function.

For some reason I've not been able to trigger this on Linux,
but it does sometimes happen on Windows during intense write
activity by openvpn.exe sending log lines to the management
client.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220728034508.15180-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24751.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoDo not skip ERROR:/SUCCESS: response from management interface
Selva Nair [Thu, 28 Jul 2022 03:45:07 +0000 (23:45 -0400)] 
Do not skip ERROR:/SUCCESS: response from management interface

Generally we expect a response of SUCCESS: or ERROR: to every
command sent to the management interface. But, while in
the management-hold state, sending "signal foo" returns only
the following reply (with foo = SIGHUP, SIGUSR1 etc.):

>HOLD:Waiting for hold release:0

Fix by always responding

ERROR: signal 'foo' is currently ignored"
followed by the above line.

Though this is seldom seen in practice[*], such violation of the
protocol could stall clients like the GUI. So fix it.

[*] One way this happens is with SIGHUP sent before the daemon
is on hold state which it enters before the SIGHUP is received.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220728034508.15180-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24750.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodisable DCO if no --dev was specified
Antonio Quartulli [Mon, 1 Aug 2022 15:08:12 +0000 (17:08 +0200)] 
disable DCO if no --dev was specified

The DCO logic is unable to proceed without --dev argument, therefore
just disable DCO if no --dev was specified by the user.

Right now, calling openvpn with DCO enabled (default) and no --dev
specified leads to a crash, because --dev is assumed to always be there.

Reported-by: Frank Lichtenheld <frank@lichtenheld.com>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220801150812.32561-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24772.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoxkey_provider: fix building with --disable-management
Selva Nair [Wed, 27 Jul 2022 22:18:30 +0000 (18:18 -0400)] 
xkey_provider: fix building with --disable-management

v2: also fix building test_provider
 - ifdefs in test_provider.c
 - include integer.h for min_int as manage.h
   may not always pull it in

Too many ifdefs, unfortunately..

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220727221830.31861-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24749.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agodco: configure keys in DCO right after generating them
Antonio Quartulli [Thu, 28 Jul 2022 15:20:12 +0000 (17:20 +0200)] 
dco: configure keys in DCO right after generating them

The ovpn-dco kernel module needs to be informed about the keys to be
used to encrypt/decrypt data traffic to/from a peer.

Configure keys in DCO right afte they are generated by the SSL code, to
avoid keeping them in memory longer than needed.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220728152012.18643-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24758.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
21 months agoExtract check_session_cipher into standalone function
Arne Schwabe [Fri, 29 Jul 2022 12:37:48 +0000 (14:37 +0200)] 
Extract check_session_cipher into standalone function

This allow the code later to check if the cipher is okay to use and
update it for the calculation for the max MTU size.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch v2: Name function check_session_cipher to better reflect its
          function
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220729123748.3267207-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24766.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agosystemd: remove generated service files on clean
Frank Lichtenheld [Tue, 26 Jul 2022 08:33:13 +0000 (10:33 +0200)] 
systemd: remove generated service files on clean

Found this when trying to build the Debian package
twice in a row. Which failed since then there were
additional files.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220726083313.14067-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24740.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agodco: initialize context and save pointer in TLS object
Antonio Quartulli [Wed, 20 Jul 2022 12:30:21 +0000 (14:30 +0200)] 
dco: initialize context and save pointer in TLS object

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-By: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220720123021.24281-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24714.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agodco: introduce open_tun_dco_generic() to open dynamic or fixed-name DCO devices
Antonio Quartulli [Thu, 21 Jul 2022 18:24:25 +0000 (20:24 +0200)] 
dco: introduce open_tun_dco_generic() to open dynamic or fixed-name DCO devices

This function is similar to the essence of open_tun_generic(), but
calling open_tun_dco() instead of trying to do a file open on
"/dev/%s"

Previous attempts to save code duplication by including this into
open_tun_generic() created additional #ifdef plus confusing call
paths.  So this is a clean new function, leaving the door open for
a cleanup of open_tun_generic().

Also, introduce tun_dco_enabled(tt) to avoid the negative
"!tt->options.disable_dco" calls.

v11:
  - add new function open_tun_dco_generic() for Linux (and FreeBSD, later)
    instead of lumping this into open_tun_generic()
  - pick up tun_dco_enabled() from a later patch in the series
    (easier to bring this in right now than to convert the code back
    and then patch it again later)

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220721182425.1569798-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24717.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoFix error message about extended errors for IPv4-only sockets.
Gert Doering [Sat, 23 Jul 2022 12:19:09 +0000 (14:19 +0200)] 
Fix error message about extended errors for IPv4-only sockets.

The new code to enable IPv6 extended error reporting will cause
an error ("Protocol not available (errno=92)") if trying to enable
that setsockopt() option on an IPv4-only socket.

Fix: pass sock->info.af to set_sock_extended_error_passing(), only
apply to AF_INET6 sockets.

To make that work, ensure that sock->info.af is set to not only
the value coming from config (which might be AF_UNSPEC) but to the
actual value used in socket creation (credits: Arne Schwabe).

Add comments to make explicit that the asymmetry here (IPv4 extended
socket error reporting is enabled on all sockets) is intentional.

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

Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoIn x_check_status() read errno early
Selva Nair [Fri, 22 Jul 2022 20:40:07 +0000 (16:40 -0400)] 
In x_check_status() read errno early

The correct errno can get overwritten by the call to
format_extended_socket_error() which may set errno to EAGAIN
losing the original error and cause to bypass the error reporting
below. Fix by reading the errno of interest at the top of the
function.

Reported by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722204007.7537-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24728.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agot_client: Allow to force FAIL on prerequisite fails
Frank Lichtenheld [Fri, 22 Jul 2022 13:49:02 +0000 (15:49 +0200)] 
t_client: Allow to force FAIL on prerequisite fails

In automated tests we want the build to fail if the
worker node is configured incorrectly.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722134902.22092-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24723.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoFix segfault when no --config argument is given
Arne Schwabe [Fri, 22 Jul 2022 13:46:52 +0000 (15:46 +0200)] 
Fix segfault when no --config argument is given

Commit 4df5003 introduced a check against options->config but
did not ensure that this variable is non-null.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722134652.2446598-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24722.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoError out if both remap-usr1 SIGHUP and config stdin are used
Arne Schwabe [Fri, 22 Jul 2022 13:02:24 +0000 (15:02 +0200)] 
Error out if both remap-usr1 SIGHUP and config stdin are used

OpenVPN for Android uses config stdin to avoid writing the config
file containing private keys to 'disk'. However using stdin means
that config cannot be reread using SIGHUP. While there might be other
corner cases that trigger SIGHUP, this is an obvious one, so we
error out if we detect this misconfiguration.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722130224.2442759-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24720.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agotun: extract close_tun_handle into its own fucntion and print correct type
Arne Schwabe [Fri, 24 Jun 2022 08:38:01 +0000 (10:38 +0200)] 
tun: extract close_tun_handle into its own fucntion and print correct type

This moves closing the tun handle into its own function and also prints
the adapter type we are operating on, instead hardcoding it to
tap-windows.

While at it, set the handle to NULL after closing, to prevent a double
close due to multiple invocations of this helper.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220624083809.23487-18-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24527.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoGitHub Actions: add Linux DCO build (on Ubuntu 20.04)
Antonio Quartulli [Fri, 24 Jun 2022 08:38:00 +0000 (10:38 +0200)] 
GitHub Actions: add Linux DCO build (on Ubuntu 20.04)

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220624083809.23487-17-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24523.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agodco: allow user to disable it at runtime
Antonio Quartulli [Mon, 18 Jul 2022 22:19:23 +0000 (00:19 +0200)] 
dco: allow user to disable it at runtime

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220718221923.2033-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24702.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agodco: add option check - disable DCO if conflict is detected
Antonio Quartulli [Mon, 18 Jul 2022 22:17:57 +0000 (00:17 +0200)] 
dco: add option check - disable DCO if conflict is detected

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220718221757.545-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24701.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoLog address of management client on accept
Selva Nair [Thu, 30 Jun 2022 19:05:49 +0000 (15:05 -0400)] 
Log address of management client on accept

Currently when we are listening on the management
interface, the local address/port is logged as that of
the connecting client.

Fix it.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220630190549.16675-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24619.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoLog the actual management interface port in use
Selva Nair [Thu, 30 Jun 2022 19:05:47 +0000 (15:05 -0400)] 
Log the actual management interface port in use

When the port is specified as zero, log the actual port
bound to, instead of 0.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220630190549.16675-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24617.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoRemove management_write_peer_info_file and related code
Selva Nair [Fri, 1 Jul 2022 00:07:26 +0000 (20:07 -0400)] 
Remove management_write_peer_info_file and related code

Use of this has never been documented and the code was
dead for a long while now.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220701000726.8198-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24624.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoFix crash in xkey-provider in msvc builds
Selva Nair [Thu, 7 Jul 2022 03:51:51 +0000 (23:51 -0400)] 
Fix crash in xkey-provider in msvc builds

The function signature for xkey_load_generic_key had
function pointers defined as function types that seems
to work in gcc but not in msvc.

Fix it by changing the function signatures to what was intended.

Also revert part of commit 627d1a3d28638... as that workaround
should be no longer required.

Reported by: Lev Stipakov https://github.com/lstipakov

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220707035151.25469-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24664.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agotun: create tun_name_is_fixed helper
Antonio Quartulli [Tue, 12 Jul 2022 22:16:55 +0000 (00:16 +0200)] 
tun: create tun_name_is_fixed helper

This helper encloses the (simple) logic used by OpenVPN to determine if
the name passed to --dev has to be considered a fixed interface name or
just a pattern.

Having a helper is useful because when this logic is required elsewhere,
we can just re-use this logic without duplicating the code (which may
mean introducing bugs if a future logic change should not update all
spots).

The logic is actually fairly simple: check if the name contains a number
(i.e. tun0). If so, consider the name a fixed device name.

While at it make has_digit() accept a signed argument because strings
are normally signed (also isdigit() accepts a signed argument).

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220712221655.19333-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24676.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agonetworking: add net_iface_type API
Antonio Quartulli [Wed, 13 Jul 2022 12:43:32 +0000 (14:43 +0200)] 
networking: add net_iface_type API

This new API can be used to retrieve the type of a specific interface.
It's mostly platform dependant, but right now expected values are
"ovpn-dco", "tun" or "tap".

Other values are possible too, but they are not of interest to us.

This commit also extends the networking unit-test by using the newly
introduced API in conjunction with iface_new and iface_del.

The t_net.sh script has been slightly adapted to allow running these
tests in standalone (as they don't require any iproute2 counterpart).

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220713124332.16147-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24688.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agonetworking_sitnl: always return negative error code in case of failure
Antonio Quartulli [Wed, 13 Jul 2022 12:14:16 +0000 (14:14 +0200)] 
networking_sitnl: always return negative error code in case of failure

The API is designed to always return a negative error code in case of
failure, therefore we should return '-errno' when ifindex has failed.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220713121416.1912-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24686.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agoHandle exceeding 'max-clients'
Kristof Provost [Wed, 13 Jul 2022 08:34:04 +0000 (10:34 +0200)] 
Handle exceeding 'max-clients'

If 'max-clients' is set multi_create_instance() can return NULL (for any
client that would take us over the client limit).

If mi is NULL we don't add it to the hash map, but we do potentially
dereference it to increment the session count.
Do not attempt to do so if 'mi == NULL'.

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220713083404.13227-2-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24678.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agooptions: don't export local function pre_connect_save()
Antonio Quartulli [Mon, 11 Jul 2022 12:23:48 +0000 (14:23 +0200)] 
options: don't export local function pre_connect_save()

The pre_connect_save() function is not used outside of options.c,
therefore it should not be exported.

Make it static and move definition before its invocation.
Move also pre_connect_restore() along with it in order to keep the two
close to each other.

Cc: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20220711122348.8756-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24666.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
22 months agonetworking: fix doc for net_iface_new() API
Antonio Quartulli [Tue, 5 Jul 2022 09:18:42 +0000 (11:18 +0200)] 
networking: fix doc for net_iface_new() API

Some auto correction must have sneaked in.
Restore proper wording.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20220705091842.24053-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24636.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agomake %x destination unsigned
Heiko Hund [Thu, 12 May 2022 23:19:01 +0000 (01:19 +0200)] 
make %x destination unsigned

The %x specifier requires for the argument to be an unsigned int.

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220512231901.1077306-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24336.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agodco: use specific metric when installing routes
Antonio Quartulli [Tue, 28 Jun 2022 18:56:23 +0000 (20:56 +0200)] 
dco: use specific metric when installing routes

When using DCO iroutes and routes all live in the same routing table,
However, the latter should always come after the former.

for this reason assign a default metric of 200 to routes. iroutes will
later get a metric of 100.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220628185623.1734-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24599.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agotls-crypt-v2: bail out if the client key is too small
Antonio Quartulli [Tue, 28 Jun 2022 09:41:44 +0000 (11:41 +0200)] 
tls-crypt-v2: bail out if the client key is too small

The tls-crypt-v2 key should be at least 2 bytes long in order to read
the actual length. Bail out if the key is too short.

This looks like it could be abused to trigger a read of uninitialized
memory, but after close checking it won't:

  We read from BEND(), so this is defined for TCP since the minimum
  length there is 3 bytes (pkt len + opcode)

  For UDP we might read past the beginning of the packet but since they
  are buffers coming from the packet stack we have the headroom/tailroom,
  so might read some random data (but not out of bound!).

  So we copy some more or less random number into net_len/wkc_len but without
  actually reading from undefined memory.

  The next line will then almost definitively fail (buf_advance()).

While at it improve the error message a bit.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220628094144.17471-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24580.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agodco: create DCO interface using SITNL
Antonio Quartulli [Fri, 24 Jun 2022 08:37:48 +0000 (10:37 +0200)] 
dco: create DCO interface using SITNL

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220624083809.23487-5-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24514.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agodco: add helper function to detect if DCO is enabled or not
Antonio Quartulli [Fri, 24 Jun 2022 08:37:46 +0000 (10:37 +0200)] 
dco: add helper function to detect if DCO is enabled or not

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220624083809.23487-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24513.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agodco: introduce low-level code for handling ovpn-dco in the Linux kernel
Antonio Quartulli [Fri, 24 Jun 2022 08:37:45 +0000 (10:37 +0200)] 
dco: introduce low-level code for handling ovpn-dco in the Linux kernel

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220624083809.23487-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24512.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agosignal --dns support in peer info
Heiko Hund [Fri, 13 May 2022 09:37:40 +0000 (11:37 +0200)] 
signal --dns support in peer info

Have clients set a bit in IV_PROTO, so that servers can make an informed
decision on whether to push --dns to the client. While unknown options
are ignored by clients when pushed, they generate a warning in the log.
That can be circumvented by server backends by checking if bit 7 is set.

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20220513093740.1091639-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24350.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agodns: also (re)place foreign dhcp options in env
Heiko Hund [Fri, 27 May 2022 01:24:57 +0000 (03:24 +0200)] 
dns: also (re)place foreign dhcp options in env

Override DNS related foreign_options with values set by the --dns
option. This is done so that scripts looking for these options continue
to work if only --dns option were pushed, or the values in the
--dhcp-options differ from what's pushed in --dns.

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220527012457.1819262-5-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24432.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agoSet o->use_peer_id flag for p2p mode
Lev Stipakov [Tue, 24 May 2022 09:19:16 +0000 (12:19 +0300)] 
Set o->use_peer_id flag for p2p mode

There are two flags to indicate peer-id usage, one is
in tls_multi struct and another one is in options.

For P2P mode we don't set this flag in options,
which is used in MTU calculation. As a result,
automatically calculated MSS value in P2P mode is wrong,

Fix by bring use_peer_id flag in options and tls_multi
into sync for P2P.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220524091916.145-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24430.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agoInline frame_add_to_extra_tun function and remove frame_defined
Arne Schwabe [Tue, 21 Jun 2022 16:16:45 +0000 (18:16 +0200)] 
Inline frame_add_to_extra_tun function and remove frame_defined

This function has only one usage and is so trivial that an extra
function makes little sense anymore.

frame_defined is no longer used, so remove the function.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220621161649.2872985-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24492.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agoRemove leftover frame_set_mtu_dynamic definitions in mtu.h
Arne Schwabe [Tue, 21 Jun 2022 16:16:44 +0000 (18:16 +0200)] 
Remove leftover frame_set_mtu_dynamic definitions in mtu.h

The frame_set_mtu_dynamic function and it defines were removed during
the buffer rework but this definitions were overlooked.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220621161649.2872985-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24494.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 months agoUpdate the replay-window backtrack log message
Martin Janů [Fri, 10 Jun 2022 12:04:05 +0000 (12:04 +0000)] 
Update the replay-window backtrack log message

The man pages reference a logging message which has been rephrased
in ac1310528a248c99e039e7afaf48724ad1b7f10e. This commit updates the
man page message to reflect the change for improved grep-ability.

Signed-off-by: Martin Janů <martin.janu@protonmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <SVrvuTydxR6Qs_mvwvG7mqT8iLV0inlcCMXoenZTMI8M0LkosV4pZsH9m_XCTwcRWAPN5H8Zdro0ubhJrnSp6v5KC2ZNAL9So0Y2SKiSe7g=@protonmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24472.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>