[Openvpn-devel,v11] Use print_tun_backend_driver instead of custom code to print type

Message ID 20240924125513.10710-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v11] Use print_tun_backend_driver instead of custom code to print type | expand

Commit Message

Gert Doering Sept. 24, 2024, 12:55 p.m. UTC
From: Arne Schwabe <arne@rfc2549.org>

Also show the device type that we opened always instead of certain
conditions only.

Change-Id: Ib8f12516dbe294e21d3fed77478fb7660d4600c1
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/749
This mail reflects revision 11 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering Sept. 24, 2024, 1:12 p.m. UTC | #1
Straight forward code simplification and generalization.

Your patch has been applied to the master branch.

commit 193b4f9dd0b09379c0f8f2be0613a1405bbdac8a
Author: Arne Schwabe
Date:   Tue Sep 24 14:55:13 2024 +0200

     Use print_tun_backend_driver instead of custom code to print type

     Signed-off-by: Arne Schwabe <arne@rfc2549.org>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20240924125513.10710-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29386.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index fbf2c5b..cd9203a 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -1876,6 +1876,7 @@ 
         open_tun(c->options.dev, c->options.dev_type, c->options.dev_node,
                  tt, &c->net_ctx);
     }
+    msg(M_INFO, "%s device [%s] opened", print_tun_backend_driver(tt->backend_driver), tt->actual_name);
 }
 
 
@@ -2056,7 +2057,7 @@ 
 do_close_tun_simple(struct context *c)
 {
     msg(D_CLOSE, "Closing %s interface",
-        dco_enabled(&c->options) ? "DCO" : "TUN/TAP");
+        print_tun_backend_driver(c->c1.tuntap->backend_driver));
 
     if (c->c1.tuntap)
     {
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 770e806..206ddc0 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -6678,7 +6678,6 @@ 
      * GUID using the registry */
     tt->actual_name = string_alloc((const char *)actual_buffer, NULL);
 
-    msg(M_INFO, "%s device [%s] opened", print_tun_backend_driver(tt->backend_driver), tt->actual_name);
     tt->adapter_index = get_adapter_index(*device_guid);
 }
 
diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h
index b2c1b01..329cd10 100644
--- a/src/openvpn/tun.h
+++ b/src/openvpn/tun.h
@@ -361,6 +361,12 @@ 
 
 void warn_on_use_of_common_subnets(openvpn_net_ctx_t *ctx);
 
+/**
+ * Return a string representation of the tun backed driver type
+ */
+const char *
+print_tun_backend_driver(enum tun_driver_type driver);
+
 /*
  * Should ifconfig be called before or after
  * tun dev open?
@@ -689,9 +695,6 @@ 
     return tuntap_is_dco_win(tt) && (status < 0) && (openvpn_errno() == ERROR_NETNAME_DELETED);
 }
 
-const char *
-print_tun_backend_driver(enum tun_driver_type driver);
-
 #else  /* ifdef _WIN32 */
 
 static inline bool