Skip to contentSkip to conversation

tun.h: remove TUN_PASS_BUFFER define

PATCH In review Lev Stipakov 3 participants 3 messages Sep 9, 2019 – Sep 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tun.h: remove TUN_PASS_BUFFER define

Since the very beginning this define has only been used together with _WIN32 and code wrapped into it uses Win32 API, so it could be safely removed and replaced with _WIN32.

---
 src/openvpn/forward.c | 4 ++--
 src/openvpn/tun.h     | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)
src/openvpn/forward.c +2 -2
index c2dcb53..8451706 100644
@@ -1256,7 +1256,7 @@ read_incoming_tun(struct context *c)
     perf_push(PERF_READ_IN_TUN);
 
     c->c2.buf = c->c2.buffers->read_tun_buf;
-#ifdef TUN_PASS_BUFFER
+#ifdef _WIN32
     read_tun_buffered(c->c1.tuntap, &c->c2.buf);
 #else
     ASSERT(buf_init(&c->c2.buf, FRAME_HEADROOM(&c->c2.frame)));
@@ -1877,7 +1877,7 @@ process_outgoing_tun(struct context *c)
                                 &c->c2.n_trunc_tun_write);
 #endif
 
-#ifdef TUN_PASS_BUFFER
+#ifdef _WIN32
         size = write_tun_buffered(c->c1.tuntap, &c->c2.to_tun);
 #else
         size = write_tun(c->c1.tuntap, BPTR(&c->c2.to_tun), BLEN(&c->c2.to_tun));
src/openvpn/tun.h +0 -2
index 69831c4..c8f08e2 100644
@@ -336,8 +336,6 @@ route_order(void)
 
 #ifdef _WIN32
 
-#define TUN_PASS_BUFFER
-
 struct tap_reg
 {
     const char *guid;
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Lev Stipakov

Since the very beginning this define has only been used together with _WIN32 and code wrapped into it uses Win32 API, so it could be safely removed and replaced with _WIN32.

---
 src/openvpn/forward.c | 4 ++--
 src/openvpn/tun.h     | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

I've only glared at the code, and it makes sense. It removes a macro only enabled when _WIN32 is anyhow defined. When this macro doesn't even give much extra clarity, swapping out TUN_PASS_BUFFER with _WIN32 makes more sense.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#2 lore raw
In reply to Lev Stipakov

Your patch has been applied to the master branch.

Not sure if it increades readability very much, given that the functions are still called "..._buffered()", and what they really do is "..._win32_special_asyncio_using_packet_buffer_from_event_loop()" (if I read tun.h/tun.c right).

But it's certainly not making things worse :-)

commit daaa43941c7fa3b7689a5abcbd4e8e30f63856d2

Author: Lev Stipakov
Date:   Mon Sep 9 11:57:16 2019 +0300
     tun.h: remove TUN_PASS_BUFFER define

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: David Sommerseth <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg18808.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering