close_tun: print interface type consistently in message
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
@@ -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
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.
Signed-off-by Antonio Quartulli <[email protected]...>--- src/openvpn/init.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)src/openvpn/init.c +0
-0@@ -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]...PATCH v2 1/1 close_tun: print interface type consistently in message
In reply to Antonio QuartulliWhen 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
@@ -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
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