[Openvpn-devel,02/25] dco: add helper function to detect if DCO is enabled or not

Message ID 20220624083809.23487-3-a@unstable.cc
State Accepted
Headers show
Series
  • ovpn-dco: introduce data-channel offload support
Related show

Commit Message

Antonio Quartulli June 24, 2022, 8:37 a.m.
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
 src/openvpn/options.h | 20 ++++++++++++++++++++
 src/openvpn/tun.h     |  1 +
 2 files changed, 21 insertions(+)

Comments

Arne Schwabe June 27, 2022, 11:47 a.m. | #1
Am 24.06.22 um 10:37 schrieb Antonio Quartulli:
> Signed-off-by: Antonio Quartulli <a@unstable.cc>
> ---
>   src/openvpn/options.h | 20 ++++++++++++++++++++
>   src/openvpn/tun.h     |  1 +
>   2 files changed, 21 insertions(+)
> 

Acked-By: Arne Schwabe <arne@rfc2549.org>
Gert Doering June 28, 2022, 3:11 p.m. | #2
Trivial enough :-) - compile tested on Linux (with --enable-dco) and FreeBSD.

Your patch has been applied to the master branch.

commit 4f1671fabdce2df94f01e63ff97191325c5bfa8c
Author: Antonio Quartulli
Date:   Fri Jun 24 10:37:46 2022 +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>


--
kind regards,

Gert Doering
Heiko Hund July 5, 2022, 12:36 p.m. | #3
On Freitag, 24. Juni 2022 10:37:46 CEST Antonio Quartulli wrote:
> +/**
> + * Returns whether the current configuration has dco enabled.
> + */
> +static inline bool
> +dco_enabled(const struct options *o)
> +{
> +    return !o->tuntap_options.disable_dco;
> +}

I think it would be beneficial if this took a tun_options* instead, as it 
could be used more widely and replace the many "!tt->options.disable_dco" 
occurrences and alike.

Patch

diff --git a/src/openvpn/options.h b/src/openvpn/options.h
index c2937dc3..8152e755 100644
--- a/src/openvpn/options.h
+++ b/src/openvpn/options.h
@@ -879,4 +879,24 @@  void options_string_import(struct options *options,
 
 bool key_is_external(const struct options *options);
 
+#if defined(ENABLE_DCO) && defined(TARGET_LINUX)
+
+/**
+ * Returns whether the current configuration has dco enabled.
+ */
+static inline bool
+dco_enabled(const struct options *o)
+{
+    return !o->tuntap_options.disable_dco;
+}
+
+#else /* if defined(ENABLE_DCO) && defined(TARGET_LINUX) */
+
+static inline bool
+dco_enabled(const struct options *o)
+{
+    return false;
+}
+
+#endif
 #endif /* ifndef OPTIONS_H */
diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h
index 60cd574d..5fcea590 100644
--- a/src/openvpn/tun.h
+++ b/src/openvpn/tun.h
@@ -139,6 +139,7 @@  struct tuntap_options {
 
 struct tuntap_options {
     int txqueuelen;
+    bool disable_dco;
 };
 
 #else  /* if defined(_WIN32) || defined(TARGET_ANDROID) */