diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/protocols_static.py | 9 | ||||
-rwxr-xr-x | src/conf_mode/qos.py | 3 | ||||
-rwxr-xr-x | src/conf_mode/system-option.py | 17 | ||||
-rwxr-xr-x | src/migration-scripts/qos/1-to-2 | 42 |
4 files changed, 32 insertions, 39 deletions
diff --git a/src/conf_mode/protocols_static.py b/src/conf_mode/protocols_static.py index 58e202928..cbbc476a7 100755 --- a/src/conf_mode/protocols_static.py +++ b/src/conf_mode/protocols_static.py @@ -98,6 +98,15 @@ def generate(static): return None def apply(static): + ## Put routing table names in /etc/iproute2/rt_tables + with open("/etc/iproute2/rt_tables.d/vyos.conf", 'w') as f: + print("# Generated by VyOS (protocols_static.py), do not edit by hand", file=f) + for t in static['table']: + if 'description' in static['table'][t]: + print(f"{t}\t{static['table'][t]['description']}", file=f) + + ## Inject routes into FRR + static_daemon = 'staticd' zebra_daemon = 'zebra' diff --git a/src/conf_mode/qos.py b/src/conf_mode/qos.py index 2eb03237c..1fe3b6aa9 100755 --- a/src/conf_mode/qos.py +++ b/src/conf_mode/qos.py @@ -187,6 +187,9 @@ def verify(qos): if queue_lim < max_tr: raise ConfigError(f'Policy "{policy}" uses queue-limit "{queue_lim}" < max-threshold "{max_tr}"!') + if 'default' in policy_config: + if 'bandwidth' not in policy_config['default']: + raise ConfigError('Bandwidth not defined for default traffic!') # we should check interface ingress/egress configuration after verifying that # the policy name is used only once - this makes the logic easier! diff --git a/src/conf_mode/system-option.py b/src/conf_mode/system-option.py index 36dbf155b..e6c7a0ed2 100755 --- a/src/conf_mode/system-option.py +++ b/src/conf_mode/system-option.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2019-2020 VyOS maintainers and contributors +# Copyright (C) 2019-2022 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -22,17 +22,19 @@ from time import sleep from vyos.config import Config from vyos.configdict import dict_merge +from vyos.configverify import verify_source_interface from vyos.template import render from vyos.util import cmd from vyos.util import is_systemd_service_running from vyos.validate import is_addr_assigned +from vyos.validate import is_intf_addr_assigned from vyos.xml import defaults from vyos import ConfigError from vyos import airbag airbag.enable() curlrc_config = r'/etc/curlrc' -ssh_config = r'/etc/ssh/ssh_config' +ssh_config = r'/etc/ssh/ssh_config.d/91-vyos-ssh-client-options.conf' systemd_action_file = '/lib/systemd/system/ctrl-alt-del.target' def get_config(config=None): @@ -68,8 +70,17 @@ def verify(options): if 'ssh_client' in options: config = options['ssh_client'] if 'source_address' in config: + address = config['source_address'] if not is_addr_assigned(config['source_address']): - raise ConfigError('No interface with give address specified!') + raise ConfigError('No interface with address "{address}" configured!') + + if 'source_interface' in config: + verify_source_interface(config) + if 'source_address' in config: + address = config['source_address'] + interface = config['source_interface'] + if not is_intf_addr_assigned(interface, address): + raise ConfigError(f'Address "{address}" not assigned on interface "{interface}"!') return None diff --git a/src/migration-scripts/qos/1-to-2 b/src/migration-scripts/qos/1-to-2 index 6f4c08a50..41026cbd6 100755 --- a/src/migration-scripts/qos/1-to-2 +++ b/src/migration-scripts/qos/1-to-2 @@ -98,49 +98,19 @@ config.set(['qos']) config.copy(base, ['qos', 'policy']) config.delete(base) -# TODO -# - remove burst from network emulator - -def change_cli_bandwidth(config, path): - if config.exists(path + ['bandwidth']): - bw = config.return_value(path + ['bandwidth']) - if bw.endswith('%'): - bw = bandwidth_percent_to_val(interface, bw.rstrip('%')) - config.set(path + ['bandwidth'], value=bw) - return - # Now map the interface policy binding to the new CLI syntax +if len(iface_config): + config.set(['qos', 'interface']) + config.set_tag(['qos', 'interface']) + for interface, interface_config in iface_config.items(): + config.set(['qos', 'interface', interface]) + config.set_tag(['qos', 'interface', interface]) if 'ingress' in interface_config: config.set(['qos', 'interface', interface, 'ingress'], value=interface_config['ingress']) if 'egress' in interface_config: config.set(['qos', 'interface', interface, 'egress'], value=interface_config['egress']) - # QoS policy <-> interface binding is now established - we now can adjust some - # CLI values like bandwidth in percent - for direction in ['ingress', 'egress']: - if direction not in interface_config: - continue - # Convert % bandwidth values to absolute values - for policy in config.list_nodes(['qos', 'policy']): - for policy_name in config.list_nodes(['qos', 'policy', policy]): - if policy_name == interface_config[direction]: - policy_base = ['qos', 'policy', policy, policy_name] - # This is for the toplevel bandwidth node on a policy - change_cli_bandwidth(config, policy_base) - - # This is for class based bandwidth value - if config.exists(policy_base + ['class']): - for cls in config.list_nodes(policy_base + ['class']): - cls_base = policy_base + ['class', cls] - change_cli_bandwidth(config, cls_base) - - # This is for the bandwidth value specified under the - # policy "default" tree - if config.exists(policy_base + ['default']): - default_base = policy_base + ['default'] - change_cli_bandwidth(config, default_base) - # Remove "burst" CLI node from network emulator netem_base = ['qos', 'policy', 'network-emulator'] if config.exists(netem_base): |