]> git.ipfire.org Git - thirdparty/openvpn.git/commit
Don't "undo" ifconfig on exit if it wasn't done
authorMax Fillinger <maximilian.fillinger@foxcrypto.com>
Wed, 10 Aug 2022 15:30:06 +0000 (17:30 +0200)
committerGert Doering <gert@greenie.muc.de>
Fri, 19 Aug 2022 14:09:29 +0000 (16:09 +0200)
commit0c4d40cb838eb0fad4a82bbed1198f6d359d445a
treeb6e2c8c3a89a70ff43272f4bcc33c5e3867e0482
parentddbe6a6fc26586d09f5a9105f13124c479b4d993
Don't "undo" ifconfig on exit if it wasn't done

When running with --ifconfig-noexec, OpenVPN does not execute ifconfig,
but on exit, it still tries to "undo" the configuration it would have
done. This patch fixes it by extracting an undo_ifconfig() function from
close_tun(). The undo function is called before close_tun(), but only if
--ifconfig-noexec isn't set. This is symmetric to how open_tun() and
do_ifconfig() are used.

v2: Fix tabs-vs-spaces.
v3: Fix another style mistake.
v4: Move undo_ifconfig{4,6}() out of #ifdef TARGET_LINUX.
v5: Keep ctx argument in close_tun().
v6: Fix bug in non-Linux non-Windows version of undo_ifconfig_ipv6

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220810153006.18860-1-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24860.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/init.c
src/openvpn/tun.c
src/openvpn/tun.h