@@ -476,7 +476,7 @@
int
dco_p2p_add_new_peer(struct context *c)
{
- if (!dco_enabled(&c->options))
+ if (!tun_dco_enabled(c->c1.tuntap))
{
return 0;
}
@@ -511,7 +511,7 @@
void
dco_remove_peer(struct context *c)
{
- if (!dco_enabled(&c->options))
+ if (!tun_dco_enabled(c->c1.tuntap))
{
return;
}
@@ -631,7 +631,7 @@
struct mroute_addr *addr)
{
#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
- if (!dco_enabled(&m->top.options))
+ if (tun_dco_enabled(m->top.c1.tuntap))
{
return;
}
@@ -668,7 +668,7 @@
dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi)
{
#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
- if (!dco_enabled(&m->top.options))
+ if (!tun_dco_enabled(m->top.c1.tuntap))
{
return;
}
@@ -145,7 +145,7 @@
check_dco_key_status(struct context *c)
{
/* DCO context is not yet initialised or enabled */
- if (!dco_enabled(&c->options))
+ if (!tun_dco_enabled(c->c1.tuntap))
{
return;
}
@@ -483,7 +483,7 @@
static void
check_inactivity_timeout(struct context *c)
{
- if (dco_enabled(&c->options) && dco_get_peer_stats(c) == 0)
+ if (tun_dco_enabled(c->c1.tuntap) && dco_get_peer_stats(c) == 0)
{
int64_t tot_bytes = c->c2.tun_read_bytes + c->c2.tun_write_bytes;
int64_t new_bytes = tot_bytes - c->c2.inactivity_bytes;
@@ -623,7 +623,7 @@
const uint8_t *orig_buf = c->c2.buf.data;
struct crypto_options *co = NULL;
- if (dco_enabled(&c->options))
+ if (tun_dco_enabled(c->c1.tuntap))
{
msg(M_WARN, "Attempting to send data packet while data channel offload is in use. "
"Dropping packet");
@@ -1872,15 +1872,6 @@
return has_digit(dev);
}
-#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
-static bool
-tun_dco_enabled(struct tuntap *tt)
-{
- return tt->backend_driver == DRIVER_DCO;
-}
-#endif
-
-
#if !(defined(_WIN32) || defined(TARGET_LINUX) || defined(TARGET_SOLARIS))
static void
open_tun_generic(const char *dev, const char *dev_type, const char *dev_node,
@@ -261,6 +261,12 @@
#endif
}
+inline static bool
+tun_dco_enabled(struct tuntap *tt)
+{
+ return tt && tt->backend_driver == DRIVER_DCO;
+}
+
#ifdef _WIN32
static inline bool
tuntap_is_wintun(struct tuntap *tt)
Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/753?usp=email to review the following change. Change subject: Refactor methods to use the actual state of tun rather the options struct ...................................................................... Refactor methods to use the actual state of tun rather the options struct Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c Signed-off-by: Arne Schwabe <arne@rfc2549.org> --- M src/openvpn/dco.c M src/openvpn/forward.c M src/openvpn/tun.c M src/openvpn/tun.h 4 files changed, 13 insertions(+), 16 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/53/753/1