From 029f9839c21317ec5959b331eee25da472d08dc1 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 18 Oct 2020 18:04:34 +0200
Subject: openvpn: T2969: force creation of tunnel interfaces

A lot of VyOS code requires the Kernel interface to be present in order to
properly work and adjust the interface to the users CLI intends (alias, ipv6,
vrf - just to name a few).

OpenVPN - when run in client mode - only creates the interface (e.g. vtun1) when
the connection to the OpenVPN server was successful. This can't be always the
case due to e.g. software-updates or routing issues to the remote side. This
will in the end result in a zombie OpenVPN client interface where some config
items might not have been set when the interface finally comes up - imagine a
wrong assigned VRF instance.

By always creating the OpenVPN interface manuall we ensure that all the CLI
settings are properly configured in the OS kernel.
---
 smoketest/scripts/cli/test_interfaces_openvpn.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'smoketest')

diff --git a/smoketest/scripts/cli/test_interfaces_openvpn.py b/smoketest/scripts/cli/test_interfaces_openvpn.py
index 0ac91c170..2af07a579 100755
--- a/smoketest/scripts/cli/test_interfaces_openvpn.py
+++ b/smoketest/scripts/cli/test_interfaces_openvpn.py
@@ -17,6 +17,8 @@
 import os
 import unittest
 
+from netifaces import interfaces
+
 from vyos.configsession import ConfigSession
 from vyos.configsession import ConfigSessionError
 from vyos.util import cmd
@@ -72,8 +74,8 @@ class TestInterfacesOpenVPN(unittest.TestCase):
         self.assertIn(f'remote {remote_host}', config)
         self.assertIn('persist-tun', config)
 
-
         self.assertTrue(process_named_running(PROCESS_NAME))
+        self.assertIn(interface, interfaces())
 
 if __name__ == '__main__':
     # Our SSL certificates need a subject ...
-- 
cgit v1.2.3