diff --git a/interface-definitions/include/pim/dr-priority.xml.i b/interface-definitions/include/pim/dr-priority.xml.i index bfda4e257..e4b3067c2 100644 --- a/interface-definitions/include/pim/dr-priority.xml.i +++ b/interface-definitions/include/pim/dr-priority.xml.i @@ -1,14 +1,14 @@ <!-- include start from pim/dr-priority.xml.i --> <leafNode name="dr-priority"> <properties> - <help>Designated Router Election Priority</help> + <help>Designated router election priority</help> <valueHelp> <format>u32:1-4294967295</format> - <description>Value of the new DR Priority</description> + <description>DR Priority</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-4294967295"/> </constraint> </properties> </leafNode> <!-- include end --> diff --git a/interface-definitions/include/pim/join-prune-interval.xml.i b/interface-definitions/include/pim/join-prune-interval.xml.i index f7519ad67..882787d3f 100644 --- a/interface-definitions/include/pim/join-prune-interval.xml.i +++ b/interface-definitions/include/pim/join-prune-interval.xml.i @@ -1,15 +1,15 @@ <!-- include start from pim/join-prune-interval.xml.i --> <leafNode name="join-prune-interval"> <properties> - <help>Join Prune Send Interval</help> + <help>Join prune send interval</help> <valueHelp> <format>u32:1-65535</format> <description>Interval in seconds</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-65535"/> </constraint> </properties> <defaultValue>60</defaultValue> </leafNode> <!-- include end --> diff --git a/interface-definitions/include/pim/register-suppress-time.xml.i b/interface-definitions/include/pim/register-suppress-time.xml.i index 80180e9b6..919945b52 100644 --- a/interface-definitions/include/pim/register-suppress-time.xml.i +++ b/interface-definitions/include/pim/register-suppress-time.xml.i @@ -1,14 +1,14 @@ <!-- include start from pim/register-suppress-time.xml.i --> <leafNode name="register-suppress-time"> <properties> - <help>Register Suppress Timer</help> + <help>Register suppress timer</help> <valueHelp> <format>u32:1-65535</format> - <description>In seconds</description> + <description>Timer in seconds</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-65535"/> </constraint> </properties> </leafNode> <!-- include end --> diff --git a/interface-definitions/protocols-pim.xml.in b/interface-definitions/protocols-pim.xml.in index 39188398b..4a20c0d9b 100644 --- a/interface-definitions/protocols-pim.xml.in +++ b/interface-definitions/protocols-pim.xml.in @@ -1,210 +1,210 @@ <?xml version="1.0"?> <!-- Protocol Independent Multicast (PIM) configuration --> <interfaceDefinition> <node name="protocols"> <children> <node name="pim" owner="${vyos_conf_scripts_dir}/protocols_pim.py"> <properties> <help>Protocol Independent Multicast (PIM) and IGMP</help> <priority>400</priority> </properties> <children> <tagNode name="interface"> <properties> <help>PIM interface</help> <completionHelp> <script>${vyos_completion_dir}/list_interfaces</script> </completionHelp> <constraint> #include <include/constraint/interface-name.xml.i> </constraint> </properties> <children> #include <include/bfd/bfd.xml.i> #include <include/pim/bsm.xml.i> #include <include/pim/dr-priority.xml.i> #include <include/pim/hello.xml.i> #include <include/pim/passive.xml.i> #include <include/source-address-ipv4.xml.i> <node name="igmp"> <properties> <help>Internet Group Management Protocol (IGMP) options</help> </properties> <children> #include <include/generic-disable-node.xml.i> <tagNode name="join"> <properties> <help>IGMP join multicast group</help> <valueHelp> <format>ipv4</format> <description>Multicast group address</description> </valueHelp> <constraint> <validator name="ipv4-address"/> </constraint> </properties> <children> #include <include/source-address-ipv4-multi.xml.i> </children> </tagNode> <leafNode name="query-interval"> <properties> <help>IGMP host query interval</help> <valueHelp> <format>u32:1-1800</format> <description>Query interval in seconds</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-1800"/> </constraint> </properties> </leafNode> <leafNode name="query-max-response-time"> <properties> <help>IGMP max query response time</help> <valueHelp> <format>u32:10-250</format> <description>Query response value in deci-seconds</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 10-250"/> </constraint> </properties> </leafNode> <leafNode name="version"> <properties> <help>Interface IGMP version</help> <completionHelp> <list>2 3</list> </completionHelp> <valueHelp> <format>2</format> <description>IGMP version 2</description> </valueHelp> <valueHelp> <format>3</format> <description>IGMP version 3</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 2-3"/> </constraint> </properties> <defaultValue>3</defaultValue> </leafNode> </children> </node> </children> </tagNode> <node name="ecmp"> <properties> <help>Enable PIM ECMP</help> </properties> <children> <leafNode name="rebalance"> <properties> <help>Enable PIM ECMP Rebalance</help> <valueless/> </properties> </leafNode> </children> </node> <node name="igmp"> <properties> <help>Internet Group Management Protocol (IGMP) options</help> </properties> <children> <leafNode name="watermark-warning"> <properties> <help>Configure group limit for watermark warning</help> <valueHelp> <format>u32:1-65535</format> <description>Group count to generate watermark warning</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-65535"/> </constraint> </properties> </leafNode> </children> </node> #include <include/pim/join-prune-interval.xml.i> #include <include/pim/keep-alive-timer.xml.i> #include <include/pim/packets.xml.i> #include <include/pim/register-suppress-time.xml.i> <node name="register-accept-list"> <properties> <help>Only accept registers from a specific source prefix list</help> </properties> <children> #include <include/policy/prefix-list.xml.i> </children> </node> <node name="rp"> <properties> <help>Rendezvous Point</help> </properties> <children> <tagNode name="address"> <properties> <help>Rendezvous Point address</help> <valueHelp> <format>ipv4</format> <description>Rendezvous Point address</description> </valueHelp> <constraint> <validator name="ipv4-address"/> </constraint> </properties> <children> <leafNode name="group"> <properties> <help>Group Address range</help> <valueHelp> <format>ipv4net</format> <description>Group Address range RFC 3171</description> </valueHelp> <constraint> <validator name="ip-prefix"/> </constraint> <multi/> </properties> </leafNode> </children> </tagNode> #include <include/pim/keep-alive-timer.xml.i> </children> </node> <leafNode name="no-v6-secondary"> <properties> <help>Disable IPv6 secondary address in hello packets</help> <valueless/> </properties> </leafNode> <node name="spt-switchover"> <properties> - <help>Send v6 secondary addresses</help> + <help>Shortest-path tree (SPT) switchover</help> </properties> <children> <node name="infinity-and-beyond"> <properties> <help>Never switch to SPT Tree</help> </properties> <children> #include <include/policy/prefix-list.xml.i> </children> </node> </children> </node> <node name="ssm"> <properties> <help>Source-Specific Multicast</help> </properties> <children> #include <include/policy/prefix-list.xml.i> </children> </node> </children> </node> </children> </node> </interfaceDefinition> diff --git a/src/conf_mode/protocols_pim.py b/src/conf_mode/protocols_pim.py index 5e6225f6f..09c3be8df 100755 --- a/src/conf_mode/protocols_pim.py +++ b/src/conf_mode/protocols_pim.py @@ -1,164 +1,162 @@ #!/usr/bin/env python3 # # Copyright (C) 2020-2023 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 # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os from ipaddress import IPv4Network from signal import SIGTERM from sys import exit from vyos.config import Config from vyos.config import config_dict_merge -from vyos.configdict import dict_merge from vyos.configdict import node_changed -from vyos.utils.dict import dict_search from vyos.configverify import verify_interface_exists from vyos.utils.process import process_named_running from vyos.utils.process import call from vyos.template import render_to_string from vyos import ConfigError from vyos import frr from vyos import airbag airbag.enable() def get_config(config=None): if config: conf = config else: conf = Config() base = ['protocols', 'pim'] pim = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True, no_tag_node_value_mangle=True) # We can not run both IGMP proxy and PIM at the same time - get IGMP # proxy status if conf.exists(['protocols', 'igmp-proxy']): pim.update({'igmp_proxy_enabled' : {}}) # FRR has VRF support for different routing daemons. As interfaces belong # to VRFs - or the global VRF, we need to check for changed interfaces so # that they will be properly rendered for the FRR config. Also this eases # removal of interfaces from the running configuration. interfaces_removed = node_changed(conf, base + ['interface']) if interfaces_removed: pim['interface_removed'] = list(interfaces_removed) # Bail out early if configuration tree does no longer exist. this must # be done after retrieving the list of interfaces to be removed. if not conf.exists(base): pim.update({'deleted' : ''}) return pim # We have gathered the dict representation of the CLI, but there are default # options which we need to update into the dictionary retrived. default_values = conf.get_config_defaults(**pim.kwargs, recursive=True) # We have to cleanup the default dict, as default values could enable features # which are not explicitly enabled on the CLI. Example: default-information # originate comes with a default metric-type of 2, which will enable the # entire default-information originate tree, even when not set via CLI so we # need to check this first and probably drop that key. for interface in pim.get('interface', []): # We need to reload the defaults on every pass b/c of # hello-multiplier dependency on dead-interval # If hello-multiplier is set, we need to remove the default from # dead-interval. if 'igmp' not in pim['interface'][interface]: del default_values['interface'][interface]['igmp'] pim = config_dict_merge(default_values, pim) return pim def verify(pim): if not pim or 'deleted' in pim: return None if 'igmp_proxy_enabled' in pim: raise ConfigError('IGMP proxy and PIM cannot be configured at the same time!') if 'interface' not in pim: raise ConfigError('PIM require defined interfaces!') for interface in pim['interface']: verify_interface_exists(interface) if 'rp' in pim: if 'address' not in pim['rp']: raise ConfigError('PIM rendezvous point needs to be defined!') # Check unique multicast groups unique = [] pim_base_error = 'PIM rendezvous point group' for address, address_config in pim['rp']['address'].items(): if 'group' not in address_config: raise ConfigError(f'{pim_base_error} should be defined for "{address}"!') # Check if it is a multicast group for gr_addr in address_config['group']: if not IPv4Network(gr_addr).is_multicast: raise ConfigError(f'{pim_base_error} "{gr_addr}" is not a multicast group!') if gr_addr in unique: raise ConfigError(f'{pim_base_error} must be unique!') unique.append(gr_addr) def generate(pim): if not pim or 'deleted' in pim: return None pim['frr_pimd_config'] = render_to_string('frr/pimd.frr.j2', pim) return None def apply(pim): pim_daemon = 'pimd' pim_pid = process_named_running(pim_daemon) if not pim or 'deleted' in pim: if 'deleted' in pim: os.kill(int(pim_pid), SIGTERM) return None if not pim_pid: call('/usr/lib/frr/pimd -d -F traditional --daemon -A 127.0.0.1') # Save original configuration prior to starting any commit actions frr_cfg = frr.FRRConfig() frr_cfg.load_configuration(pim_daemon) frr_cfg.modify_section(f'^ip pim') frr_cfg.modify_section(f'^ip igmp') for key in ['interface', 'interface_removed']: if key not in pim: continue for interface in pim[key]: frr_cfg.modify_section(f'^interface {interface}', stop_pattern='^exit', remove_stop_mark=True) if 'frr_pimd_config' in pim: frr_cfg.add_before(frr.default_add_before, pim['frr_pimd_config']) frr_cfg.commit_configuration(pim_daemon) return None if __name__ == '__main__': try: c = get_config() verify(c) generate(c) apply(c) except ConfigError as e: print(e) exit(1)