From 2e498164218851f1b958c43a7b903849a80b8304 Mon Sep 17 00:00:00 2001 From: Cheeze-It Date: Wed, 11 Nov 2020 13:27:51 -0700 Subject: mpls-conf: T915: Add MPLS misc parameters, add LDP misc parameters This commit has to do with the addition of miscellaneous MPLS parameters, as well as miscellaneous LDP parameters. Per c-po, for miscellaneous options and whatnot that do not fit anywhere we will put them into a specific "parameters" node. I also did some global linux configuration changes here. We make changes to kernel options "net.mpls.ip_ttl_propagate" and "net.mpls.default_ttl" which should allow the behavior of VyOS to have the same as routers from the big vendors. I added two LDP options for cisco interoperation TLV and for a dual stack preference. Lastly, I went through and changes some of the help/description fields in the definitions page because I just felt they weren't uniform and the words seemed to not properly explain what they were doing. I also did some code clean up (or tried to...) with comments and whatnot. --- data/templates/frr/ldpd.frr.tmpl | 12 +++++ interface-definitions/protocols-mpls.xml.in | 80 ++++++++++++++++++++++------- src/conf_mode/protocols_mpls.py | 71 ++++++++++++++++++++++--- 3 files changed, 137 insertions(+), 26 deletions(-) diff --git a/data/templates/frr/ldpd.frr.tmpl b/data/templates/frr/ldpd.frr.tmpl index 441ddcb3a..4b7e5c5ea 100644 --- a/data/templates/frr/ldpd.frr.tmpl +++ b/data/templates/frr/ldpd.frr.tmpl @@ -7,6 +7,18 @@ no router-id {{ old_router_id }} {% if router_id -%} router-id {{ router_id }} {% endif -%} +{% if old_ldp.cisco_interop_tlv -%} +no dual-stack cisco-interop +{% endif -%} +{% if ldp.cisco_interop_tlv -%} +dual-stack cisco-interop +{% endif -%} +{% if old_ldp.transport_prefer_ipv4 -%} +no dual-stack transport-connection prefer ipv4 +{% endif -%} +{% if ldp.transport_prefer_ipv4 -%} +dual-stack transport-connection prefer ipv4 +{% endif -%} {% for neighbor_id in old_ldp.neighbors -%} no neighbor {{neighbor_id}} password {{old_ldp.neighbors[neighbor_id].password}} {% if 'ttl_security' is defined -%} diff --git a/interface-definitions/protocols-mpls.xml.in b/interface-definitions/protocols-mpls.xml.in index 259289cc8..4df2be4e7 100644 --- a/interface-definitions/protocols-mpls.xml.in +++ b/interface-definitions/protocols-mpls.xml.in @@ -11,15 +11,15 @@ - LDP options + Label Distribution Protocol (LDP) - x.x.x.x Label Switch Router (LSR) id + Label Distribution Protocol (LDP) router ID ipv4 - LSR ipv4 id + LDP IPv4 ID @@ -28,10 +28,10 @@ - LDP Id of neighbor + LDP neighbor parameters ipv4 - neighbor IPv4 id + Neighbor IPv4 address @@ -40,7 +40,7 @@ - Peer password + Neighbor password @@ -61,7 +61,7 @@ - Session ipv4 holdtime + Session IPv4 hold time 15-65535 Time in seconds @@ -84,7 +84,7 @@ - Hello ipv4 holdtime + Hello IPv4 hold time 1-65535 Time in seconds @@ -96,7 +96,7 @@ - Hello ipv4 interval + Hello IPv4 interval 1-65535 Time in seconds @@ -108,7 +108,7 @@ - Hello ipv6 holdtime + Hello IPv6 hold time 1-65535 Time in seconds @@ -120,7 +120,7 @@ - Hello ipv6 interval + Hello IPv6 interval 1-65535 Time in seconds @@ -132,7 +132,7 @@ - Session ipv4 holdtime + Session IPv4 hold time 15-65535 Time in seconds @@ -144,7 +144,7 @@ - Session ipv6 holdtime + Session IPv6 hold time 15-65535 Time in seconds @@ -156,7 +156,7 @@ - Transport ipv4 address + Transport IPv4 address ipv4 IPv4 bind as transport @@ -168,7 +168,7 @@ - Transport ipv6 address + Transport IPv6 address ipv6 IPv6 bind as transport @@ -223,7 +223,7 @@ - Hello holdtime + Hello hold time 1-65535 Time in seconds @@ -273,7 +273,7 @@ - Hello holdtime + Hello hold time 1-65535 Time in seconds @@ -287,6 +287,25 @@ + + + Label Distribution Protocol (LDP) miscellaneous parameters + + + + + Enable Cisco non-compliant format capability TLV + + + + + + Prefer IPv4 for TCP peer transport connection + + + + + Export parameters @@ -322,7 +341,7 @@ - Listen interface for LDP + Enable LDP and neighbor discovery on interface @@ -331,6 +350,31 @@ + + + Multiprotocol Label Switching (MPLS) miscellaneous parameters + + + + + Disable copy of IP TTL to MPLS TTL + + + + + + Maximum TTL for MPLS packets + + 1-255 + Maximum hops allowed + + + + + + + + diff --git a/src/conf_mode/protocols_mpls.py b/src/conf_mode/protocols_mpls.py index 0972e337a..84948baf4 100755 --- a/src/conf_mode/protocols_mpls.py +++ b/src/conf_mode/protocols_mpls.py @@ -37,6 +37,14 @@ def get_config(config=None): mpls_conf = { 'router_id' : None, 'mpls_ldp' : False, + 'old_parameters' : { + 'no_ttl_propagation' : False, + 'maximum_ttl' : None + }, + 'parameters' : { + 'no_ttl_propagation' : False, + 'maximum_ttl' : None + }, 'old_ldp' : { 'interfaces' : [], 'neighbors' : {}, @@ -50,6 +58,8 @@ def get_config(config=None): 'ses_ipv6_hold' : None, 'export_ipv4_exp' : False, 'export_ipv6_exp' : False, + 'cisco_interop_tlv' : False, + 'transport_prefer_ipv4' : False, 'target_ipv4_addresses' : [], 'target_ipv6_addresses' : [], 'target_ipv4_enable' : False, @@ -72,6 +82,8 @@ def get_config(config=None): 'ses_ipv6_hold' : None, 'export_ipv4_exp' : False, 'export_ipv6_exp' : False, + 'cisco_interop_tlv' : False, + 'transport_prefer_ipv4' : False, 'target_ipv4_addresses' : [], 'target_ipv6_addresses' : [], 'target_ipv4_enable' : False, @@ -84,15 +96,35 @@ def get_config(config=None): } if not (conf.exists('protocols mpls') or conf.exists_effective('protocols mpls')): return None - + + # If LDP is defined then enable LDP portion of code if conf.exists('protocols mpls ldp'): mpls_conf['mpls_ldp'] = True + # Set to MPLS hierarchy configuration level + conf.set_level('protocols mpls') + + # Get no_ttl_propagation + if conf.exists_effective('parameters no-propagate-ttl'): + mpls_conf['old_parameters']['no_ttl_propagation'] = True + + if conf.exists('parameters no-propagate-ttl'): + mpls_conf['parameters']['no_ttl_propagation'] = True + + # Get maximum_ttl + if conf.exists_effective('parameters maximum-ttl'): + mpls_conf['old_parameters']['maximum_ttl'] = conf.return_effective_value('parameters maximum-ttl') + + if conf.exists('parameters maximum-ttl'): + mpls_conf['parameters']['maximum_ttl'] = conf.return_value('parameters maximum-ttl') + + # Set to LDP hierarchy configuration level conf.set_level('protocols mpls ldp') # Get router-id if conf.exists_effective('router-id'): mpls_conf['old_router_id'] = conf.return_effective_value('router-id') + if conf.exists('router-id'): mpls_conf['router_id'] = conf.return_value('router-id') @@ -222,6 +254,20 @@ def get_config(config=None): if conf.exists('targeted-neighbor ipv6 hello-holdtime'): mpls_conf['ldp']['target_ipv6_hello_hold'] = conf.return_value('targeted-neighbor ipv6 hello-holdtime') + # Get parameters cisco-interop-tlv + if conf.exists_effective('parameters cisco-interop-tlv'): + mpls_conf['old_ldp']['cisco_interop_tlv'] = True + + if conf.exists('parameters cisco-interop-tlv'): + mpls_conf['ldp']['cisco_interop_tlv'] = True + + # Get parameters transport-prefer-ipv4 + if conf.exists_effective('parameters transport-prefer-ipv4'): + mpls_conf['old_ldp']['transport_prefer_ipv4'] = True + + if conf.exists('parameters transport-prefer-ipv4'): + mpls_conf['ldp']['transport_prefer_ipv4'] = True + # Get interfaces if conf.exists_effective('interface'): mpls_conf['old_ldp']['interfaces'] = conf.return_effective_values('interface') @@ -264,15 +310,15 @@ def verify(mpls): return None if mpls['mpls_ldp']: - # Requre router-id + # Require router-id if not mpls['router_id']: raise ConfigError(f"MPLS ldp router-id is mandatory!") - # Requre discovery transport-address + # Require discovery transport-address if not mpls['ldp']['d_transp_ipv4'] and not mpls['ldp']['d_transp_ipv6']: raise ConfigError(f"MPLS ldp discovery transport address is mandatory!") - # Requre interface + # Require interface if not mpls['ldp']['interfaces']: raise ConfigError(f"MPLS ldp interface is mandatory!") @@ -287,15 +333,24 @@ def apply(mpls): if mpls is None: return None - # Set number of entries in the platform label table + # Set number of entries in the platform label table if mpls['mpls_ldp']: sysctl('net.mpls.platform_labels', '1048575') else: sysctl('net.mpls.platform_labels', '0') - # Do not copy IP TTL to MPLS header - sysctl('net.mpls.ip_ttl_propagate', '0') - + # Choose whether to copy IP TTL to MPLS header TTL + if mpls['parameters']['no_ttl_propagation']: + sysctl('net.mpls.ip_ttl_propagate', '0') + else: + sysctl('net.mpls.ip_ttl_propagate', '1') + + # Choose whether to limit maximum MPLS header TTL + if mpls['parameters']['maximum_ttl']: + sysctl('net.mpls.default_ttl', '%s' %(mpls['parameters']['maximum_ttl'])) + else: + sysctl('net.mpls.default_ttl', '255') + # Allow mpls on interfaces operate_mpls_on_intfc(mpls['ldp']['interfaces'], 1) -- cgit v1.2.3