From: "plaisthos (Code Review)" Date: Wed, 18 Sep 2024 17:35:44 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <6c122f07c357a8877ba5259f3f6f01df7199b788-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="YvWoyDWz77s="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Refactor methods to use the actual state of tun rather the options st... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --YvWoyDWz77s= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=3Demail 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 --- 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 diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index 2f33973..384ffe6 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -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; } diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 9c78adf..4b620ea 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -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) =3D=3D 0) + if (tun_dco_enabled(c->c1.tuntap) && dco_get_peer_stats(c) =3D=3D 0) { int64_t tot_bytes =3D c->c2.tun_read_bytes + c->c2.tun_write_bytes; int64_t new_bytes =3D tot_bytes - c->c2.inactivity_bytes; @@ -623,7 +623,7 @@ const uint8_t *orig_buf =3D c->c2.buf.data; struct crypto_options *co =3D NULL; - if (dco_enabled(&c->options)) + if (tun_dco_enabled(c->c1.tuntap)) { msg(M_WARN, "Attempting to send data packet while data channel off= load is in use. " "Dropping packet"); diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index ec63bff..e44f2f0 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -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 =3D=3D 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_no= de, diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index db0b5d7..7e4cb59 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -261,6 +261,12 @@ #endif } +inline static bool +tun_dco_enabled(struct tuntap *tt) +{ + return tt && tt->backend_driver =3D=3D DRIVER_DCO; +} + #ifdef _WIN32 static inline bool tuntap_is_wintun(struct tuntap *tt) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/753?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c Gerrit-Change-Number: 753 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --YvWoyDWz77s= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

Refactor methods to use the actual state of tun rather the op=
tions struct

Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680cSigned-off-by: Arne Schwabe <arne@...1227...>
---
M src/openvp= n/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 p= ull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/53/753/1
di=
ff --git a/src/openvpn/dco.c b/src/openvpn/dco.c
index 2f33= 973..384ffe6 100644
--- a/src/openvpn/dco.c
+++ b/src/openvpn/dco.c
@@ -476,7 +476,7 @@
int
dco_p2p_add_new_peer(struct context *c)
<= span> {
- if (!dco_e= nabled(&c->options))
+ if (!tun_dco_enabled(c->c1.tuntap))
{
return 0;
}
@@= -511,7 +511,7 @@
void
dco_remove_peer(st= ruct context *c)
{
- if (!dco_enabled(&c->options))
+ if (!tun_dco_enabled(c->c1.tunta= p))
{
return;
}

@@ -631,7 +631,7 @@
= struct mroute_addr *addr)
{
#if defi= ned(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(TARG= ET_FREEBSD)
- if (!d= co_enabled(&m->top.options))
+ if (!tun_dco_enabled(m->top.c1.tuntap))
{
return;
}diff --git a/src/openvpn/forward.c b/src/openvpn/forward.cindex 9c78adf..4b620ea 100644
--- a/src/openvpn/for= ward.c
+++ b/src/openvpn/forward.c
@@ -145,= 7 +145,7 @@
check_dco_key_status(struct context *c)=
{
/* DCO context is not yet initialised or = enabled */
- if (!dc= o_enabled(&c->options))
+ if (!tun_dco_enabled(c->c1.tuntap))
= {
return;
}
@= @ -483,7 +483,7 @@
static void
check_inac= tivity_timeout(struct context *c)
{
- if (dco_enabled(&c->options) &am= p;& dco_get_peer_stats(c) =3D=3D 0)
+ if (tun_dco_enabled(c->c1.tuntap) && dco= _get_peer_stats(c) =3D=3D 0)
{
= int64_t tot_bytes =3D c->c2.tun_read_bytes + c->c2.tun_write_bytes;=
int64_t new_bytes =3D tot_bytes - c->c2.inacti= vity_bytes;
@@ -623,7 +623,7 @@
const = uint8_t *orig_buf =3D c->c2.buf.data;
struct crypto= _options *co =3D NULL;

- if (dco_enabled(&c->options))
+ if (tun_dco_enabled(c->c1.tu= ntap))
{
msg(M_WARN, "At= tempting to send data packet while data channel offload is in use. "
"Dropping packet");
d= iff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index ec6= 3bff..e44f2f0 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c

@@ -1872,15 +1872,6 @@
= return has_digit(dev);
}

-#if defined(TARGET_LINUX) = || defined(TARGET_FREEBSD)
-static bool
-tun_d= co_enabled(struct tuntap *tt)
-{
- return t= t->backend_driver =3D=3D DRIVER_DCO;
-}
-#e= ndif
-
-
#if !(defined(_WIN32= ) || defined(TARGET_LINUX) || defined(TARGET_SOLARIS))
sta= tic void
open_tun_generic(const char *dev, const char *dev= _type, const char *dev_node,
diff --git a/src/openvpn/tun.h= b/src/openvpn/tun.h
index db0b5d7..7e4cb59 100644--- a/src/openvpn/tun.h
+++ b/src/openvpn/tun.h
@@ -261,6 +261,12 @@
#endif
= }

+= inline static bool
+t= un_dco_enabled(struct tuntap *tt)
+{
+ = return tt && tt->backend_driver =3D=3D DRIVER_DCO;
+}

+
#ifdef _WIN32
st= atic inline bool
tuntap_is_wintun(struct tuntap *tt)


To view, visit change 753. To unsubscribe, or for= help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8ba2b63ea9fd1944ff07f69c54= 5a880e464680c
Gerrit-Change-Number: 753
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--YvWoyDWz77s=--