Skip to contentSkip to conversation

Change in openvpn[master]: Refactor methods to use the actual state of tun rather the options st...

Openvpn-devel plaisthos (Code Review) 1 participant 5 messages Sep 18, 2024 – Sep 19, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1726680937000.Ib8ba2b63ea9fd1944ff07f69c545a880e464680c@...2715...

#1 lore raw

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

---
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

src/openvpn/dco.c +4 -4
index 2f33973..384ffe6 100644
@@ -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;
     }
src/openvpn/forward.c +3 -3
index 9c78adf..4b620ea 100644
@@ -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");
src/openvpn/tun.c +0 -9
index ec63bff..e44f2f0 100644
@@ -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,
src/openvpn/tun.h +6 -0
index db0b5d7..7e4cb59 100644
@@ -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)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/753?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c
Gerrit-Change-Number: 753
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/753?usp=email )

Change subject: Refactor methods to use the actual state of tun rather the options struct
......................................................................

Patch Set 1: Code-Review-2

(1 comment)

Patchset:

PS1:
Not ready yet. While the patch is correct, it is missing a few instances.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/753?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c
Gerrit-Change-Number: 753
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 18 Sep 2024 17:36:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/753?usp=email )

Change subject: Refactor methods to use the actual state of tun rather the options struct
......................................................................

Patch Set 1: Code-Review-1

(1 comment)

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/753/comment/3d324953_82de2ce7 :
PS1, Line 634: if (tun_dco_enabled(m->top.c1.tuntap))
this does not look correct - it goes from "if(!dco_enabled)" to "if(tun_dco_enabled)" without !.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/753?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c
Gerrit-Change-Number: 753
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 18 Sep 2024 19:07:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/753?usp=email )

Change subject: Refactor methods to use the actual state of tun rather the options struct
......................................................................

Patch Set 1:

(1 comment)

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/753/comment/0e3f0b75_606dc005 :
PS1, Line 634: if (tun_dco_enabled(m->top.c1.tuntap))

Quoted 1 line

this does not look correct - it goes from "if(!dco_enabled)" to "if(tun_dco_enabled)" without !.

Yeah that looks like a mistake but this patch is also accidentially pushed and not really ready yet.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/753?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c
Gerrit-Change-Number: 753
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 18 Sep 2024 21:38:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/753?usp=email )

Change subject: Refactor methods to use the actual state of tun rather the options struct
......................................................................

Patch Set 1: -Code-Review

This change is ready for review.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/753?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c
Gerrit-Change-Number: 753
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Sep 2024 10:52:40 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment