Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wireguard: T7166: Call vxlan dependency if interface exist #4369

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading