Skip to content

Commit 22af5b3

Browse files
authored
Merge pull request #4369 from natali-rs1985/T7166
wireguard: T7166: Call vxlan dependency if interface exist
2 parents 467d4d6 + 19dc099 commit 22af5b3

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

data/config-mode-dependencies/vyos-1x.json

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"vxlan": ["interfaces_vxlan"],
1515
"wlan": ["interfaces_wireless"]
1616
},
17+
"interfaces_wireguard": {
18+
"vxlan": ["interfaces_vxlan"]
19+
},
1720
"load_balancing_wan": {
1821
"conntrack": ["system_conntrack"]
1922
},

src/conf_mode/interfaces_wireguard.py

+23
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
from vyos.config import Config
2020
from vyos.configdict import get_interface_dict
2121
from vyos.configdict import is_node_changed
22+
from vyos.configdict import is_source_interface
23+
from vyos.configdep import set_dependents
24+
from vyos.configdep import call_dependents
2225
from vyos.configverify import verify_vrf
2326
from vyos.configverify import verify_address
2427
from vyos.configverify import verify_bridge_delete
@@ -35,6 +38,7 @@
3538
from pathlib import Path
3639
airbag.enable()
3740

41+
3842
def get_config(config=None):
3943
"""
4044
Retrive CLI config as dictionary. Dictionary can never be empty, as at least the
@@ -61,11 +65,25 @@ def get_config(config=None):
6165
if 'disable' not in peer_config and 'host_name' in peer_config:
6266
wireguard['peers_need_resolve'].append(peer)
6367

68+
# Check if interface is used as source-interface on VXLAN interface
69+
tmp = is_source_interface(conf, ifname, 'vxlan')
70+
if tmp:
71+
if 'deleted' not in wireguard:
72+
set_dependents('vxlan', conf, tmp)
73+
else:
74+
wireguard['is_source_interface'] = tmp
75+
6476
return wireguard
6577

78+
6679
def verify(wireguard):
6780
if 'deleted' in wireguard:
6881
verify_bridge_delete(wireguard)
82+
if 'is_source_interface' in wireguard:
83+
raise ConfigError(
84+
f'Interface "{wireguard["ifname"]}" cannot be deleted as it is used '
85+
f'as source interface for "{wireguard["is_source_interface"]}"!'
86+
)
6987
return None
7088

7189
verify_mtu_ipv6(wireguard)
@@ -119,9 +137,11 @@ def verify(wireguard):
119137

120138
public_keys.append(peer['public_key'])
121139

140+
122141
def generate(wireguard):
123142
return None
124143

144+
125145
def apply(wireguard):
126146
check_kmod('wireguard')
127147

@@ -157,8 +177,11 @@ def apply(wireguard):
157177
domain_action = 'stop'
158178
call(f'systemctl {domain_action} vyos-domain-resolver.service')
159179

180+
call_dependents()
181+
160182
return None
161183

184+
162185
if __name__ == '__main__':
163186
try:
164187
c = get_config()

0 commit comments

Comments
 (0)