diff options
author | DmitriyEshenko <dmitriy.eshenko@vyos.io> | 2020-04-04 20:51:22 +0000 |
---|---|---|
committer | DmitriyEshenko <dmitriy.eshenko@vyos.io> | 2020-04-04 20:51:22 +0000 |
commit | fbdfd7a2f03205d69ebe53e927f378850f832a20 (patch) | |
tree | c4aa9302e628a4381c5e3021a8d2aa993133b542 | |
parent | 3e7fe69a6b03b053098171411e286ba515838842 (diff) | |
download | vyos-1x-fbdfd7a2f03205d69ebe53e927f378850f832a20.tar.gz vyos-1x-fbdfd7a2f03205d69ebe53e927f378850f832a20.zip |
pim: T1729: Add dr-priority and IGMP join support
-rw-r--r-- | interface-definitions/protocols-igmp.xml.in | 27 | ||||
-rw-r--r-- | interface-definitions/protocols-pim.xml.in | 12 | ||||
-rwxr-xr-x | src/conf_mode/protocols_igmp.py | 34 | ||||
-rwxr-xr-x | src/conf_mode/protocols_pim.py | 11 |
4 files changed, 79 insertions, 5 deletions
diff --git a/interface-definitions/protocols-igmp.xml.in b/interface-definitions/protocols-igmp.xml.in index a6a2f1420..a9b11e1a3 100644 --- a/interface-definitions/protocols-igmp.xml.in +++ b/interface-definitions/protocols-igmp.xml.in @@ -16,6 +16,33 @@ </completionHelp> </properties> <children> + <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> + <leafNode name="source"> + <properties> + <help>Source address</help> + <valueHelp> + <format>ipv4</format> + <description>Source address</description> + </valueHelp> + <constraint> + <validator name="ipv4-address"/> + </constraint> + <multi/> + </properties> + </leafNode> + </children> + </tagNode> <leafNode name="version"> <properties> <help>IGMP version</help> diff --git a/interface-definitions/protocols-pim.xml.in b/interface-definitions/protocols-pim.xml.in index 944224f7b..6152045a7 100644 --- a/interface-definitions/protocols-pim.xml.in +++ b/interface-definitions/protocols-pim.xml.in @@ -17,6 +17,18 @@ </completionHelp> </properties> <children> + <leafNode name="dr-priority"> + <properties> + <help>Designated Router Election Priority</help> + <valueHelp> + <format>1-4294967295</format> + <description>Value of the new DR Priority</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 1-4294967295"/> + </constraint> + </properties> + </leafNode> <leafNode name="hello"> <properties> <help>Hello Interval</help> diff --git a/src/conf_mode/protocols_igmp.py b/src/conf_mode/protocols_igmp.py index 8d25fe9d5..dcbd9a0a8 100755 --- a/src/conf_mode/protocols_igmp.py +++ b/src/conf_mode/protocols_igmp.py @@ -23,6 +23,7 @@ import vyos.validate from vyos import ConfigError from vyos.config import Config +from ipaddress import IPv4Address config_file = r'/tmp/igmp.frr' @@ -31,6 +32,15 @@ config_tmpl = """ ! {% for iface in old_ifaces -%} interface {{ iface }} +{% for group in old_ifaces[iface].gr_join -%} +{% if old_ifaces[iface].gr_join[group] -%} +{% for source in old_ifaces[iface].gr_join[group] -%} +no ip igmp join {{ group }} {{ source }} +{% endfor -%} +{% else -%} +no ip igmp join {{ group }} +{% endif -%} +{% endfor -%} no ip igmp ! {% endfor -%} @@ -48,6 +58,15 @@ ip igmp query-interval {{ ifaces[iface].query_interval }} {% if ifaces[iface].query_max_resp_time -%} ip igmp query-max-response-time {{ ifaces[iface].query_max_resp_time }} {% endif -%} +{% for group in ifaces[iface].gr_join -%} +{% if ifaces[iface].gr_join[group] -%} +{% for source in ifaces[iface].gr_join[group] -%} +ip igmp join {{ group }} {{ source }} +{% endfor -%} +{% else -%} +ip igmp join {{ group }} +{% endif -%} +{% endfor -%} ! {% endfor -%} ! @@ -74,18 +93,24 @@ def get_config(): iface : { 'version' : conf.return_effective_value('interface {0} version'.format(iface)), 'query_interval' : conf.return_effective_value('interface {0} query-interval'.format(iface)), - 'query_max_resp_time' : conf.return_effective_value('interface {0} query-max-response-time'.format(iface)) + 'query_max_resp_time' : conf.return_effective_value('interface {0} query-max-response-time'.format(iface)), + 'gr_join' : {} } }) + for gr_join in conf.list_effective_nodes('interface {0} join'.format(iface)): + igmp_conf['old_ifaces'][iface]['gr_join'][gr_join] = conf.return_effective_values('interface {0} join {1} source'.format(iface, gr_join)) for iface in conf.list_nodes('interface'): igmp_conf['ifaces'].update({ iface : { 'version' : conf.return_value('interface {0} version'.format(iface)), 'query_interval' : conf.return_value('interface {0} query-interval'.format(iface)), - 'query_max_resp_time' : conf.return_value('interface {0} query-max-response-time'.format(iface)) + 'query_max_resp_time' : conf.return_value('interface {0} query-max-response-time'.format(iface)), + 'gr_join' : {} } }) + for gr_join in conf.list_nodes('interface {0} join'.format(iface)): + igmp_conf['ifaces'][iface]['gr_join'][gr_join] = conf.return_values('interface {0} join {1} source'.format(iface, gr_join)) return igmp_conf @@ -97,6 +122,11 @@ def verify(igmp): # Check interfaces if not igmp['ifaces']: raise ConfigError(f"IGMP require defined interfaces!") + # Check, is this multicast group + for intfc in igmp['ifaces']: + for gr_addr in igmp['ifaces'][intfc]['gr_join']: + if IPv4Address(gr_addr) < IPv4Address('224.0.0.0'): + raise ConfigError(gr_addr + " not a multicast group") def generate(igmp): if igmp is None: diff --git a/src/conf_mode/protocols_pim.py b/src/conf_mode/protocols_pim.py index dc65a59a6..f4c365923 100755 --- a/src/conf_mode/protocols_pim.py +++ b/src/conf_mode/protocols_pim.py @@ -45,10 +45,13 @@ no ip pim {% endfor -%} {% for iface in pim.ifaces -%} interface {{ iface }} +ip pim +{% if pim.ifaces[iface].dr_prio -%} +ip pim drpriority {{ pim.ifaces[iface].dr_prio }} +{% endif -%} {% if pim.ifaces[iface].hello -%} ip pim hello {{ pim.ifaces[iface].hello }} {% endif -%} -ip pim ! {% endfor -%} {% for rp_addr in pim.rp -%} @@ -87,14 +90,16 @@ def get_config(): for iface in conf.list_effective_nodes('interface'): pim_conf['old_pim']['ifaces'].update({ iface : { - 'hello' : conf.return_effective_value('interface {0} hello'.format(iface)) + 'hello' : conf.return_effective_value('interface {0} hello'.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 : { - 'hello' : conf.return_value('interface {0} hello'.format(iface)) + 'hello' : conf.return_value('interface {0} hello'.format(iface)), + 'dr_prio' : conf.return_value('interface {0} dr-priority'.format(iface)), } }) |