Make error non-fatal while deleting address using netsh

During windows power events such as sleep or suspend, the TUN/TAP
I/O aborts and openvpn signals SIGHUP so as to automatically reconnect
on resume (since commit ea66a2b5cdb2..). During the SIGHUP processing
operations such as address and route deletion are expected to fail. Such
failures should be treated as non-fatal to allow for this automatic
recovery logic to work. Currently, when the address deletion is handled
by netsh, errors are treated as M_FATAL. This patch changes the error
level to M_WARN.

Resolves Trac #71 (comments 37 to 43)

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1463185884-4355-2-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11656
Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
Selva Nair 2016-05-13 20:31:24 -04:00 committed by Gert Doering
parent e7ec6a3a11
commit e3420d5683

View file

@ -68,7 +68,7 @@ static void netsh_ifconfig (const struct tuntap_options *to,
const in_addr_t ip,
const in_addr_t netmask,
const unsigned int flags);
static void netsh_command (const struct argv *a, int n);
static void netsh_command (const struct argv *a, int n, int msglevel);
static const char *netsh_get_id (const char *dev_node, struct gc_arena *gc);
@ -1398,7 +1398,7 @@ do_ifconfig (struct tuntap *tt,
NETSH_PATH_SUFFIX,
iface,
ifconfig_ipv6_local );
netsh_command (&argv, 4);
netsh_command (&argv, 4, M_FATAL);
}
/* explicit route needed */
@ -4597,7 +4597,7 @@ dhcp_renew (const struct tuntap *tt)
*/
static void
netsh_command (const struct argv *a, int n)
netsh_command (const struct argv *a, int n, int msglevel)
{
int i;
for (i = 0; i < n; ++i)
@ -4612,7 +4612,7 @@ netsh_command (const struct argv *a, int n)
return;
openvpn_sleep (4);
}
msg (M_FATAL, "NETSH: command failed");
msg (msglevel, "NETSH: command failed");
}
void
@ -4762,7 +4762,7 @@ netsh_ifconfig_options (const char *type,
NETSH_PATH_SUFFIX,
type,
flex_name);
netsh_command (&argv, 2);
netsh_command (&argv, 2, M_FATAL);
}
/* add new DNS/WINS settings to TAP interface */
@ -4783,7 +4783,7 @@ netsh_ifconfig_options (const char *type,
type,
flex_name,
print_in_addr_t (addr_list[i], 0, &gc));
netsh_command (&argv, 2);
netsh_command (&argv, 2, M_FATAL);
++count;
}
@ -4858,7 +4858,7 @@ netsh_ifconfig (const struct tuntap_options *to,
print_in_addr_t (ip, 0, &gc),
print_in_addr_t (netmask, 0, &gc));
netsh_command (&argv, 4);
netsh_command (&argv, 4, M_FATAL);
}
}
@ -4904,7 +4904,7 @@ netsh_enable_dhcp (const struct tuntap_options *to,
NETSH_PATH_SUFFIX,
actual_name);
netsh_command (&argv, 4);
netsh_command (&argv, 4, M_FATAL);
argv_reset (&argv);
}
@ -5648,7 +5648,7 @@ close_tun (struct tuntap *tt)
tt->actual_name,
ifconfig_ipv6_local);
netsh_command (&argv, 1);
netsh_command (&argv, 1, M_WARN);
argv_reset (&argv);
}
}