aboutsummaryrefslogtreecommitdiff
path: root/src/openvpn/tun.h
AgeCommit message (Collapse)Author
2023-02-10Allow certain DHCP options to be used without DHCP serverLev Stipakov
Followin DHCP options: DOMAIN, ADAPTER_DOMAIN_SUFFIX, DNS, WINS don't require DHCP server in order to be used. This change allows those options to be used with dco and wintun drivers. If an option specified which requires DHCP server and tap-windows6 driver is not used, print a clear error message instead of obscure reference to --ip-win32. Reported-by: Marek Zarychta Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Antonio Quartulli <a@unstable.cc> Message-Id: <20230207145416.1415-1-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26169.html Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit 469158f93ea52a6c2f821890ef599299183aa020)
2023-01-10Update copyright year to 2023Frank Lichtenheld
Manually excluded ovpn_dco_win.h because it is an imported file. ovpn_dco_linux.h is already excluded because it still says 2021. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20230110160531.81010-1-frank@lichtenheld.com> URL: https://patchwork.openvpn.net/project/openvpn2/patch/20230110160531.81010-1-frank@lichtenheld.com/ Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit ccf9d57249acb9bc9a450aec3e613bda631415f5)
2023-01-09tun: move print_windows_driver() out of tun.hLev Stipakov
We got warnings from MinGW about function being defined but not used when compiling modules which include tun.h. This function is not defined as inline, so its definition should not be in header. Since this is not a performance critical, no need to make it inline. Leave declaration in tun.h and move definition to tun.c. Github: fixes OpenVPN/openvpn#215 Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20230109113046.1678-1-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25923.html Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit a0eb1f764df39d9447b666e5a2cbd3aa01b41983)
2022-09-16Use DCO on Windows by defaultLev Stipakov
On startup, check following conditions: - ovpn-dco-win driver is installed. Perform this check by trying to open adapter by symbolic name. - options are compatible with dco. Same checks as on Linux and FreeBSD. In addition, check that --mode server is not used and --windows-driver is not set to tap-windows6/wintun. If both checks are passed, use DCO. Move options_postprocess_mutate_invariant() call below since it depends on selected windows driver. dco_check_option() has side effect on Windows - if dco is not used, it might complain "cipher chachapoly not supported by dco, disabling dco" if chachapoly support is missing system-wide. To not to see this, check dco options only if dco is enabled. This means moving dco_enabled() from dco_check_startup_option() to one level above. We do similar thing in multi_connection_established() before checking ccd options. Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Frank Lichtenheld <frank@lichtenheld.com> Message-Id: <20220915104028.188-1-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25221.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2022-08-25dco-win: implement ovpn-dco support in P2P Windows code pathAntonio Quartulli
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>
2022-08-19Don't "undo" ifconfig on exit if it wasn't doneMax Fillinger
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>
2022-08-18dco-win: introduce low-level code for handling ovpn-dco-win in WindowsAntonio Quartulli
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>
2022-08-16tun: properly handle device interface listLev Stipakov
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>
2022-08-13ovpn-dco: introduce FreeBSD data-channel offload supportKristof Provost
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>
2022-07-27dco: introduce open_tun_dco_generic() to open dynamic or fixed-name DCO devicesAntonio Quartulli
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>
2022-07-14tun: create tun_name_is_fixed helperAntonio Quartulli
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>
2022-06-28dco: add helper function to detect if DCO is enabled or notAntonio Quartulli
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>
2022-06-28dco: introduce low-level code for handling ovpn-dco in the Linux kernelAntonio Quartulli
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>
2022-05-12Fix M_ERRNO behavior on WindowsLev Stipakov
We use M_ERRNO flag in logging to display error code and error message. This has been broken on Windows, where we use error code from GetLastError() and error description from strerror(). strerror() expects C runtime error code, which is quite different from last error code from WinAPI call. As a result, we got incorrect error description. The ultimate fix would be introducing another flag for WinAPI errors, like M_WINERR and use either that or M_ERRNO depends on context. However, the change would be quite intrusive and in some cases it is hard to say which one to use without looking into internals. Instead we stick to M_ERRNO and in Windows case we first try to obtain error code from GetLastError() and if it returns ERROR_SUCCESS (which is 0), we assume that we have C runtime error and use errno. To get error description we use strerror_win32() with GetLastError() and strerror() with errno. strerror_win32() uses FormatMessage() internally, which is the right way to get WinAPI error description. Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Selva Nair <selva.nair@gmail.com> Message-Id: <20220503002840.295-1-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24270.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2022-01-26update copyright year to 2022Antonio Quartulli
Update performed by means of: dev-tools/update-copyright.sh Cc: David Sommerseth <davids@openvpn.net> Signed-off-by: Antonio Quartulli <a@unstable.cc> Acked-by: David Sommerseth <davids@openvpn.net> Message-Id: <20220125142456.18176-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23650.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2022-01-21tun: remove tun_finalize()Lev Stipakov
tun_finalize() is essentially subset of socket_finalize() apart from: - using WSAFoo() functions instead of Foo() - "from" address is not returned There is no clear official statement that one can use non-WSA API on handles, so let's be on a safe side and use both. Introduce sockethandle_t abstraction, which represents socket and handle. Add SocketHandle* routines which call proper API depends on underlying type in abstraction. Rename socket_finalize() to sockethandle_finalize(), take sockethandle_t and new routines into use and kick tun_finalize(). Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Selva Nair <selva.nair@gmail.com> Message-Id: <20220117094917.178-1-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23555.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-12-14Remove post_open_mtu codeArne Schwabe
This code is probably from a time when we could not set the MTU on the Windows tap6 driver. Nowadays we can set the MTU on this device, so this code is a noop now. Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20211207170211.3275837-7-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23327.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15Update copyrightsDavid Sommerseth
- Update the update-copyright script to include more contributors as well as correcting a few typos - Correct a copyright address in the source code to now used address (dazo) - Update copyright year to 2021 Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210609213231.22576-1-openvpn@sf.lists.topphemmelig.net> URL: https://www.mail-archive.com/search?l=mid&q=20210609213231.22576-1-openvpn@sf.lists.topphemmelig.net URL: https://sourceforge.net/p/openvpn/mailman/message/37299719/ Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-18Add parsing of dhcp-option PROXY_HTTPArne Schwabe
This adds support for setting a HTTP proxy that should be used after connecting to a VPN. The syntax has been picked to have compatibility with OpenVPN3. Otherwise I would have used HTTP-PROXY instead. Since this option requires an additional argument compared to the existing dhcp-option keywords, move checking the number of arguments to the individual keywords. Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210416110955.1162574-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22129.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01Remove unused field txqueuelen from struct tuntapArne Schwabe
The code uses tuntap->options.txqueuelen instead. Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210401131337.3684-8-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21947.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01Remove pointless tun_adjust_frame_parameters functionArne Schwabe
This functions seem to serve no purpose other than to add confusion. Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210401131337.3684-7-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21957.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-03-28Fix #elif TARGET_LINUX missing defined() callArne Schwabe
I found this when playing with building OpenVPN with cmake. Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210328143633.10300-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21884.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-03-19Fix multiple problems when compiling with LLVM/Windows (clang-cl)Arne Schwabe
When using the LLVM clang compiler instead the MSVC cl.exe but with the same build environment as MSVC, clang encounters a few errors: src\openvpn\socket.c(3550,23): warning: assigning to 'CHAR *' (aka 'char *') from 'uint8_t *' (aka 'unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign] wsabuf[0].buf = BPTR(&sock->reads.buf); ^ ~~~~~~~~~~~~~~~~~~~~~~ src\openvpn\socket.c(3670,23): warning: assigning to 'CHAR *' (aka 'char *') from 'uint8_t *' (aka 'unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign] wsabuf[0].buf = BPTR(&sock->writes.buf); ^ ~~~~~~~~~~~~~~~~~~~~~~~ Use BSTR instead of BPTR, which casts to the correct type that is expected. src\compat\compat-gettimeofday.c(105,18): error: assignment to cast is illegal, lvalue casts are not supported tv->tv_sec = (long)last_sec = (long)sec; Split into two assignments to avoid the illegal cast include\stdint.h(18,28): error: typedef redefinition with different types ('signed char' vs 'char') typedef signed char int8_t; ^ openvpn\config-msvc.h(162,16): note: previous definition is here typedef __int8 int8_t; Removes our custom int type typdefs from config-msvc.h and replace it with an include of inttypes.h. C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\tcpmib.h(56,3): error: typedef redefinition with different types ('enum MIB_TCP_STATE' vs 'int') } MIB_TCP_STATE; ^ C:\Users\User\source\repos\openvpn\src\openvpn/syshead.h(369,13): note: previous definition is here typedef int MIB_TCP_STATE; ^ 1 error generated. This seems to be for mingw32 only, so guard this with a mingw32 compiler guard. \src\openvpn\tun.c(3727,34): warning: passing 'char [256]' to parameter of type 'LPBYTE' (aka 'unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign] net_cfg_instance_id, ^~~~~~~~~~~~~~~~~~~ C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winreg.h(955,88): note: passing argument to parameter 'lpData' here This is windows specific code, use the Windows LPBTYE in the definitions. (long pointer to BYTE (long pointer as far/near pointer relict from windows 16 bit times, in moddern words (unsigned char *)) Fix also a few other char vs uint8/unisgned char/BYTE issues in tun.c Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210319114631.20459-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21719.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-07-14Added support for DHCP option 119 (dns search suffix list) for Windows.Jan Just Keijser
As of Windows 10 1809 Windows finally supports this so it makes sense to add support to OpenVPN as well. Multiple options can be specified at the same time, with one search domain per line (in the config, or pushed from server): dhcp-option DOMAIN-SEARCH my.company.domain dhcp-option DOMAIN-SEARCH some.example.domain OpenVPN will (on windows) concatenate them all together into a single "option 119" for the tapv9 DHCP server. Max length is 254 in total. DNS label compression is not used - it's complicated, and Windows does not need it. See RFC 3397 for more details. This only works with the tun/tap driver, not with wintun. On non-windows platforms, these settings are exported in the environment towards --up scripts (or to the management interface), and need to be picked up there. Signed-off-by: Jan Just Keijser <jan.just.keijser@gmail.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <c404dd17-e0db-ce61-0d79-864a5736f2d0@nikhef.nl> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20349.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-03-08tun.c: uncrustifySimon Rozman
Signed-off-by: Simon Rozman <simon@rozman.si> Acked-by: Lev Stipakov <lstipakov@gmail.com> Message-Id: <20200205175944.432-1-simon@rozman.si> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19366.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-02-05Fix linking issues on MinGWDomagoj Pensa
MinGW linking fails for several files if compiled without "-O2" due to a missing "static" declaration for inline functions tuntap_is_wintun() and tuntap_ring_empty(). Signed-off-by: Domagoj Pensa <domagoj@pensa.hr> Acked-by: Lev Stipakov <lstipakov@gmail.com> Message-Id: <20200205124615.15758-3-domagoj@pensa.hr> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19356.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-01-19wintun: refactor code to use enum driver typeSimon Rozman
Signed-off-by: Simon Rozman <simon@rozman.si> Acked-by: Lev Stipakov <lstipakov@gmail.com> Message-Id: <20200116141900.1524-1-simon@rozman.si> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19312.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-12-17wintun: interactive service supportLev Stipakov
Wintun requires ring buffers registration to be performed by privileged process. In order to use openvpn with wintun by non-Administrator, we need to use interactive service and shared memory to register buffers. Openvpn process creates memory mapping object and event for send and receive ring and passes handles to interactive service. There handles are duplicated and memory mapped object is mapped into the address space of service process. Then address of mapped view and event handle is passed to wintun kernel driver. After interactive service preformed registration, openvpn process maps memory mapped object into own address space. Thus mapped views in openvpn and service process represent the same memory region. Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Simon Rozman <simon@rozman.si> Message-Id: <20191217125041.207-1-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19244.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-12-17wintun: ring buffers based I/OLev Stipakov
Implemented according to Wintun documentation and reference client code. Wintun uses ring buffers to communicate between kernel driver and user process. Client allocates send and receive ring buffers, creates events and passes it to kernel driver under LocalSystem privileges. When data is available for read, wintun modifies "tail" pointer of send ring and signals via event. User process reads data from "head" to "tail" and updates "head" pointer. When user process is ready to write, it writes to receive ring, updates "tail" pointer and signals to kernel via event. In openvpn code we add send ring's event to event loop. Before performing io wait, we compare "head" and "tail" pointers of send ring and if they're different, we skip io wait and perform read. This also adds ring buffers support to tcp and udp server code. Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Steffan Karger <steffan.karger@fox-it.com> Acked-by: Simon Rozman <simon@rozman.si> Message-Id: <20191217124410.81-1-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19243.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-11-10get rid of 'broadcast' argument when configuring the tun deviceAntonio Quartulli
The broadcast argument is actually useless as every platform will figure it out and configure it on its own. We even realized that on linux, if you configure it wrong, nothing wrong will happen. At this point, let's make the code cleaner and let's get rid of this useless argument at all. This patch just removed any occurrence of 'broadcast'. Signed-off-by: Antonio Quartulli <a@unstable.cc> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20191110124407.8734-1-a@unstable.cc> URL: https://www.mail-archive.com/search?l=mid&q=20191110124407.8734-1-a@unstable.cc Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-11-09wintun: implement opening wintun deviceLev Stipakov
To open wintun device, we cannot use "\\.\Global\Wintun<luid>" path as before. To get device path which we supply to CreateFile, we have to use SetupAPI to: - enumerate network adapters with "wintun" as component id - for each adapter save its guid - open device information set - for each item in set - open corresponding registry key to get net_cfg_instance_id - get symbolic link name of device interface by instance id - path will be symbolic link name of device instance matched with adapter's guid See https://github.com/OpenVPN/openvpn3/blob/master/openvpn/tun/win/tunutil.hpp and https://github.com/WireGuard/wireguard-go/blob/master/tun/wintun/wintun_win dows.go for implementation examples. Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Simon Rozman <simon@rozman.si> Message-Id: <1573148729-27339-4-git-send-email-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19029.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-11-09wintun: add --windows-driver config optionLev Stipakov
This allows to specify which tun driver openvpn should use, tap-windows6 (default) or wintun. Note than wintun support will be added in follow-up patches. Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Simon Rozman <simon@rozman.si> Message-Id: <1573234655-905-1-git-send-email-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19046.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-09-18tun.h: remove TUN_PASS_BUFFER defineLev Stipakov
Since the very beginning this define has only been used together with _WIN32 and code wrapped into it uses Win32 API, so it could be safely removed and replaced with _WIN32. Signed-off-by: Lev Stipakov <lstipakov@gmail.com> Acked-by: David Sommerseth <davids@openvpn.net> Message-Id: <1568019436-28527-1-git-send-email-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18808.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-09-18tun.h: change tun_set() return value type to voidLev Stipakov
This function's return value is never used, so make it void. Signed-off-by: Lev Stipakov <lstipakov@gmail.com> Acked-by: Antonio Quartulli <antonio@openvpn.net> Acked-by: David Sommerseth <davids@openvpn.net> Message-Id: <1567784437-25922-1-git-send-email-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18804.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-06-05route.c: use new networking API to handle routing table on LinuxAntonio Quartulli
By switching to the networking API (for Linux) openvpn will now use any of the available implementations to handle the routing table. At the moment only iproute2 is implemented. Signed-off-by: Antonio Quartulli <a@unstable.cc> Acked-by: Arne Schwabe <arne@rfc2549.org> Message-Id: <20181219050118.6568-5-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18029.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-06-02tun.c: use new networking API to handle tun interface on LinuxAntonio Quartulli
By switching to the networking API (for Linux) openvpn will now use any of the available implementations to handle the tun interface. At the moment only iproute2 and sitnl (NetLink) is implemented. Signed-off-by: Antonio Quartulli <a@unstable.cc> Acked-by: Arne Schwabe <arne@rfc2549.org> Message-Id: <20181219050118.6568-4-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18028.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2019-05-10Fix various compiler warningsLev Stipakov
This patch fixes "unused variable/unreferenced format parameter" warnings in different places, kudos to Visual Studio compiler for discoveing some of those. This also also removes unneeded uninit_management_callback_multi() wrapper. Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Arne Schwabe <arne@rfc2549.org> Message-Id: <1540889615-24868-1-git-send-email-lstipakov@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17855.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2018-06-18tun: ensure interface can be configured with IPv6 onlyAntonio Quartulli
This change ensures that an interface is properly brought up and down even when only IPv6 settings are configured/pushed. At the same time, some code restyling took place to ensure the new generic logic is easier to read. Both do_ifconfig() and close_tun() (Linux only) functions have been rearranged by splitting the logic into a v4 and a v6 specific part. Each part has then been moved into an idependent helper that can be invoked as needed. This makes the code easier to read and more "symmetric" with respect to the two address families. Trac: #208 Signed-off-by: Antonio Quartulli <antonio@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20180618074733.19773-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17064.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2018-06-13tun: get rid of tt->did_ifconfig memberAntonio Quartulli
tt->did_ifconfig is currently only read by the Linux platform, but it is currently uselessly set also by every other system. The Linux platform does not actually even need this member and can directly rely on tt->did_ifconfig_setup. For the reasons above, remove the tt->did_ifconfig at all and use tt->did_ifconfig_setup where needed (close_tun() on Linux). Signed-off-by: Antonio Quartulli <antonio@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20180613122824.4207-4-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17046.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2018-02-01Update copyright to include 2018 plus company name changeDavid Sommerseth
The autumn of 2017, OpenVPN Technologies, Inc changed name to just OpenVPN Inc. Otherwise, extend the copyright to cover 2018 as well. With the exception of the company name change, all changes have been performed by the dev-tools/update-copyright.sh script. Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20180131140314.11103-1-davids@openvpn.net> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16418.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2017-06-16copyright: Update GPLv2 license textsDavid Sommerseth
The COPYRIGHT.GPL file was slightly out-of-sync with the last GPLv2 license from Free Software Foundation, Inc. The changes are primarily a new address, which required touching almost all the project files. Except of that, it is just minor adjustments to formatting, removal of form-feed characters and referencing "GNU Lesser General Public License" instead of "GNU Library General Public License". Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20170329093648.10156-1-davids@openvpn.net> URL: https://www.mail-archive.com/search?l=mid&q=20170329093648.10156-1-davids@openvpn.net Signed-off-by: Gert Doering <gert@greenie.muc.de>
2017-01-09Always release dhcp address in close_tun() on Windows.Selva Nair
Also make sure --dhcp-pre-release results in not just dhcp_release() in open_tun() but a subsequent dhcp_renew() as well. Else dhcp transaction gets aborted as this call to release() happens after the adapter status is changed to connected. Fixes Trac #807 (but can't say the same for Trac #665 without knowing how to reproduce it) v2: Mark --dhcp-release as obsolete in manpage and option parser, and remove the unused dhcp_release variable. Enforce dhcp-renew with dhcp-pre-release while parsing the option instead of in open_tun(). Trac: #807 Signed-off-by: Selva Nair <selva.nair@gmail.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1483475883-17450-1-git-send-email-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13814.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-12-21Update copyrightsDavid Sommerseth
Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Steffan Karger <steffan@karger.me> Message-Id: <1482350454-27280-2-git-send-email-davids@openvpn.net> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13653.html
2016-12-14The Great Reformatting - first phaseDavid Sommerseth
This is the first commit of the big reformatting task. This is performed by running the ./dev-tools/reformat-all.sh script. This is based upon the v3 reformat-all.sh/uncrustify.conf version which is now applied to git master. Signed-off-by: David Sommerseth <davids@openvpn.net>
2016-11-22Handle --dhcp-option DNS6 on Windows using netshSelva Nair
v2: On closing tun delete the ipv6 dns addresses (if any were set). Also use "validate=no" only in Windows 7 and higher where it is supported. Its used to skip the time consuming automatic address validation which is on by default on those platforms. Tested on Windows Server 2008 (i686), Win 7 (x64) and Win 10 (x64) TODO: set dns servers using the interactive service Signed-off-by: Selva Nair <selva.nair@gmail.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1479784332-21680-1-git-send-email-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13193.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-11-15Replace WIN32 by _WIN32Gert Doering
With c99, "WIN32" is no longer automatically defined when (cross-)building for Windows, and proper compilation relies on including <windefs.h>, before checking the macro. "_WIN32" is the official define that is guaranteed to be defined by the compiler itself, no includes are needed. So, mechanically change all occurrances of "WIN32" to "_WIN32". While at it, get rid of unused WIN32_0_1 #define in syshead.h See also: http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefi ned_macros_detect_operating_system#WindowsCygwinnonPOSIXandMinGW Trac #746 v2: rebased to master, merge the console[_builtin].c changes Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Steffan Karger <steffan.karger@fox-it.com> Message-Id: <20161113195228.74090-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13035.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-10-17Windows: do_ifconfig() after open_tun()Heiko Hund
When you had multiple TAP adapters and IPv6 configured you got an error message about "you must also specify --dev-node" and openvpn exited. Very inconvenient especially since this is only due to the fact that Windows tries to set the adapter address before it is opened; for no good reason. This patch changes the order to IFCONFIG_AFTER_TUN_OPEN, moves some initialization code to init_tun, where it belongs, and removes duplicate code that is now no longer needed. v2: do not use "%lu" in argv_printf(), crashes non-iservice usage Signed-off-by: Heiko Hund <heiko.hund@sophos.com> Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Gert Doering <gert@greenie.muc.de> Acked-by: Heiko Hund <heiko.hund@sophos.com> Message-Id: <20161009152550.GQ78279@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12631.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-10-14Remove tun-ipv6 Option. Instead assume that IPv6 is always supported.Arne Schwabe
This option was useful when IPv6 tun support was non standard and was an internal/user specified flag that tracked the Ipv6 capability of the tun device. All supported OS support IPv6. Also tun-ipv6 is pushable by the remote so not putting tun-ipv6 does not forbid ipv6 addresses. This commit also clean up a bit of the ipv6 related tun.c. Changes for most platforms are minimal. For linux a bit more cleanup is done: - Remove compatibility defines that were added 2008 - Always use IFF_NO_PI for the linux tun and not only for IPv4 only tun setups (Android also always IFF_NO_PI works fine with Ipv6). This commit also remove a non ipv6 fallback for tap driver from OpenVPN 2.2-beta or earlier and only warns. Patch V2: Integrate Gert's comments Patch V3: Remove tun_ipv4 option. It only used for MTU discovery and there it was wrong since it should on the transport protocol if at all Patch V4: Completely remove support for NetBSD <= 4.0 and remove NETBSD_MULTI_AF defines Patch V5: Assume generic OS in tun.c is also IPv6 capable. Add changes to man page. Fix typos/change message as suggest by David. Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: David Sommerseth <davids@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1476377656-3150-1-git-send-email-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12695.html Signed-off-by: David Sommerseth <davids@openvpn.net>
2016-02-05interactive service v3Heiko Hund
v1: Heiko Hund - Message-ID: <2215306.x9ci9DhAZ9@de-gn-40970> - extend openvpn service to provide "automatic service" and "interactive service" (which is used by GUI and OpenVPN to run openvpn non-privileged and still be able to install routes and configure IPv6 addresses) - add --msg-channel <n> option to openvpn to tell it which pipe to use to talk to the interactive service (used in tun.c for ifconfig + ARP flush, and route.c for routing) - add openvpn-msg.h with message definitions for talking to interactive service - routing in openvpn uses message-pipe automatically if --msg-channel <n> is configured, no other option needed - today, the integration in route.c and tun.c is windows-only, but could be adapted to other platforms v2: Steffan Karger - Message-ID: <548D9046.5000600@karger.me> - include "openvpn-msg.h" not "include/openvpn-msg.h" - add $(top_srcdir)/include to openvpnsrv build for out-of-tree builds v3: Gert Doering, rebasing and integrating review feedback - rebased to 417fe4a72c - r->metric_defined is now r->flags & RT_METRIC_DEFINED (c3ef2d2333fb) - move "openvpn-msg.h" include inside #ifdef WIN32 (windows-only right now) - hide "msg_channel" extra option inside tt->tuntap_options, so we do not need an extra argument to all the add/del_route...() functions - do_route_ipv6_service(): use r->adapter index (if set) for RGI6 routes Signed-off-by: Heiko Hund <heiko.hund@sophos.com> Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Selva Nair <selva.nair@gmail.com> (Service changes) Acked-by: Arne Schwabe <arne@rfc2549.org> (OpenVPN changes) Message-Id: <1453835508-26119-1-git-send-email-gert@greenie.muc.de> URL: http://article.gmane.org/gmane.network.openvpn.devel/11027 Signed-off-by: Gert Doering <gert@greenie.muc.de>
2015-05-23include ifconfig_ environment variables in --up-restart env setJan Just Keijser
here's my patch for bug #93: missing ifconfig_* env vars after up-restart. Tested with both IPv4, IPv6, topology subnet and topology net30 Document differences between --up-restart and --up in openvpn.8 See trac #93 and the discussion starting with <555BF270.3090706@nikhef.nl> on the openvpn-devel mailing list. fix trac #93 Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <555BF270.3090706@nikhef.nl> URL: http://article.gmane.org/gmane.network.openvpn.devel/9705 Signed-off-by: Gert Doering <gert@greenie.muc.de>