Introduce ovpn-dco(-win) support
cover Introduce ovpn-dco(-win) support
This is a first implementation of the ovpn-dco support in OpenVPN2. It is sent as RFC because it is not intended for final review/merge, but rather to collect additional feedback and allow users to test it.
This implementation supports both dco for Linux and for Windows.
* For Linux, please get the ovpn-dco kernel module source at:
https://gitlab.com/openvpn/ovpn-dco
(alternatively, it is also packaged on various distributions along with OpenVPN3-for-Linux)
* For Windows, a snapshot of the driver can be found on:
https://github.com/OpenVPN/ovpn-dco-win/actions
(note that "test signing" must be enabled on your Windows box, for the driver to be accepted. Instructions to enable this mode are here:
https://github.com/OpenVPN/ovpn-dco-win/blob/master/README.md#installation
DO IT AT YOUR OWN RISK)
In the meantime the code is still being rearranged a bit and a newer version, including all collected feedback, will be sent later on.
Known expected changes are:
* refactoring of the networking API implementation
* tun open logic (i.e. merge it with the current logic used by other platforms)
* options handling
When running ./configure, if --enable-dco is specified, then DCO_INCLUDEDIR must be defined and should point to where the ovpn-dco header can be found.
For example, it can be configure'd like this:
./configure --enable-dco DCO_INCLUDEDIR=/path/to/include/uapi/
ovpn-dco is enabled opportunistically, which means that it is always on, unless some conflicting option has been chosen (because ovpn-dco does not support all known openvpn options) or if disabled explicitly.
Feel free to test/break/comment. Any input is highly appreciated.
Best Regards,
Antonio Quartulli (2):
networking: silence warnings about unused arguments
ovpn-dco: force user to set DCO_INCLUDEDIR
Arne Schwabe (5):
networking: remove duplicate methods from networking_sitnl.c
sitnl: implement net_iface_new and net_iface_del
ovpn-dco: introduce linux data-channel offload support
tun: extract close_tun_handle into its own fucntion and print correct
type
ovpn-dco-win: introduce windows data-channel offload support
Lev Stipakov (1):
ovpn-dco-win: fix mingw i686 build
Changes.rst | 7 + README.dco.md | 132 +++ config-msvc.h | 12 +- configure.ac | 66 ++ doc/man-sections/advanced-options.rst | 13 + src/compat/Makefile.am | 3 +- src/compat/compat-dco_get_overlapped_result.c | 44 + src/compat/compat.h | 6 + src/compat/compat.vcxproj | 1 + src/compat/compat.vcxproj.filters | 3 + src/openvpn/Makefile.am | 9 +- src/openvpn/crypto.c | 10 + src/openvpn/crypto.h | 6 + src/openvpn/dco.c | 272 ++++++ src/openvpn/dco.h | 119 +++ src/openvpn/errlevel.h | 2 + src/openvpn/event.h | 3 + src/openvpn/forward.c | 66 +- src/openvpn/init.c | 195 +++- src/openvpn/init.h | 2 +- src/openvpn/mtcp.c | 61 +- src/openvpn/mudp.c | 13 + src/openvpn/multi.c | 278 +++++- src/openvpn/multi.h | 6 +- src/openvpn/networking.h | 11 +- src/openvpn/networking_linuxdco.c | 848 ++++++++++++++++++ src/openvpn/networking_linuxdco.h | 85 ++ src/openvpn/networking_sitnl.c | 116 ++- src/openvpn/networking_sitnl.h | 28 + src/openvpn/networking_windco.c | 306 +++++++ src/openvpn/networking_windco.h | 47 + src/openvpn/openvpn.vcxproj | 6 +- src/openvpn/openvpn.vcxproj.filters | 12 + src/openvpn/options.c | 181 +++- src/openvpn/options.h | 41 + src/openvpn/socket.c | 125 ++- src/openvpn/socket.h | 58 +- src/openvpn/ssl.c | 6 +- src/openvpn/ssl_common.h | 13 + src/openvpn/ssl_ncp.c | 2 +- src/openvpn/tun.c | 130 ++- src/openvpn/tun.h | 60 +- tests/unit_tests/openvpn/test_networking.c | 27 +- 43 files changed, 3265 insertions(+), 166 deletions(-) create mode 100644 README.dco.md create mode 100644 src/compat/compat-dco_get_overlapped_result.c create mode 100644 src/openvpn/dco.c create mode 100644 src/openvpn/dco.h create mode 100644 src/openvpn/networking_linuxdco.c create mode 100644 src/openvpn/networking_linuxdco.h create mode 100644 src/openvpn/networking_windco.c create mode 100644 src/openvpn/networking_windco.h
Signature · 1 line
2.32.0
RFC 1/8 networking: remove duplicate methods from networking_sitnl.c
From: Arne Schwabe <[email protected]...>
The net_ctx_init/reset/free methods of sitnl are the same dummy methods that are already defined for non-Linux platforms in the networking.h header.
--- src/openvpn/networking.h | 7 ++++++- src/openvpn/networking_sitnl.c | 22 ---------------------- 2 files changed, 6 insertions(+), 23 deletions(-)
src/openvpn/networking.h +6 -1
@@ -33,7 +33,12 @@ struct context;/* define mock types to ensure code builds on any platform */ typedef void *openvpn_net_ctx_t ;typedef void *openvpn_net_iface_t ; +#endif /* ifdef ENABLE_SITNL */ +/* Only the iproute2 backend implements these functions, +* the rest can rely on these stubs +*/ +#if !defined(ENABLE_IPROUTE )static inline int net_ctx_init (struct context *c,openvpn_net_ctx_t *ctx) {
@@ -51,7 +56,7 @@ net_ctx_free(openvpn_net_ctx_t *ctx) { (void )ctx; } -#endif /* ifdef ENABLE_SITNL */ +#endif /* !defined(ENABLE_IPROUTE) */ #if defined(ENABLE_SITNL ) || defined(ENABLE_IPROUTE )
src/openvpn/networking_sitnl.c +0 -22
@@ -595,28 +595,6 @@ net_route_v6_best_gw(openvpn_net_ctx_t *ctx, const struct in6_addr *dst, }#ifdef ENABLE_SITNL - -int -net_ctx_init (struct context *c,openvpn_net_ctx_t *ctx) -{ - (void )c; - (void )ctx; - -return 0 ; -} - -void -net_ctx_reset (openvpn_net_ctx_t *ctx) -{ - (void )ctx; -} - -void -net_ctx_free (openvpn_net_ctx_t *ctx) -{ - (void )ctx; -} -int net_route_v4_best_gw (openvpn_net_ctx_t *ctx,const in_addr_t *dst,in_addr_t *best_gw,char *best_iface)
Signature · 1 line
2.32.0
RFC 2/8 networking: silence warnings about unused arguments
In reply to Antonio QuartulliIn the net_ctx_init() stub definition, arguments are not used and therefore they should be explicitly marked to avoid compiler warnings.
--- src/openvpn/networking.h | 3 +++ 1 file changed, 3 insertions(+)
src/openvpn/networking.h +3 -0
@@ -42,6 +42,9 @@ typedef void *openvpn_net_iface_t;static inline int net_ctx_init (struct context *c,openvpn_net_ctx_t *ctx) { + (void )c; + (void )ctx; +return 0 ; }
Signature · 1 line
2.32.0
RFC 3/8 sitnl: implement net_iface_new and net_iface_del
In reply to Antonio QuartulliFrom: Arne Schwabe <[email protected]...>
These two new methods can be used to create and delete a tun or an ovpn-dco interface via RTNL API.
--- src/openvpn/networking_sitnl.c | 94 ++++++++++++++++++++++ src/openvpn/networking_sitnl.h | 28 +++++++ tests/unit_tests/openvpn/test_networking.c | 22 ++++- 3 files changed, 143 insertions(+), 1 deletion(-)
src/openvpn/networking_sitnl.c +94 -0
@@ -1312,6 +1312,100 @@ net_route_v6_del(openvpn_net_ctx_t *ctx, const struct in6_addr *dst, table, metric); } + +int +net_iface_new (const char *iface,const char *type) +{ +struct sitnl_link_req req = { }; +struct rtattr *tail =NULL ; +int ret =-1 ; + + req.n.nlmsg_len =NLMSG_LENGTH (sizeof (req.i)); + req.n.nlmsg_flags =NLM_F_REQUEST |NLM_F_CREATE |NLM_F_EXCL ; + req.n.nlmsg_type =RTM_NEWLINK ; + +if (iface) + { +SITNL_ADDATTR (&req.n,sizeof (req),IFLA_IFNAME , iface,strlen (iface) +1 ); + } + tail =NLMSG_TAIL (&req.n); +SITNL_ADDATTR (&req.n,sizeof (req),IFLA_LINKINFO ,NULL ,0 ); +SITNL_ADDATTR (&req.n,sizeof (req),IFLA_INFO_KIND , type, +strlen (type) +1 ); + tail->rta_len = (uint8_t *)NLMSG_TAIL (&req.n) - (uint8_t *)tail; + + req.i.ifi_family =AF_PACKET ; + req.i.ifi_change =0xFFFFFFFF ; + +msg (D_ROUTE ,"%s: add %s type %s" , __func__,np (iface), type); + +if (iface) + { +/* if we have an interface name we can use that name to later +* lookup what interface index we created */ + ret =sitnl_send (&req.n,0 ,0 ,NULL ,NULL ); +if (!ret) + { + req.i.ifi_index =if_nametoindex (iface); + } + + } +else + { + req.i.ifi_index =1194 ; +do + { +/* for some reason RTM_NEWLINK does not have a reply */ +/* Therefore we use try using different if indices untiles +* we get one that does not exist already */ + req.i.ifi_index++; + ret =sitnl_send (&req.n,0 ,0 ,NULL ,NULL ); + } +while (ret == -EEXIST ); + } +if (!ret) + { +return req.i.ifi_index; + } + +err: +return ret; +} + +int +net_iface_del_name (const char *iface) +{ +int ifindex; + + ifindex =if_nametoindex (iface); + +msg (D_ROUTE ,"%s: idel %s" , __func__, iface); + +if (ifindex ==0 ) + { +msg (D_ROUTE |M_ERRNO ,"%s: rtnl: cannot get ifindex for %s:" , + __func__, iface); +return -ENOENT ; + } + +return net_iface_del_index (ifindex); +} + +int +net_iface_del_index (int ifindex) +{ +struct sitnl_link_req req = { }; + + req.n.nlmsg_len =NLMSG_LENGTH (sizeof (req.i)); + req.n.nlmsg_flags =NLM_F_REQUEST ; + req.n.nlmsg_type =RTM_DELLINK ; + + req.i.ifi_family =AF_PACKET ; + req.i.ifi_index = ifindex; + +return sitnl_send (&req.n,0 ,0 ,NULL ,NULL ); +} +#endif /* !ENABLE_SITNL */ #endif /* TARGET_LINUX */
src/openvpn/networking_sitnl.h +28 -0
@@ -25,4 +25,32 @@typedef char openvpn_net_iface_t ;typedef void *openvpn_net_ctx_t ; +/** +* @brief Add new interface (similar to ip link add) +* +* @param iface interface name +* @param type interface link type (for example "ovpn-dco") +* @return int 0 on success, negative error code on error +*/ +int +net_iface_new (const char *iface,const char *type); + +/** +* @brief Remove an interface (similar to ip link remove) +* +* @param iface interface name +* @return int 0 on success, negative error code on error +*/ +int +net_iface_del_name (const char *iface); + +/** +* @brief Remove an interface (similar to ip link remove) +* +* @param ifindex interface index +* @return int 0 on success, negative error code on error +*/ +int +net_iface_del_index (int ifindex); +#endif /* NETWORKING_SITNL_H_ */
tests/unit_tests/openvpn/test_networking.c +21 -1
@@ -13,6 +13,20 @@ net__iface_up(bool up)return net_iface_up (NULL , iface, up); } +static int +net__iface_new (const char *name,const char * type) +{ +printf ("CMD: ip link add %s type %s\n" , name, type); +return net_iface_new (name, type); +} + +static int +net__iface_del (const char *name) +{ +printf ("CMD: ip link del %s\n" , name); +return net_iface_del_name (name); +} +static int net__iface_mtu_set (int mtu) {
@@ -191,7 +205,7 @@ net__route_v6_add_gw(const char *dst_str, int prefixlen, const char *gw_str,static void usage (char *name) { -printf ("Usage: %s <0-7>\n" , name); +printf ("Usage: %s <0-9>\n" , name); }int
@@ -243,6 +257,12 @@ main(int argc, char *argv[])case 7 :return net__route_v6_add_gw ("2001:cafe:babe::" ,48 ,"2001::2" ,600 ); +case 8 : +return net__iface_new ("dummy0815" ,"dummy" ); + +case 9 : +return net__iface_del ("dummy0815" ); +default :printf ("invalid test: %d\n" , test);break ;
Signature · 1 line
2.32.0
RFC 4/8 ovpn-dco: introduce linux data-channel offload support
In reply to Antonio QuartulliFrom: Arne Schwabe <[email protected]...>
Implement the data-channel offloading using the ovpn-dco kernel module. See README.dco.md for more details.
--- Changes.rst | 7 + README.dco.md | 124 +++ configure.ac | 56 ++ doc/man-sections/advanced-options.rst | 13 + src/openvpn/Makefile.am | 8 +- src/openvpn/crypto.c | 10 + src/openvpn/crypto.h | 6 + src/openvpn/dco.c | 272 +++++++ src/openvpn/dco.h | 118 +++ src/openvpn/errlevel.h | 2 + src/openvpn/event.h | 3 + src/openvpn/forward.c | 66 +- src/openvpn/init.c | 153 +++- src/openvpn/init.h | 2 +- src/openvpn/mtcp.c | 61 +- src/openvpn/mudp.c | 13 + src/openvpn/multi.c | 278 ++++++- src/openvpn/multi.h | 6 +- src/openvpn/networking.h | 1 + src/openvpn/networking_linuxdco.c | 848 +++++++++++++++++++++ src/openvpn/networking_linuxdco.h | 85 +++ src/openvpn/openvpn.vcxproj | 4 +- src/openvpn/openvpn.vcxproj.filters | 6 + src/openvpn/options.c | 143 +++- src/openvpn/options.h | 26 + src/openvpn/socket.h | 1 + src/openvpn/ssl.c | 6 +- src/openvpn/ssl_common.h | 13 + src/openvpn/ssl_ncp.c | 2 +- src/openvpn/tun.c | 13 +- src/openvpn/tun.h | 4 + tests/unit_tests/openvpn/test_networking.c | 9 +- 32 files changed, 2305 insertions(+), 54 deletions(-) create mode 100644 README.dco.md create mode 100644 src/openvpn/dco.c create mode 100644 src/openvpn/dco.h create mode 100644 src/openvpn/networking_linuxdco.c create mode 100644 src/openvpn/networking_linuxdco.h
Changes.rst +7 -0
@@ -62,6 +62,13 @@ Optional ciphers in ``--data-ciphers`` Ciphers in ``--data-ciphers`` can now be prefixed with a ``?`` to mark those as optional and only use them if the SSL library supports them. +Data channel offloading with ovpn-dco + 2.6.0+ implements support for data-channel offloading where the data packets + are directly processed and forwarded in kernel space thanks to the ovpn-dco + kernel module. The userspace openvpn program acts purely as a control plane + application. + + Deprecated features ------------------- ``inetd`` has been removed
README.dco.md new file +124 -0
124 lines not on this page · raw message
configure.ac +56 -0
74 lines not on this page · raw message
doc/man-sections/advanced-options.rst +13 -0
@@ -91,3 +91,16 @@ used when debugging or testing out special usage scenarios. *(Linux only)* Set the TX queue length on the TUN/TAP interface. Currently defaults to operating system default. +--disable-dco + Disables the opportunistic use the data channel offloading if available. + Without this option, OpenVPN will opportunistically use DCO mode if + the config options and the running kernel supports using DCO. + + Data channel offload currently requires data-ciphers to only contain + AEAD ciphers (AES-GCM and Chacha20-Poly1305) and Linux with the + ovpn-dco module. + + Note that some options have no effect or not available when + DCO mode is enabled. + + A platforms that do not support DCO ``disable-dco`` has no effect.
src/openvpn/Makefile.am +6 -2
@@ -30,6 +30,7 @@ AM_CFLAGS = \ $(OPTIONAL_LZ4_CFLAGS) \ $(OPTIONAL_PKCS11_HELPER_CFLAGS) \ $(OPTIONAL_INOTIFY_CFLAGS) \ + ${OPTIONAL_DCO_CFLAGS} \ -DPLUGIN_LIBDIR=\"${plugindir}\" if WIN32
@@ -53,6 +54,7 @@ openvpn_SOURCES = \ crypto.c crypto.h crypto_backend.h \ crypto_openssl.c crypto_openssl.h \ crypto_mbedtls.c crypto_mbedtls.h \ + dco.c dco.h \ dhcp.c dhcp.h \ env_set.c env_set.h \ errlevel.h \
@@ -85,7 +87,8 @@ openvpn_SOURCES = \ multi.c multi.h \ networking_iproute2.c networking_iproute2.h \ networking_sitnl.c networking_sitnl.h \ - networking.h \ + networking_linuxdco.c networking_linuxdco.h \ + networking.h \ ntlm.c ntlm.h \ occ.c occ.h \ openssl_compat.h \
@@ -141,7 +144,8 @@ openvpn_LDADD = \ $(OPTIONAL_SELINUX_LIBS) \ $(OPTIONAL_SYSTEMD_LIBS) \ $(OPTIONAL_DL_LIBS) \ - $(OPTIONAL_INOTIFY_LIBS) + $(OPTIONAL_INOTIFY_LIBS) \ + $(OPTIONAL_DCO_LIBS) if WIN32 openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi
src/openvpn/crypto.c +10 -0
@@ -826,6 +826,16 @@ init_key_ctx(struct key_ctx *ctx, const struct key *key, cipher_kt_iv_size(kt->cipher));warn_insecure_key_type (ciphername, kt->cipher); } + +#if defined(ENABLE_DCO ) +/* Keep key material for DCO */ +static_assert (sizeof (key->cipher) ==sizeof (ctx->aead_key),"DCO key size mismatch" ); +if (kt->keep_key_data) + { +memcpy (ctx->aead_key, key->cipher,sizeof (ctx->aead_key)); + } +#endif +if (kt->digest) { ctx->hmac =hmac_ctx_new ();
src/openvpn/crypto.h +6 -0
@@ -140,6 +140,9 @@ struct key_type {const cipher_kt_t *cipher;/**< Cipher static parameters */ const md_kt_t *digest;/**< Message digest static parameters */ +#if defined(ENABLE_DCO ) +bool keep_key_data; +#endif };/**
@@ -166,6 +169,9 @@ struct key_ctxuint8_t implicit_iv[OPENVPN_MAX_IV_LENGTH ];/**< The implicit part of the IV */ size_t implicit_iv_len;/**< The length of implicit_iv */ +#if defined(ENABLE_DCO ) +uint8_t aead_key[MAX_CIPHER_KEY_LENGTH ];/**< Keeps the key data for use with DCO */ +#endif };#define KEY_DIRECTION_BIDIRECTIONAL 0/* same keys for both directions */
src/openvpn/dco.c new file +272 -0
273 lines not on this page · raw message
src/openvpn/dco.h new file +118 -0
119 lines not on this page · raw message
src/openvpn/errlevel.h +2 -0
@@ -91,6 +91,7 @@#define D_OSBUF LOGLEV(3, 43, 0)/* show socket/tun/tap buffer sizes */ #define D_PS_PROXY LOGLEV(3, 44, 0)/* messages related to --port-share option */ #define D_IFCONFIG LOGLEV(3, 0, 0)/* show ifconfig info (don't mute) */ +#define D_DCO LOGLEV(3, 0, 0)/* show DCO related messages */ #define D_SHOW_PARMS LOGLEV(4, 50, 0)/* show all parameters on program initiation */ #define D_SHOW_OCC LOGLEV(4, 51, 0)/* show options compatibility string */
@@ -113,6 +114,7 @@#define D_TUN_RW LOGLEV(6, 69, M_DEBUG)/* show TUN/TAP reads/writes */ #define D_TAP_WIN_DEBUG LOGLEV(6, 69, M_DEBUG)/* show TAP-Windows driver debug info */ #define D_CLIENT_NAT LOGLEV(6, 69, M_DEBUG)/* show client NAT debug info */ +#define D_DCO_DEBUG LOGLEV(6, 69, M_DEBUG)/* show DCO related lowlevel debug messages */ #define D_SHOW_KEYS LOGLEV(7, 70, M_DEBUG)/* show data channel encryption keys */ #define D_SHOW_KEY_SOURCE LOGLEV(7, 70, M_DEBUG)/* show data channel key source entropy */
src/openvpn/event.h +3 -0
@@ -72,6 +72,9 @@#define MANAGEMENT_WRITE (1 << (MANAGEMENT_SHIFT + WRITE_SHIFT))#define FILE_SHIFT 8#define FILE_CLOSED (1 << (FILE_SHIFT + READ_SHIFT)) +#define DCO_SHIFT 10 +#define DCO_READ (1 << (DCO_SHIFT + READ_SHIFT)) +#define DCO_WRITE (1 << (DCO_SHIFT + WRITE_SHIFT))/* * Initialization flags passed to event_set_init
src/openvpn/forward.c +62 -4
118 lines not on this page · raw message
src/openvpn/init.c +146 -7
211 lines not on this page · raw message
src/openvpn/init.h +1 -1
@@ -30,7 +30,7 @@* Baseline maximum number of events * to wait for. */ -#define BASE_N_EVENTS 4 +#define BASE_N_EVENTS 5void context_clear (struct context *c);
src/openvpn/mtcp.c +47 -14
120 lines not on this page · raw message
src/openvpn/mudp.c +13 -0
@@ -227,6 +227,19 @@ multi_process_io_udp(struct multi_context *m)multi_process_file_closed (m, mpp_flags); }#endif +#ifdef ENABLE_LINUXDCO + else if (status & DCO_READ) + { +if (!IS_SIG (&m->top)) + { +bool ret = true; +while (ret) + { + ret =multi_process_incoming_dco (m); + } + } + } +#endif }/*
src/openvpn/multi.c +260 -18
354 lines not on this page · raw message
src/openvpn/multi.h +5 -1
@@ -98,7 +98,9 @@ struct client_connect_defer_state* server-mode. */ struct multi_instance { -struct schedule_entry se;/* this must be the first element of the structure */ +struct schedule_entry se;/* this must be the first element of the structure, +* We cast between this and schedule_entry so the +* beginning of the struct must be identical */ struct gc_arena gc;bool halt;int refcount;
@@ -308,6 +310,8 @@ void multi_process_float(struct multi_context *m, struct multi_instance *mi);bool multi_process_post (struct multi_context *m,struct multi_instance *mi,const unsigned int flags); +bool multi_process_incoming_dco (struct multi_context *m); +/**************************************************************************/ /** * Demultiplex and process a packet received over the external network
src/openvpn/networking.h +1 -0
@@ -27,6 +27,7 @@ struct context;#ifdef ENABLE_SITNL #include "networking_sitnl.h" +#include "dco.h" #elif ENABLE_IPROUTE #include "networking_iproute2.h" #else
src/openvpn/networking_linuxdco.c new file +848 -0
848 lines not on this page · raw message
src/openvpn/networking_linuxdco.h new file +85 -0
85 lines not on this page · raw message
src/openvpn/openvpn.vcxproj +3 -1
@@ -253,8 +253,9 @@ <ClCompile Include="crypto.c" /> <ClCompile Include="crypto_openssl.c" /> <ClCompile Include="cryptoapi.c" /> - <ClCompile Include="env_set.c" /> + <ClCompile Include="dco.c" /> <ClCompile Include="dhcp.c" /> + <ClCompile Include="env_set.c" /> <ClCompile Include="error.c" /> <ClCompile Include="event.c" /> <ClCompile Include="fdmisc.c" />
@@ -335,6 +336,7 @@ <ClInclude Include="crypto_backend.h" /> <ClInclude Include="crypto_openssl.h" /> <ClInclude Include="cryptoapi.h" /> + <ClInclude Include="dco.h" /> <ClInclude Include="dhcp.h" /> <ClInclude Include="env_set.h" /> <ClInclude Include="errlevel.h" />
src/openvpn/openvpn.vcxproj.filters +6 -0
@@ -39,6 +39,9 @@ <ClCompile Include="dhcp.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="dco.c"> + <Filter>Source Files</Filter> + </ClCompile> <ClCompile Include="error.c"> <Filter>Source Files</Filter> </ClCompile>
@@ -287,6 +290,9 @@ <ClInclude Include="cryptoapi.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="dco.h"> + <Filter>Header Files</Filter> + </ClInclude> <ClInclude Include="dhcp.h"> <Filter>Header Files</Filter> </ClInclude>
src/openvpn/options.c +142 -1
173 lines not on this page · raw message
src/openvpn/options.h +26 -0
@@ -862,4 +862,30 @@ void options_string_import(struct options *options,unsigned int *option_types_found, struct env_set *es); +/** +* Returns whether the current configuration has dco enabled. +*/ +#ifdef ENABLE_LINUXDCO +static inline bool +dco_enabled (struct options *o) {return !o->tuntap_options.disable_dco; } + +/** +* Checks whether the options struct has any option that is not supported by +* our current dco implementation. If so it prints a warning at warning level +* for the first conflicting option found and returns false +* @param msglevel the msg level to use to print the warnings +* @param o the optiions struct that hold the options +* @return true if a conflict with dco is detected. +*/ +bool +check_option_conflict_dco (int msglevel,const struct options *o); +#else +/* Dummy functions to avoid ifdefs in the other code */ + +static inline bool +dco_enabled (struct options *o) {return false; } + +static inline bool +check_option_conflict_dco (int msglevel,struct options *o) {return false; } +#endif #endif /* ifndef OPTIONS_H */
src/openvpn/socket.h +1 -0
@@ -120,6 +120,7 @@ struct link_socket_infosa_family_t af;/* Address family like AF_INET, AF_INET6 or AF_UNSPEC*/ bool bind_ipv6_only;int mtu_changed;/* Set to true when mtu value is changed */ +bool dco_installed; };/*
src/openvpn/ssl.c +5 -1
@@ -1880,6 +1880,10 @@ tls_session_update_crypto_params_do_work(struct tls_session *session,init_key_type (&session->opt->key_type, options->ciphername, options->authname, true, true); +#if defined(ENABLE_DCO ) + session->opt->key_type.keep_key_data =dco_enabled (options); +#endif +bool packet_id_long_form =cipher_kt_mode_ofb_cfb (session->opt->key_type.cipher); session->opt->crypto_flags &= ~(CO_PACKET_ID_LONG_FORM );if (packet_id_long_form)
@@ -2236,7 +2240,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session) {buf_printf (&out,"IV_HWADDR=%s\n" ,format_hex_ex (rgi.hwaddr,6 ,0 ,1 ,":" , &gc)); } -buf_printf (&out,"IV_SSL=%s\n" ,get_ssl_library_version () ); +buf_printf (&out,"IV_SSL=%s\n" ,get_ssl_library_version ());#if defined(_WIN32)buf_printf (&out,"IV_PLAT_VER=%s\n" ,win32_version_string (&gc, false));#endif
src/openvpn/ssl_common.h +13 -0
@@ -167,6 +167,12 @@ enum auth_deferred_result { ACF_FAILED /**< deferred auth has failed */ }; +enum dco_key_status { +DCO_NOT_INSTALLED , +DCO_INSTALLED_PRIMARY , +DCO_INSTALLED_SECONDARY +}; +/** * Security parameter state of one TLS and data channel %key session. * @ingroup control_processor
@@ -240,6 +246,8 @@ struct key_statestruct auth_deferred_status plugin_auth;struct auth_deferred_status script_auth; + +enum dco_key_status dco_status; };/** Control channel wrapping (--tls-auth/--tls-crypt) context */
@@ -634,6 +642,11 @@ struct tls_multi/**< Array of \c tls_session objects * representing control channel * sessions with the remote peer. */ + +/* Only used when DCO is used to remember how many keys we installed +* for this session */ +int dco_keys_installed; +bool dco_peer_added; };/** gets an item of \c key_state objects in the
src/openvpn/ssl_ncp.c +1 -1
@@ -489,4 +489,4 @@ p2p_mode_ncp(struct tls_multi *multi, struct tls_session *session) multi->use_peer_id, multi->peer_id, common_cipher);gc_free (&gc); -} +}
src/openvpn/tun.c +12 -1
@@ -1957,6 +1957,10 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun {open_null (tt); } + else if (!tt->options.disable_dco) + { +open_tun_dco (tt, dev); + } else {/*
@@ -2206,7 +2210,14 @@ close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx)net_ctx_reset (ctx); } -close_tun_generic (tt); +if (!tt->options.disable_dco) + { +close_tun_dco (tt); + } +else + { +close_tun_generic (tt); + }free (tt); }
src/openvpn/tun.h +4 -0
@@ -40,6 +40,7 @@#include "misc.h" #include "networking.h" #include "ring_buffer.h" +#include "networking_linuxdco.h" #ifdef _WIN32#define WINTUN_COMPONENT_ID "wintun"
@@ -138,6 +139,7 @@ struct tuntap_options {struct tuntap_options {int txqueuelen; +bool disable_dco; };#else /* if defined(_WIN32) || defined(TARGET_ANDROID) */
@@ -218,6 +220,8 @@ struct tuntap/* Some TUN/TAP drivers like to be ioctled for mtu * after open */ int post_open_mtu; + +dco_context_t dco; }; static inline bool
tests/unit_tests/openvpn/test_networking.c +7 -2
@@ -1,7 +1,10 @@#include "config.h" #include "syshead.h" +#include "error.h" #include "networking.h" +#include "mock_msg.h" +static char *iface ="ovpn-dummy0" ;
@@ -16,8 +19,10 @@ net__iface_up(bool up)static int net__iface_new (const char *name,const char * type) { -printf ("CMD: ip link add %s type %s\n" , name, type); -return net_iface_new (name, type); +printf ("CMD: ip link add type %s\n" , type); +int ifidx =net_iface_new (NULL , type); +printf ("ifindex: %d\n" , ifidx); +return ifidx; } static int
Signature · 1 line
2.32.0
RFC 5/8 tun: extract close_tun_handle into its own fucntion and print correct type
In reply to Antonio QuartulliFrom: Arne Schwabe <[email protected]...>
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.
--- src/openvpn/tun.c | 75 ++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 34 deletions(-)
src/openvpn/tun.c +41 -34
@@ -6780,6 +6780,46 @@ netsh_delete_address_dns(const struct tuntap *tt, bool ipv6, struct gc_arena *gcargv_free (&argv); } +static +void close_tun_handle (struct tuntap * tt) +{ +const char * adaptertype =print_windows_driver (tt->windows_driver); +if (tt->hand !=NULL ) + { +dmsg (D_WIN32_IO_LOW ,"Attempting CancelIO on %s adapter" , adaptertype); +if (!CancelIo (tt->hand)) + { +msg (M_WARN |M_ERRNO ,"Warning: CancelIO failed on %s adapter" , adaptertype); + } + } + +dmsg (D_WIN32_IO_LOW ,"Attempting close of overlapped read event on %s adapter" , adaptertype); +overlapped_io_close (&tt->reads); + +dmsg (D_WIN32_IO_LOW ,"Attempting close of overlapped write event on %s adapter" , adaptertype); +overlapped_io_close (&tt->writes); + +if (tt->hand !=NULL ) + { +dmsg (D_WIN32_IO_LOW ,"Attempting CloseHandle on %s adapter" , adaptertype); +if (!CloseHandle (tt->hand)) + { +msg (M_WARN |M_ERRNO ,"Warning: CloseHandle failed on %s adapter" , adaptertype); + } + tt->hand =NULL ; + } + +if (tt->windows_driver ==WINDOWS_DRIVER_WINTUN ) + { +CloseHandle (tt->rw_handle.read); +CloseHandle (tt->rw_handle.write); +UnmapViewOfFile (tt->wintun_send_ring); +UnmapViewOfFile (tt->wintun_receive_ring); +CloseHandle (tt->wintun_send_ring_handle); +CloseHandle (tt->wintun_receive_ring_handle); + } +} +void close_tun (struct tuntap *tt,openvpn_net_ctx_t *ctx) {
@@ -6849,43 +6889,10 @@ close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx)dhcp_release (tt); -if (tt->hand !=NULL ) - { -dmsg (D_WIN32_IO_LOW ,"Attempting CancelIO on TAP-Windows adapter" ); -if (!CancelIo (tt->hand)) - { -msg (M_WARN |M_ERRNO ,"Warning: CancelIO failed on TAP-Windows adapter" ); - } - } - -dmsg (D_WIN32_IO_LOW ,"Attempting close of overlapped read event on TAP-Windows adapter" ); -overlapped_io_close (&tt->reads); - -dmsg (D_WIN32_IO_LOW ,"Attempting close of overlapped write event on TAP-Windows adapter" ); -overlapped_io_close (&tt->writes); - -if (tt->hand !=NULL ) - { -dmsg (D_WIN32_IO_LOW ,"Attempting CloseHandle on TAP-Windows adapter" ); -if (!CloseHandle (tt->hand)) - { -msg (M_WARN |M_ERRNO ,"Warning: CloseHandle failed on TAP-Windows adapter" ); - } - } +close_tun_handle (tt);free (tt->actual_name); -if (tt->windows_driver ==WINDOWS_DRIVER_WINTUN ) - { -CloseHandle (tt->rw_handle.read); -CloseHandle (tt->rw_handle.write); -UnmapViewOfFile (tt->wintun_send_ring); -UnmapViewOfFile (tt->wintun_receive_ring); -CloseHandle (tt->wintun_send_ring_handle); -CloseHandle (tt->wintun_receive_ring_handle); - } - -clear_tuntap (tt);free (tt);gc_free (&gc);
Signature · 1 line
2.32.0
RFC 6/8 ovpn-dco-win: introduce windows data-channel offload support
In reply to Antonio QuartulliFrom: Arne Schwabe <[email protected]...>
Implement the data-channel offloading using the ovpn-dco-win kernel module. See README.dco.md for more details.
--- README.dco.md | 8 + config-msvc.h | 12 +- configure.ac | 82 +++++--- src/openvpn/Makefile.am | 1 + src/openvpn/dco.h | 1 + src/openvpn/init.c | 42 +++- src/openvpn/networking_windco.c | 301 ++++++++++++++++++++++++++++ src/openvpn/networking_windco.h | 47 +++++ src/openvpn/openvpn.vcxproj | 2 + src/openvpn/openvpn.vcxproj.filters | 6 + src/openvpn/options.c | 38 +++- src/openvpn/options.h | 27 ++- src/openvpn/socket.c | 125 +++++++++++- src/openvpn/socket.h | 57 +++++- src/openvpn/tun.c | 44 +++- src/openvpn/tun.h | 58 ++++-- 16 files changed, 758 insertions(+), 93 deletions(-) create mode 100644 src/openvpn/networking_windco.c create mode 100644 src/openvpn/networking_windco.h
README.dco.md +8 -0
@@ -60,6 +60,12 @@ see a message like in your log. +Getting started (Windows) +------------------------- +Getting started under windows is currently for brave people having experience +with windows development. You need to compile openvpn yourself and also need +to get the test driver installed on your system. + DCO and P2P mode ---------------- DCO is also available when running OpenVPN in P2P mode without --pull/--client option.
@@ -105,6 +111,8 @@ Limitations by design - topology subnet is the only supported `--topology` for servers - iroute directives install routes on the host operating system, see also routing with ovpn-dco +- (ovpn-dco-win) client and p2p mode only +- (ovpn-dco-win) only AES-GCM-128/192/256 cipher support Current limitations -------------------
config-msvc.h +8 -4
@@ -6,10 +6,10 @@#define ENABLE_CRYPTO_OPENSSL 1#define ENABLE_FRAGMENT 1#define ENABLE_HTTP_PROXY 1 -#define ENABLE_LZO 1 +//#define ENABLE_LZO 1 #define ENABLE_LZ4 1#define ENABLE_MANAGEMENT 1 -#define ENABLE_PKCS11 1 +//#define ENABLE_PKCS11 0 #define ENABLE_PLUGIN 1#define ENABLE_PORT_SHARE 1#define ENABLE_SOCKS 1
@@ -30,8 +30,8 @@#define HAVE_IO_H 1#define HAVE_SYS_TYPES_H 1#define HAVE_SYS_STAT_H 1 -#define HAVE_LZO_LZO1X_H 1 -#define HAVE_LZO_LZOUTIL_H 1 +//#define HAVE_LZO_LZO1X_H 1 +//#define HAVE_LZO_LZOUTIL_H 1 #define HAVE_VERSIONHELPERS_H 1#define HAVE_ACCESS 1
@@ -86,3 +86,7 @@ typedef uint16_t in_port_t;#ifdef HAVE_CONFIG_MSVC_LOCAL_H #include <config-msvc-local.h> #endif + +#define ENABLE_WINDCO 1 +#define ENABLE_DCO 1 +
configure.ac +52 -30
93 lines not on this page · raw message
src/openvpn/Makefile.am +1 -0
@@ -88,6 +88,7 @@ openvpn_SOURCES = \ networking_iproute2.c networking_iproute2.h \ networking_sitnl.c networking_sitnl.h \ networking_linuxdco.c networking_linuxdco.h \ + networking_windco.c networking_windco.h \ networking.h \ ntlm.c ntlm.h \ occ.c occ.h \
src/openvpn/dco.h +1 -0
@@ -41,6 +41,7 @@ static inline void open_tun_dco(struct tuntap *tt, const char* dev) { ASSERT(falstatic inline void close_tun_dco (struct tuntap *tt) {ASSERT (false); }#else +#include "networking_windco.h" #include "networking_linuxdco.h" #include "crypto.h"
src/openvpn/init.c +37 -5
66 lines not on this page · raw message
src/openvpn/networking_windco.c new file +301 -0
302 lines not on this page · raw message
src/openvpn/networking_windco.h new file +47 -0
47 lines not on this page · raw message
src/openvpn/openvpn.vcxproj +2 -0
@@ -279,6 +279,7 @@ <ClCompile Include="mtu.c" /> <ClCompile Include="mudp.c" /> <ClCompile Include="multi.c" /> + <ClCompile Include="networking_windco.c" /> <ClCompile Include="ntlm.c" /> <ClCompile Include="occ.c" /> <ClCompile Include="openvpn.c" />
@@ -365,6 +366,7 @@ <ClInclude Include="mtu.h" /> <ClInclude Include="mudp.h" /> <ClInclude Include="multi.h" /> + <ClInclude Include="networking_windco.h" /> <ClInclude Include="ntlm.h" /> <ClInclude Include="occ.h" /> <ClInclude Include="openvpn.h" />
src/openvpn/openvpn.vcxproj.filters +6 -0
@@ -249,6 +249,9 @@ <ClCompile Include="ssl_util.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="networking_windco.c"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="base64.h">
@@ -374,6 +377,9 @@ <ClInclude Include="multi.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="networking_windco.h"> + <Filter>Header Files</Filter> + </ClInclude> <ClInclude Include="ntlm.h"> <Filter>Header Files</Filter> </ClInclude>
src/openvpn/options.c +33 -5
@@ -2249,6 +2249,11 @@ options_postprocess_verify_ce(const struct options *options, {msg (M_USAGE ,"--windows-driver wintun requires --dev tun" ); } + +if (options->windows_driver ==WINDOWS_DRIVER_WINDCO ) + { +check_option_conflict_dco (M_USAGE , options); + }#endif /* ifdef _WIN32 */ /*
@@ -3001,8 +3006,8 @@ options_postprocess_mutate_invariant(struct options *options)#ifdef _WIN32const int dev =dev_type_enum (options->dev, options->dev_type); -/* when using wintun, kernel doesn't send DHCP requests, so don't use it */ -if (options->windows_driver ==WINDOWS_DRIVER_WINTUN +/* when using wintun/ovpn-dco-win, kernel doesn't send DHCP requests, so don't use it */ +if ((options->windows_driver ==WINDOWS_DRIVER_WINTUN || options->windows_driver ==WINDOWS_DRIVER_WINDCO ) && (options->tuntap_options.ip_win32_type ==IPW32_SET_DHCP_MASQ || options->tuntap_options.ip_win32_type ==IPW32_SET_ADAPTIVE )) { options->tuntap_options.ip_win32_type =IPW32_SET_NETSH ;
@@ -3088,7 +3093,7 @@ options_postprocess_setdefault_ncpciphers(struct options *o)/* custom --data-ciphers set, keep list */ return ; } -else if (cipher_kt_get ("CHACHA20-POLY1305" )) +else if (cipher_kt_get ("CHACHA20-POLY1305" ) && !dco_win_enabled (o)) { o->ncp_ciphers ="AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305" ; }
@@ -3260,6 +3265,22 @@ static bool check_option_conflict_dco_platform(int msglevel, const struct option }return false; } +#elif defined(ENABLE_WINDCO) +static bool check_option_conflict_dco_platform (int msglevel,const struct options *o) +{ +if (o->mode ==MODE_SERVER ) + { +msg (msglevel,"Only client and p2p data channel offload is supported " +"with ovpn-dco-win." ); +return true; + } +if (o->persist_tun) + { +msg (msglevel,"--persist-tun is not supported with ovpn-dco-win." ); +return true; + } +return false; +}#endif bool check_option_conflict_dco (int msglevel,const struct options *o)
@@ -4050,7 +4071,8 @@ options_string(const struct options *o,NULL , false,NULL , - ctx); + ctx, + NULL);if (tt) { tt_local = true;
@@ -4472,9 +4494,15 @@ parse_windows_driver(const char *str, const int msglevel) {return WINDOWS_DRIVER_WINTUN ; } + + else if (streq(str, "ovpn-dco-win")) + { +return WINDOWS_DRIVER_WINDCO ; + } else { -msg (msglevel,"--windows-driver must be tap-windows6 or wintun" ); +msg (msglevel,"--windows-driver must be tap-windows6, wintun " +"or ovpn-dco-win" );return WINDOWS_DRIVER_UNSPECIFIED ; } }
src/openvpn/options.h +21 -6
@@ -865,10 +865,30 @@ void options_string_import(struct options *options,/** * Returns whether the current configuration has dco enabled. */ -#ifdef ENABLE_LINUXDCO +#if defined(ENABLE_LINUXDCO )static inline bool dco_enabled (struct options *o) {return !o->tuntap_options.disable_dco; } +#elif defined(ENABLE_WINDCO ) +static inline bool dco_enabled (struct options *o) +{ +return o->windows_driver ==WINDOWS_DRIVER_WINDCO ; +} +#else +/* Dummy functions to avoid ifdefs in the other code */ +static inline bool +dco_enabled (struct options *o) {return false; } +#endif + +#if defined(ENABLE_WINDCO ) +static inline bool +dco_win_enabled (struct options *o) {return dco_enabled (o); } +#else +static inline bool +dco_win_enabled (struct options *o) {return false; } +#endif + +#if defined(ENABLE_DCO )/** * Checks whether the options struct has any option that is not supported by * our current dco implementation. If so it prints a warning at warning level
@@ -880,11 +900,6 @@ dco_enabled(struct options *o) { return !o->tuntap_options.disable_dco; }bool check_option_conflict_dco (int msglevel,const struct options *o);#else -/* Dummy functions to avoid ifdefs in the other code */ - -static inline bool -dco_enabled (struct options *o) {return false; } -static inline bool check_option_conflict_dco (int msglevel,struct options *o) {return false; }#endif
src/openvpn/socket.c +116 -9
185 lines not on this page · raw message
src/openvpn/socket.h +49 -8
100 lines not on this page · raw message
src/openvpn/tun.c +35 -9
101 lines not on this page · raw message
src/openvpn/tun.h +41 -17
117 lines not on this page · raw message
Signature · 1 line
2.32.0
RFC 7/8 ovpn-dco-win: fix mingw i686 build
In reply to Antonio QuartulliFrom: Lev Stipakov <[email protected]...>
mingw i686 has GetOverlappedResultEx() in header file but not in lib file, causing linking error.
To work around this issue, introduce dco_get_overlapped_result compat macro, which is defined as GetOverlappedResultEx() for all build configurations except mingw i686. For latter case, define compat implementation which uses GetOverlappedResult() and Sleep().
--- src/compat/Makefile.am | 3 +- src/compat/compat-dco_get_overlapped_result.c | 44 +++++++++++++++++++ src/compat/compat.h | 6 +++ src/compat/compat.vcxproj | 1 + src/compat/compat.vcxproj.filters | 3 ++ src/openvpn/networking_windco.c | 11 +++-- 6 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 src/compat/compat-dco_get_overlapped_result.c
src/compat/Makefile.am +2 -1
@@ -28,4 +28,5 @@ libcompat_la_SOURCES = \ compat-gettimeofday.c \ compat-daemon.c \ compat-strsep.c \ - compat-versionhelpers.h + compat-versionhelpers.h \ + compat-dco_get_overlapped_result.c
src/compat/compat-dco_get_overlapped_result.c new file +44 -0
44 lines not on this page · raw message
src/compat/compat.h +6 -0
@@ -62,4 +62,10 @@ char *strsep(char **stringp, const char *delim);#endif +#if defined(__MINGW32__) && !defined(__MINGW64__) +BOOL dco_get_overlapped_result (HANDLE handle,OVERLAPPED * ov,DWORD * transferred,DWORD delay_millisec,BOOL unused); +#else +#define dco_get_overlapped_result GetOverlappedResultEx +#endif +#endif /* COMPAT_H */
src/compat/compat.vcxproj +1 -0
@@ -159,6 +159,7 @@ </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="compat-basename.c" /> + <ClCompile Include="compat-dco_get_overlapped_result.c" /> <ClCompile Include="compat-dirname.c" /> <ClCompile Include="compat-gettimeofday.c" /> <ClCompile Include="compat-daemon.c" />
src/compat/compat.vcxproj.filters +3 -0
@@ -30,6 +30,9 @@ <ClCompile Include="compat-strsep.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="compat-dco_get_overlapped_result.c"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="compat.h">
src/openvpn/networking_windco.c +8 -3
@@ -74,17 +74,22 @@ void dco_start_tun(struct tuntap* tt)int dco_connect_wait (HANDLE handle,OVERLAPPED * ov,int timeout,volatile int * signal_received) { -while (timeout-- >0 ) +DWORD timeout_msec = timeout *1000 ; +const int poll_interval_ms =50 ; + +while (timeout_msec >0 ) { + timeout_msec -= poll_interval_ms; +DWORD transferred; -if (GetOverlappedResultEx (handle, ov, &transferred,1000 , FALSE) !=0 ) +if (dco_get_overlapped_result (handle, ov, &transferred, poll_interval_ms, FALSE) !=0 ) {/* TCP connection established by dco */ return 0 ; }DWORD err =GetLastError (); -if (err !=WAIT_TIMEOUT ) +if ((err !=WAIT_TIMEOUT ) && (err !=ERROR_IO_INCOMPLETE )) {/* dco reported connection error */ struct gc_arena gc =gc_new ();
Signature · 1 line
2.32.0
RFC 8/8 ovpn-dco: force user to set DCO_INCLUDEDIR
In reply to Antonio Quartulli--- configure.ac | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-)
configure.ac +10 -22
@@ -777,29 +777,22 @@ PKG_CHECK_MODULES( if test "$enable_dco" = "yes"; then dnl -dnl Configure path for the ovpn-dco kernel module source directory. +dnl Configure path for the ovpn-dco header directory. dnl -dnl This is similar to the core librariy, there is an embedded -dnl version in this tree which will be used by default. The -dnl git checkout inside the ovpn-dco/ directory is managed via git -dnl submodule. -dnl - AC_ARG_VAR([DCO_SOURCEDIR], [Alternative ovpn-dco kernel module source directory]) - if test -z "${DCO_SOURCEDIR}"; then - case "$host" in - *-mingw*) DCO_SOURCEDIR="${srcdir}/../ovpn-dco-win";; - *) DCO_SOURCEDIR="${srcdir}/../ovpn-dco";; - esac + AC_ARG_VAR([DCO_INCLUDEDIR], [ovpn-dco header directory (where to find ovpn-dco.h)]) + if test -z "${DCO_INCLUDEDIR}"; then + AC_MSG_ERROR([You must specify DCO_INCLUDEDIR when using --enable-dco.]) + fi - AC_MSG_NOTICE([Using ovpn-dco source directory: ${DCO_SOURCEDIR}]) - AC_SUBST([DCO_SOURCEDIR]) + + AC_MSG_NOTICE([Using ovpn-dco header directory: ${DCO_INCLUDEDIR}]) + DCO_CFLAGS="-I${DCO_INCLUDEDIR}" case "$host" in *-*-linux*) dnl dnl Include generic netlink library used to talk to ovpn-dco dnl - saved_CFLAGS="${CFLAGS}" PKG_CHECK_MODULES( [LIBNL_GENL], [libnl-genl-3.0 >= 3.2.29],
@@ -807,16 +800,12 @@ dnl [AC_MSG_ERROR([libnl-genl-3.0 package not found or too old. Is the development package and pkg-config installed? Must be version 3.4.0 or newer])] ) - DCO_CFLAGS="-I${DCO_SOURCEDIR}/include/uapi ${LIBNL_GENL_CFLAGS}" - - CFLAGS="${CFLAGS} ${DCO_CFLAGS}" + CFLAGS="${CFLAGS} ${DCO_CFLAGS} ${LIBNL_GENL_CFLAGS}" AC_CHECK_HEADERS( [linux/ovpn_dco.h], , - [AC_MSG_ERROR([linux/ovpn_dco.h is missing (use DCO_SOURCE to set path to it, CFLAGS=${CFLAGS})])] + [AC_MSG_ERROR([linux/ovpn_dco.h couldn't be found (use DCO_INCLUDEDIR to set the path to it, CFLAGS=${CFLAGS})])] ) - CFLAGS=${saved_CFLAGS} - OPTIONAL_DCO_LIBS="${LIBNL_GENL_LIBS}" AC_DEFINE(ENABLE_LINUXDCO, 1, [Enable linux data channel offload])
@@ -1407,7 +1396,6 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS]) AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS]) AC_SUBST([OPTIONAL_INOTIFY_CFLAGS]) AC_SUBST([OPTIONAL_INOTIFY_LIBS]) -AC_SUBST([OPTIONAL_DCO_CFLAGS]) AC_SUBST([OPTIONAL_DCO_LIBS]) AC_SUBST([PLUGIN_AUTH_PAM_CFLAGS])
Signature · 1 line
2.32.0
Re: [Openvpn-devel] [RFC 8/8] ovpn-dco: force user to set DCO_INCLUDEDIR
Hi,
Quoted 4 lines · Antonio Quartulli
Signed-off-by Antonio Quartulli <[email protected]...>--- configure.ac | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-)
I think this should be squashed into the first patch, that adds DCO support to configure.ac in the first place.
Plus, I wonder how we should do this in the first place - if we want widespread DCO adoption, maybe we should include the necessary header file into the openvpn community tree, and always compile "with DCO" on Linux (if libnl is available)?
Having to fiddle with an extra library dependency *and* "you need this header file which is found elsewhere" feels extra clumsy...
Alternatively, maybe linuxdco should just install the header file when installing the kernel module? How's this typically done for other kernel modules that expose an API that needs a header file?
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Re: [Openvpn-devel] [RFC 8/8] ovpn-dco: force user to set DCO_INCLUDEDIR
Hi,
Quoted 11 lines · Gert Doering
Hi,
Quoted 4 lines · Antonio Quartulli
Signed-off-by Antonio Quartulli <[email protected]...>--- configure.ac | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-)I think this should be squashed into the first patch, that adds DCO support to configure.ac in the first place.
Yeah, this is done already.
Quoted 5 lines
Plus, I wonder how we should do this in the first place - if we want widespread DCO adoption, maybe we should include the necessary header file into the openvpn community tree, and always compile "with DCO" on Linux (if libnl is available)?
Quoted 7 lines
Having to fiddle with an extra library dependency *and* "you need this header file which is found elsewhere" feels extra clumsy...
Alternatively, maybe linuxdco should just install the header file when installing the kernel module? How's this typically done for other kernel modules that expose an API that needs a header file?
Normally the required header is just shipped with the program itself (i.e. check the 'iw' program which comes with its own copy of 'nl80211.h').
Being this API forward compatible, it won't hurt if our header is slightly out-of-date.
Ideally, when DCO will be upstream, the header will be installed automatically along with other kernel headers. But we still can't assume they are installed, hence it's just easier to ship the header with the OpenVPN source code.
I'd just do that at the end.
Regards,
Signature · 1 line
Antonio Quartulli
Hi,
1) 7/8 should be squashed into 6/8, because 6/8 "ovpn-dco-win:
introduce windows data-channel offload support" breaks mingw i686 build, which 7/8 "ovpn-dco-win: fix mingw i686 build" fixes.
2) Patch 6/8 "ovpn-dco-win: introduce windows data-channel offload support" has commented out certain msvc defines - this was needed because back then (when patch was originally written) MSVC didn't support lzo/pkcs11, but now everything is supported
(we build releases with MSVC) and those defines needed to be brought back. I have fixed that in my branch:
https://github.com/lstipakov/openvpn/commit/5f09bce8a50778fca9904f916f5b1073046aee84
and this needs to be squashed into 6/8
3) At the moment this doesn't compile with GitHub actions because of
a) missing ovpn-dco-win vcpkg port and b) "generic" build system code
has a bug in regards to ovpn-dco-win support. This is the fix for
MSVC/vcpkg: https://github.com/lstipakov/openvpn/commit/96a38f88254ae6ffee1cc262a295e62edecb213a
and this is for generic build system:
https://github.com/lstipakov/openvpn/commit/3058675e63a84e93bd5612238ecbd41cca463a0a
As before they needed to be squashed into "feature" commits and not
added separately as "fixes"
All those fixes are in my repo and GitHub Actions are green:
https://github.com/lstipakov/openvpn/actions/runs/1551278629
-Lev
Hi,
Quoted 3 lines · Lev Stipakov
All those fixes are in my repo and GitHub Actions are green:
https://github.com/lstipakov/openvpn/actions/runs/1551278629
Thanks for providing these fixes, Lev.
I have squashed all your new patches and I have also applied some minor corrections to make sure everything would still build.
Now GH Actions are all green again.
Thanks a lot.
Best Regards,
Signature · 1 line
Antonio Quartulli