]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Make error non-fatal while deleting address using netsh
authorSelva Nair <selva.nair@gmail.com>
Sat, 14 May 2016 00:31:23 +0000 (20:31 -0400)
committerGert Doering <gert@greenie.muc.de>
Mon, 16 May 2016 11:40:20 +0000 (13:40 +0200)
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-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11655
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/tun.c

index b70410d20dfff0eb8a7441326c03069bd327bafb..11027ddc38140539084f18e820d4f0805f149292 100644 (file)
@@ -62,7 +62,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);
 
@@ -1246,7 +1246,7 @@ do_ifconfig (struct tuntap *tt,
                     NETSH_PATH_SUFFIX,
                     win32_version_info() == WIN_XP ? actual : iface,
                     ifconfig_ipv6_local);
-       netsh_command (&argv, 4);
+       netsh_command (&argv, 4, M_FATAL);
 
        /* explicit route needed */
        /* on windows, OpenVPN does ifconfig first, open_tun later, so
@@ -4246,7 +4246,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)
@@ -4261,7 +4261,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
@@ -4411,7 +4411,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 */
@@ -4432,7 +4432,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;
          }
@@ -4507,7 +4507,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);
        }
     }
 
@@ -4553,7 +4553,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);
 }
@@ -5269,7 +5269,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);
        }
 #if 1