Skip to content

Commit

Permalink
Merge pull request #4369 from natali-rs1985/T7166
Browse files Browse the repository at this point in the history
wireguard: T7166: Call vxlan dependency if interface exist
  • Loading branch information
dmbaturin authored Feb 27, 2025
2 parents 467d4d6 + 19dc099 commit 22af5b3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions data/config-mode-dependencies/vyos-1x.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"vxlan": ["interfaces_vxlan"],
"wlan": ["interfaces_wireless"]
},
"interfaces_wireguard": {
"vxlan": ["interfaces_vxlan"]
},
"load_balancing_wan": {
"conntrack": ["system_conntrack"]
},
Expand Down
23 changes: 23 additions & 0 deletions src/conf_mode/interfaces_wireguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from vyos.config import Config
from vyos.configdict import get_interface_dict
from vyos.configdict import is_node_changed
from vyos.configdict import is_source_interface
from vyos.configdep import set_dependents
from vyos.configdep import call_dependents
from vyos.configverify import verify_vrf
from vyos.configverify import verify_address
from vyos.configverify import verify_bridge_delete
Expand All @@ -35,6 +38,7 @@
from pathlib import Path
airbag.enable()


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

# Check if interface is used as source-interface on VXLAN interface
tmp = is_source_interface(conf, ifname, 'vxlan')
if tmp:
if 'deleted' not in wireguard:
set_dependents('vxlan', conf, tmp)
else:
wireguard['is_source_interface'] = tmp

return wireguard


def verify(wireguard):
if 'deleted' in wireguard:
verify_bridge_delete(wireguard)
if 'is_source_interface' in wireguard:
raise ConfigError(
f'Interface "{wireguard["ifname"]}" cannot be deleted as it is used '
f'as source interface for "{wireguard["is_source_interface"]}"!'
)
return None

verify_mtu_ipv6(wireguard)
Expand Down Expand Up @@ -119,9 +137,11 @@ def verify(wireguard):

public_keys.append(peer['public_key'])


def generate(wireguard):
return None


def apply(wireguard):
check_kmod('wireguard')

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

call_dependents()

return None


if __name__ == '__main__':
try:
c = get_config()
Expand Down

0 comments on commit 22af5b3

Please sign in to comment.