Skip to contentSkip to conversation

close_tun: print interface type consistently in message

PATCH Superseded Antonio Quartulli 2 participants 4 messages Aug 18, 2022 – Oct 23, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 close_tun: print interface type consistently in message

When closing the tunnel interface we know if we were using DCO or not. for this reason we can customize the closing message and make it consistent with the opening one.

---
 src/openvpn/init.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
src/openvpn/init.c +9 -1
index e8335c53..92c4cab9 100644
@@ -1921,7 +1921,15 @@ do_open_tun(struct context *c)
 static void
 do_close_tun_simple(struct context *c)
 {
-    msg(D_CLOSE, "Closing TUN/TAP interface");
+    if (dco_enabled(&c->options))
+    {
+        msg(D_CLOSE, "Closing DCO interface");
+    }
+    else
+    {
+        msg(D_CLOSE, "Closing TUN/TAP interface");
+    }
+
     if (c->c1.tuntap)
     {
         close_tun(c->c1.tuntap, &c->net_ctx);
Signature · 1 line
2.30.2
#1 lore raw

Hi,

Quoted 16 lines · Antonio Quartulli

When closing the tunnel interface we know if we were using DCO or not. for this reason we can customize the closing message and make it consistent with the opening one.

---
 src/openvpn/init.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
src/openvpn/init.c +0 -0
index e8335c53..92c4cab9 100644
@@ -1921,7 +1921,15 @@ do_open_tun(struct context *c)
 static void
 do_close_tun_simple(struct context *c)

src/openvpn/init.c do_open_tun(struct context *c) · line 1931

Quoted 10 lines
src/openvpn/init.c +8 -1
 {
-    msg(D_CLOSE, "Closing TUN/TAP interface");
+    if (dco_enabled(&c->options))
+    {
+        msg(D_CLOSE, "Closing DCO interface");
+    }
+    else
+    {
+        msg(D_CLOSE, "Closing TUN/TAP interface");
+    }

I find this is a bit excessive in lines of code...

If we really want this, I think we should do

+ msg(D_CLOSE, "Closing %s interface",

          dco_enabled(&c->options)? "DCO": "TUN/TAP");

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#2 lore raw

PATCH v2 1/1 close_tun: print interface type consistently in message

In reply to Antonio Quartulli

When closing the tunnel interface we know if we were using DCO or not. for this reason we can customize the closing message and make it consistent with the opening one.

---
Changes from v1:
* use termary if instead of full blown if block

---
 src/openvpn/init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpn/init.c +3 -1
index c48048a1..01d6dab5 100644
@@ -1946,7 +1946,9 @@ do_open_tun(struct context *c)
 static void
 do_close_tun_simple(struct context *c)
 {
-    msg(D_CLOSE, "Closing TUN/TAP interface");
+    msg(D_CLOSE, "Closing %s interface",
+        dco_enabled(&c->options) ? "DCO": "TUN/TAP");
+
     if (c->c1.tuntap)
     {
         if (!c->options.ifconfig_noexec)
Signature · 1 line
2.37.4
Acked-by on v2 1/1
#3 lore raw

Tested on Linux with/without --disable-dco, and the expected message shows up. Test compiled on FreeBSD (without DCO) and nothing breaks.

Your patch has been applied to the master branch.

commit 77829be280b3b280f35d1ca4947900f3c5e5dd26

Author: Antonio Quartulli
Date:   Sat Oct 22 22:55:21 2022 +0200
     close_tun: print interface type consistently in message

     Signed-off-by: Antonio Quartulli <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg25449.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering