Skip to content

Commit 906ad30

Browse files
committed
openvpn: T7056: Raise error if non-TAP device is bridged
1 parent 5b4a665 commit 906ad30

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

smoketest/scripts/cli/test_interfaces_openvpn.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,6 @@ def test_openvpn_server_server_bridge(self):
826826
gw_subnet = "192.168.0.1"
827827

828828
self.cli_set(['interfaces', 'bridge', br_if, 'member', 'interface', vtun_if])
829-
self.cli_set(path + ['device-type', 'tap'])
830829
self.cli_set(path + ['encryption', 'data-ciphers', 'aes192'])
831830
self.cli_set(path + ['hash', auth_hash])
832831
self.cli_set(path + ['mode', 'server'])
@@ -840,6 +839,10 @@ def test_openvpn_server_server_bridge(self):
840839
self.cli_set(path + ['tls', 'certificate', 'ovpn_test'])
841840
self.cli_set(path + ['tls', 'dh-params', 'ovpn_test'])
842841

842+
with self.assertRaises(ConfigSessionError):
843+
self.cli_commit()
844+
845+
self.cli_set(path + ['device-type', 'tap'])
843846
self.cli_commit()
844847

845848
config_file = f'/run/openvpn/{vtun_if}.conf'

src/conf_mode/interfaces_bridge.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ def get_config(config=None):
111111
elif interface.startswith('wlan') and interface_exists(interface):
112112
set_dependents('wlan', conf, interface)
113113

114+
if interface.startswith('vtun'):
115+
_, tmp_config = get_interface_dict(conf, ['interfaces', 'openvpn'], interface)
116+
tmp = tmp_config.get('device_type') == 'tap'
117+
bridge['member']['interface'][interface].update({'valid_ovpn' : tmp})
118+
114119
# delete empty dictionary keys - no need to run code paths if nothing is there to do
115120
if 'member' in bridge:
116121
if 'interface' in bridge['member'] and len(bridge['member']['interface']) == 0:
@@ -178,6 +183,9 @@ def verify(bridge):
178183
if option in interface_config:
179184
raise ConfigError('Can not use VLAN options on non VLAN aware bridge')
180185

186+
if interface.startswith('vtun') and not interface_config['valid_ovpn']:
187+
raise ConfigError(error_msg + 'OpenVPN device-type must be set to "tap"')
188+
181189
if 'enable_vlan' in bridge:
182190
if dict_search('vif.1', bridge):
183191
raise ConfigError(f'VLAN 1 sub interface cannot be set for VLAN aware bridge {ifname}, and VLAN 1 is always the parent interface')

0 commit comments

Comments
 (0)