diff --git a/data/templates/frr/pimd.frr.j2 b/data/templates/frr/pimd.frr.j2 index cb2f2aa98a..7e54fb87b4 100644 --- a/data/templates/frr/pimd.frr.j2 +++ b/data/templates/frr/pimd.frr.j2 @@ -12,14 +12,17 @@ interface {{ iface }} no ip pim ! {% endfor %} -{% for iface in pim.ifaces %} -interface {{ iface }} +{% for interface, interface_config in pim.ifaces.items() %} +interface {{ interface }} ip pim -{% if pim.ifaces[iface].dr_prio %} -ip pim drpriority {{ pim.ifaces[iface].dr_prio }} +{% if interface_config.dr_prio %} +ip pim drpriority {{ interface_config.dr_prio }} +{% endif %} +{% if interface_config.hello %} +ip pim hello {{ interface_config.hello }} {% endif %} -{% if pim.ifaces[iface].hello %} -ip pim hello {{ pim.ifaces[iface].hello }} +{% if interface_config.bfd is vyos_defined('enable') %} +ip pim bfd {% endif %} ! {% endfor %} diff --git a/interface-definitions/protocols-pim.xml.in b/interface-definitions/protocols-pim.xml.in index e9475930c3..d8186db49b 100644 --- a/interface-definitions/protocols-pim.xml.in +++ b/interface-definitions/protocols-pim.xml.in @@ -41,6 +41,25 @@ + + + BFD support + + enable disable + + + enable + BFD enable + + + disable + BFD disable + + + (enable|disable) + + + diff --git a/smoketest/scripts/cli/test_protocols_pim.py b/smoketest/scripts/cli/test_protocols_pim.py new file mode 100755 index 0000000000..20d4ddb71d --- /dev/null +++ b/smoketest/scripts/cli/test_protocols_pim.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2019-2020 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 . + +import os +import unittest + +from base_vyostest_shim import VyOSUnitTestSHIM +from vyos.configsession import ConfigSessionError +from vyos.ifconfig import Section +from vyos.utils.process import process_named_running + +PROCESS_NAME = 'pimd' +base_path = ['protocols', 'pim'] + +class TestProtocolsPIM(VyOSUnitTestSHIM.TestCase): + def tearDown(self): + # Check for running process + self.assertTrue(process_named_running(PROCESS_NAME)) + self.cli_delete(base_path) + self.cli_commit() + + def test_pim_01_simple(self): + rp = '127.0.0.1' + group = '224.0.0.0/4' + hello = '100' + # commit changes + + self.cli_set(base_path + ['rp', 'address', rp, 'group', group]) + interfaces = Section.interfaces('ethernet') + + for interface in interfaces: + self.cli_set(base_path + ['interface', interface]) + self.cli_set(base_path + ['interface', interface , 'hello', hello]) + self.cli_set(base_path + ['interface', interface , 'bfd', 'enable']) + + self.cli_commit() + + + # Verify FRR pimd configuration + frrconfig = self.getFRRconfig('ip pim rp {rp} {group}', daemon=PROCESS_NAME) + + for interface in interfaces: + frrconfig = self.getFRRconfig( + f'interface {interface}', daemon=PROCESS_NAME) + self.assertIn(f'interface {interface}', frrconfig) + self.assertIn(f' ip pim', frrconfig) + self.assertIn(f' ip pim bfd', frrconfig) + self.assertIn(f' ip pim hello {hello}', frrconfig) + + self.cli_commit() + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/src/conf_mode/protocols_pim.py b/src/conf_mode/protocols_pim.py index 0aaa0d2c6f..2873ac86b3 100755 --- a/src/conf_mode/protocols_pim.py +++ b/src/conf_mode/protocols_pim.py @@ -70,14 +70,16 @@ def get_config(config=None): for iface in conf.list_effective_nodes('interface'): pim_conf['old_pim']['ifaces'].update({ iface : { + 'bfd' : conf.return_effective_value('interface {0} bfd'.format(iface)), 'hello' : conf.return_effective_value('interface {0} hello'.format(iface)), - 'dr_prio' : conf.return_effective_value('interface {0} dr-priority'.format(iface)) + 'dr_prio' : conf.return_effective_value('interface {0} dr-priority'.format(iface)), } }) for iface in conf.list_nodes('interface'): pim_conf['pim']['ifaces'].update({ iface : { + 'bfd' : conf.return_value('interface {0} bfd'.format(iface)), 'hello' : conf.return_value('interface {0} hello'.format(iface)), 'dr_prio' : conf.return_value('interface {0} dr-priority'.format(iface)), }