diff options
Diffstat (limited to 'data/templates/frr')
-rw-r--r-- | data/templates/frr/bgp.frr.tmpl | 175 |
1 files changed, 112 insertions, 63 deletions
diff --git a/data/templates/frr/bgp.frr.tmpl b/data/templates/frr/bgp.frr.tmpl index 02bac3bf7..d0857ac2c 100644 --- a/data/templates/frr/bgp.frr.tmpl +++ b/data/templates/frr/bgp.frr.tmpl @@ -14,10 +14,9 @@ router bgp {{ asn }} {%- if type == "ipv4_unicast" %} ! address-family ipv4 unicast -{#- need to check #} {%- if 'aggregate_address' in bgp_afi[type] %} {%- for ip in bgp_afi[type].aggregate_address %} -{%- if ( ('as_set' and 'summary_only') in bgp_afi[type].aggregate_address[ip] ) %} +{%- if ( ('as_set' in bgp_afi[type].aggregate_address[ip]) and ('summary_only' in bgp_afi[type].aggregate_address[ip] ) ) %} aggregate-address {{ ip }} as-set summary-only {%- elif 'as_set' in bgp_afi[type].aggregate_address[ip] %} aggregate-address {{ ip }} as-set @@ -28,23 +27,20 @@ router bgp {{ asn }} {%- endif %} {%- endfor %} {%- endif %} -{# END aggregate address#} -{#- redistribute #} -{# need to check. dont work. - 'metric' and 'route_map' match also only 'route_map' - 'table' parameter also include in protocol, its not what I want #} +{#- END aggregate address ipv4 #} + +{#- redistribute afi ipv4 #} {%- if 'redistribute' in bgp_afi[type] %} -{%- if 'table' in bgp_afi[type].redistribute %} - redistribute table {{bgp_afi[type].redistribute.table}} -{%- endif %} {%- for protocol in bgp_afi[type].redistribute %} -{%- if ( ('metric' and 'route_map') in bgp_afi[type].redistribute[protocol] ) %} +{%- if ( ('route_map' in bgp_afi[type].redistribute[protocol]) and ('metric' in bgp_afi[type].redistribute[protocol] ) ) %} redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}} route-map {{bgp_afi[type].redistribute[protocol].route_map}} {%- elif 'metric' in bgp_afi[type].redistribute[protocol] %} - redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}} + redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}} {%- elif 'route_map' in bgp_afi[type].redistribute[protocol] %} redistribute {{protocol}} route-map {{bgp_afi[type].redistribute[protocol].route_map}} -{%- else %} +{%- elif 'table' in bgp_afi[type].redistribute %} + redistribute table {{bgp_afi[type].redistribute.table}} +{%- else %} redistribute {{protocol}} {%- endif %} {%- endfor %} @@ -65,7 +61,7 @@ router bgp {{ asn }} address-family ipv6 unicast {%- if 'aggregate_address' in bgp_afi[type] %} {%- for ip in bgp_afi[type].aggregate_address %} -{%- if ( ('as_set' and 'summary_only') in bgp_afi[type].aggregate_address[ip] ) %} +{%- if ( ('as_set' in bgp_afi[type].aggregate_address[ip]) and ('summary_only' in bgp_afi[type].aggregate_address[ip] ) ) %} aggregate-address {{ ip }} as-set summary-only {%- elif 'as_set' in bgp_afi[type].aggregate_address[ip] %} aggregate-address {{ ip }} as-set @@ -76,22 +72,20 @@ router bgp {{ asn }} {%- endif %} {%- endfor %} {%- endif %} -{# END aggregate address#} +{#- END aggregate address ipv6 #} -{#- redistribute #} -{# need to check. doesn't work. 'metric' and 'route_map' match also only 'route_map' #} +{#- redistribute afi ipv6 #} {%- if 'redistribute' in bgp_afi[type] %} -{%- if 'table' in bgp_afi[type].redistribute %} - redistribute table {{bgp_afi[type].redistribute.table}} -{%- endif %} {%- for protocol in bgp_afi[type].redistribute %} -{%- if ( ('metric' and 'route_map') in bgp_afi[type].redistribute[protocol] ) %} +{%- if ( ('route_map' in bgp_afi[type].redistribute[protocol]) and ('metric' in bgp_afi[type].redistribute[protocol] ) ) %} redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}} route-map {{bgp_afi[type].redistribute[protocol].route_map}} {%- elif 'metric' in bgp_afi[type].redistribute[protocol] %} - redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}} + redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}} {%- elif 'route_map' in bgp_afi[type].redistribute[protocol] %} redistribute {{protocol}} route-map {{bgp_afi[type].redistribute[protocol].route_map}} -{%- else %} +{%- elif 'table' in bgp_afi[type].redistribute %} + redistribute table {{bgp_afi[type].redistribute.table}} +{%- else %} redistribute {{protocol}} {%- endif %} {%- endfor %} @@ -206,7 +200,7 @@ router bgp {{ asn }} neighbor {{ pr_group }} update-source {{ conf_peer_group.update_source }} {%- endif %} -{# START peer-group afi; set protocols bgp xxx peer-group FOO address-family #} +{#- START peer-group afi; set protocols bgp xxx peer-group FOO address-family #} {%- if 'address_family' in conf_peer_group %} {%- for afi in conf_peer_group.address_family %} {%- if afi == "ipv4_unicast" %} @@ -236,10 +230,19 @@ router bgp {{ asn }} {%- endif %} {#- END single params for peer-group #} -{#- Checks need to be done as-path|med|next-hop #} {%- if 'attribute_unchanged' in conf_peer_group.address_family.ipv4_unicast %} -{%- if 'as_path' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged %} +{%- if ( ('as_path' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) and ('med' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) ) %} + neighbor {{ pr_group }} attribute-unchanged as-path med +{%- elif ( ('as_path' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) and ('next_hop' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) ) %} + neighbor {{ pr_group }} attribute-unchanged as-path next-hop +{%- elif ( ('med' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) and ('next_hop' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) ) %} + neighbor {{ pr_group }} attribute-unchanged med next-hop +{%- elif 'as_path' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged %} neighbor {{ pr_group }} attribute-unchanged as-path +{%- elif 'med' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged %} + neighbor {{ pr_group }} attribute-unchanged med +{%- elif 'next_hop' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged %} + neighbor {{ pr_group }} attribute-unchanged next-hop {%- else %} neighbor {{ pr_group }} attribute-unchanged as-path next-hop med {%- endif %} @@ -247,11 +250,13 @@ router bgp {{ asn }} {#- END attribute-unchanged #} {%- if 'capability' in conf_peer_group.address_family.ipv4_unicast %} -{%- if 'receive' in conf_peer_group.address_family.ipv4_unicast.capability.orf.prefix_list %} +{%- if 'orf' in conf_peer_group.address_family.ipv4_unicast.capability %} +{%- if 'receive' in conf_peer_group.address_family.ipv4_unicast.capability.orf.prefix_list %} neighbor {{ pr_group }} capability orf prefix-list receive -{%- endif %} -{%- if 'send' in conf_peer_group.address_family.ipv4_unicast.capability.orf.prefix_list %} +{%- endif %} +{%- if 'send' in conf_peer_group.address_family.ipv4_unicast.capability.orf.prefix_list %} neighbor {{ pr_group }} capability orf prefix-list send +{%- endif %} {%- endif %} {%- endif %} @@ -322,7 +327,6 @@ router bgp {{ asn }} {%- endif %} {%- endif %} -{#- Need to check. https://phabricator.vyos.net/T2387#73900 #} {%- if 'unsuppress_map' in conf_peer_group.address_family.ipv4_unicast %} neighbor {{ pr_group }} unsuppress-map {{conf_peer_group.address_family.ipv4_unicast.unsuppress_map}} {%- endif %} @@ -357,21 +361,39 @@ router bgp {{ asn }} {%- endif %} {#- END single params for peer-group afi6 #} -{#- Checks need to be done as-path|med|next-hop #} {%- if 'attribute_unchanged' in conf_peer_group.address_family.ipv6_unicast %} -{%- if 'as_path' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged %} +{%- if ( ('as_path' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) and ('med' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) ) %} + neighbor {{ pr_group }} attribute-unchanged as-path med +{%- elif ( ('as_path' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) and ('next_hop' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) ) %} + neighbor {{ pr_group }} attribute-unchanged as-path next-hop +{%- elif ( ('med' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) and ('next_hop' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) ) %} + neighbor {{ pr_group }} attribute-unchanged med next-hop +{%- elif 'as_path' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged %} neighbor {{ pr_group }} attribute-unchanged as-path +{%- elif 'med' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged %} + neighbor {{ pr_group }} attribute-unchanged med +{%- elif 'next_hop' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged %} + neighbor {{ pr_group }} attribute-unchanged next-hop {%- else %} neighbor {{ pr_group }} attribute-unchanged as-path next-hop med {%- endif %} {%- endif %} +{#- END attribute-unchanged ipv6 #} {%- if 'capability' in conf_peer_group.address_family.ipv6_unicast %} -{%- if 'receive' in conf_peer_group.address_family.ipv6_unicast.capability.orf.prefix_list %} +{%- if 'dynamic' in conf_peer_group.address_family.ipv6_unicast.capability %} +{#- exit from afi ipv6 unicast because 'dynamic' its a global parameter for peer-group in afi6. Other checks are ongoing in afi6. Also related T3037 #} + exit-address-family + neighbor {{ pr_group }} capability dynamic + address-family ipv6 unicast +{%- endif %} +{%- if 'orf' in conf_peer_group.address_family.ipv6_unicast.capability %} +{%- if 'receive' in conf_peer_group.address_family.ipv6_unicast.capability.orf.prefix_list %} neighbor {{ pr_group }} capability orf prefix-list receive {%- endif %} -{%- if 'send' in conf_peer_group.address_family.ipv6_unicast.capability.orf.prefix_list %} +{%- if 'send' in conf_peer_group.address_family.ipv6_unicast.capability.orf.prefix_list %} neighbor {{ pr_group }} capability orf prefix-list send +{%- endif %} {%- endif %} {%- endif %} @@ -442,7 +464,6 @@ router bgp {{ asn }} {%- endif %} {%- endif %} -{#- Checks need to be done. https://phabricator.vyos.net/T2387#73900 #} {%- if 'unsuppress_map' in conf_peer_group.address_family.ipv6_unicast %} neighbor {{ pr_group }} unsuppress-map {{conf_peer_group.address_family.ipv6_unicast.unsuppress_map}} {%- endif %} @@ -453,7 +474,7 @@ router bgp {{ asn }} {%- endfor %} {%- endif %} -{# END peer-group afi; set protocols bgp xxx peer-group FOO address-family #} +{#- END peer-group afi; set protocols bgp xxx peer-group FOO address-family #} {%- endfor %} {%- endif %} @@ -464,7 +485,7 @@ router bgp {{ asn }} {#- set peer-group as conf_peer #} {%- set conf_peer = conf_bgp[asn].neighbor[peer] %} -{#- First parameter for peer-group - remote-as #} +{#- First parameter for peer neighbor - remote-as #} {%- if 'remote_as' in conf_peer %} neighbor {{ peer }} remote-as {{ conf_peer.remote_as }} {%- endif %} @@ -491,10 +512,6 @@ router bgp {{ asn }} {%- endif %} {%- endif %} -{%- if 'description' in conf_peer %} - neighbor {{ peer }} description {{ conf_peer.description }} -{%- endif %} - {%- if 'disable_capability_negotiation' in conf_peer %} neighbor {{ peer }} disable-capability-negotiation {%- endif %} @@ -564,17 +581,21 @@ router bgp {{ asn }} neighbor {{ peer }} strict-capability-match {%- endif %} -{#- Need to check #} +{#- set protocols bgp xxx neighbor x.x.x.x timers #} {%- if 'timers' in conf_peer %} -{%- if ( ('connect' and 'holdtime' and 'keepalive') in conf_peer.timers ) %} +{%- if ( ('connect' in conf_peer.timers) and ('holdtime' in conf_peer.timers) and ('keepalive' in conf_peer.timers ) ) %} neighbor {{ peer }} timers {{conf_peer.timers.keepalive}} {{conf_peer.timers.holdtime}} - neighbor {{ peer }} timers connect {{conf_peer.timers.connect}} + neighbor {{ peer }} timers connect {{conf_peer.timers.connect}} +{%- elif ( ('holdtime' in conf_peer.timers) and ('keepalive' in conf_peer.timers ) ) %} + neighbor {{ peer }} timers {{conf_peer.timers.keepalive}} {{conf_peer.timers.holdtime}} +{%- elif 'connect' in conf_peer.timers %} + neighbor {{ peer }} timers connect {{conf_peer.timers.connect}} {%- endif %} {%- endif %} {%- if 'ttl_security' in conf_peer %} {%- if 'hops' in conf_peer.ttl_security %} - neighbor {{ peer }} ttl-security hops {{conf_peer.ttl_security.hops}} + neighbor {{ peer }} ttl-security hops {{conf_peer.ttl_security.hops}} {%- endif %} {%- endif %} @@ -582,6 +603,10 @@ router bgp {{ asn }} neighbor {{ peer }} update-source {{ conf_peer.update_source }} {%- endif %} +{%- if 'description' in conf_peer %} + neighbor {{ peer }} description {{ conf_peer.description }} +{%- endif %} + {#- START address family for peer; set protocols bgp xxx neighbor x.x.x.x address-family ipvX-unicast #} {%- if 'address_family' in conf_peer %} {%- for afi in conf_peer.address_family %} @@ -615,10 +640,19 @@ router bgp {{ asn }} {%- endif %} {#- END single params for neighbor #} -{#- Checks need to be done as-path|med|next-hop #} {%- if 'attribute_unchanged' in conf_peer.address_family.ipv4_unicast %} -{%- if 'as_path' in conf_peer.address_family.ipv4_unicast.attribute_unchanged %} +{%- if ( ('as_path' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) and ('med' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) ) %} + neighbor {{ peer }} attribute-unchanged as-path med +{%- elif ( ('as_path' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) and ('next_hop' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) ) %} + neighbor {{ peer }} attribute-unchanged as-path next-hop +{%- elif ( ('med' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) and ('next_hop' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) ) %} + neighbor {{ peer }} attribute-unchanged med next-hop +{%- elif 'as_path' in conf_peer.address_family.ipv4_unicast.attribute_unchanged %} neighbor {{ peer }} attribute-unchanged as-path +{%- elif 'med' in conf_peer.address_family.ipv4_unicast.attribute_unchanged %} + neighbor {{ peer }} attribute-unchanged med +{%- elif 'next_hop' in conf_peer.address_family.ipv4_unicast.attribute_unchanged %} + neighbor {{ peer }} attribute-unchanged next-hop {%- else %} neighbor {{ peer }} attribute-unchanged as-path next-hop med {%- endif %} @@ -626,11 +660,13 @@ router bgp {{ asn }} {#- END attribute-unchanged #} {%- if 'capability' in conf_peer.address_family.ipv4_unicast %} -{%- if 'receive' in conf_peer.address_family.ipv4_unicast.capability.orf.prefix_list %} +{%- if 'orf' in conf_peer.address_family.ipv4_unicast.capability %} +{%- if 'receive' in conf_peer.address_family.ipv4_unicast.capability.orf.prefix_list %} neighbor {{ peer }} capability orf prefix-list receive -{%- endif %} -{%- if 'send' in conf_peer.address_family.ipv4_unicast.capability.orf.prefix_list %} +{%- endif %} +{%- if 'send' in conf_peer.address_family.ipv4_unicast.capability.orf.prefix_list %} neighbor {{ peer }} capability orf prefix-list send +{%- endif %} {%- endif %} {%- endif %} @@ -701,7 +737,6 @@ router bgp {{ asn }} {%- endif %} {%- endif %} -{#- Checks need to be done. https://phabricator.vyos.net/T2387#73900 #} {%- if 'unsuppress_map' in conf_peer.address_family.ipv4_unicast %} neighbor {{ peer }} unsuppress-map {{conf_peer.address_family.ipv4_unicast.unsuppress_map}} {%- endif %} @@ -740,10 +775,19 @@ router bgp {{ asn }} {%- endif %} {#- END single params for neighbor #} -{#- Checks need to be done as-path|med|next-hop #} {%- if 'attribute_unchanged' in conf_peer.address_family.ipv6_unicast %} -{%- if 'as_path' in conf_peer.address_family.ipv6_unicast.attribute_unchanged %} +{%- if ( ('as_path' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) and ('med' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) ) %} + neighbor {{ peer }} attribute-unchanged as-path med +{%- elif ( ('as_path' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) and ('next_hop' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) ) %} + neighbor {{ peer }} attribute-unchanged as-path next-hop +{%- elif ( ('med' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) and ('next_hop' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) ) %} + neighbor {{ peer }} attribute-unchanged med next-hop +{%- elif 'as_path' in conf_peer.address_family.ipv6_unicast.attribute_unchanged %} neighbor {{ peer }} attribute-unchanged as-path +{%- elif 'med' in conf_peer.address_family.ipv6_unicast.attribute_unchanged %} + neighbor {{ peer }} attribute-unchanged med +{%- elif 'next_hop' in conf_peer.address_family.ipv6_unicast.attribute_unchanged %} + neighbor {{ peer }} attribute-unchanged next-hop {%- else %} neighbor {{ peer }} attribute-unchanged as-path next-hop med {%- endif %} @@ -751,11 +795,13 @@ router bgp {{ asn }} {#- END attribute-unchanged #} {%- if 'capability' in conf_peer.address_family.ipv6_unicast %} -{%- if 'receive' in conf_peer.address_family.ipv6_unicast.capability.orf.prefix_list %} +{%- if 'orf' in conf_peer.address_family.ipv6_unicast.capability %} +{%- if 'receive' in conf_peer.address_family.ipv6_unicast.capability.orf.prefix_list %} neighbor {{ peer }} capability orf prefix-list receive -{%- endif %} -{%- if 'send' in conf_peer.address_family.ipv6_unicast.capability.orf.prefix_list %} - neighbor {{ peer }} capability orf prefix-list send +{%- endif %} +{%- if 'send' in conf_peer.address_family.ipv6_unicast.capability.orf.prefix_list %} + neighbor {{ peer }} capability orf prefix-list send +{%- endif %} {%- endif %} {%- endif %} @@ -826,7 +872,6 @@ router bgp {{ asn }} {%- endif %} {%- endif %} -{#- Checks need to be done. https://phabricator.vyos.net/T2387#73900 #} {%- if 'unsuppress_map' in conf_peer.address_family.ipv6_unicast %} neighbor {{ peer }} unsuppress-map {{conf_peer.address_family.ipv6_unicast.unsuppress_map}} {%- endif %} @@ -863,7 +908,7 @@ router bgp {{ asn }} {%- endif %} {%- endif %} {%- if 'med' in bgp_params.bestpath %} -{%- if ( ('confed' and 'missing_as_worst') in bgp_params.bestpath.med ) %} +{%- if ( ('confed' in bgp_params.bestpath.med) and ('missing_as_worst' in bgp_params.bestpath.med ) ) %} bgp bestpath med confed missing-as-worst {%- elif 'confed' in bgp_params.bestpath.med %} bgp bestpath med confed @@ -886,9 +931,9 @@ router bgp {{ asn }} {%- endif %} {%- endif %} -{#- Doesn't work in current FRR configuration (bgp dampening 16 751 2001 61) #} +{#- Doesn't work in current FRR configuration; vtysh (bgp dampening 16 751 2001 61) #} {%- if 'dampening' in bgp_params %} -{%- if ( ('half_life' and 'max_suppress_time' and 're_use' and 'start_suppress_time') in bgp_params.dampening ) %} +{%- if ( ('half_life' in bgp_params.dampening) and ('max_suppress_time' in bgp_params.dampening) and ('re_use' in bgp_params.dampening) and ('start_suppress_time' in bgp_params.dampening ) ) %} bgp dampening {{ bgp_params.dampening.half_life }} {{ bgp_params.dampening.re_use }} {{ bgp_params.dampening.start_suppress_time }} {{ bgp_params.dampening.max_suppress_time }} {%- endif %} {%- endif %} @@ -909,7 +954,7 @@ router bgp {{ asn }} {%- if 'distance' in bgp_params %} {%- if 'global' in bgp_params.distance %} -{%- if ( ('external' and 'internal' and 'local') in bgp_params.distance.global ) %} +{%- if ( ('external' in bgp_params.distance.global) and ('internal' in bgp_params.distance.global) and ('local' in bgp_params.distance.global ) ) %} ! address-family ipv4 unicast distance bgp {{ bgp_params.distance.global.external }} {{ bgp_params.distance.global.internal }} {{ bgp_params.distance.global.local }} @@ -950,10 +995,14 @@ router bgp {{ asn }} no bgp fast-external-failover {%- endif %} +{%- if 'router_id' in bgp_params %} + bgp router-id {{ bgp_params.router_id }} +{%- endif %} + {#- END parameters; set protocols bgp xxx parameters #} {%- if 'timers' in conf_bgp[asn] %} -{%- if ( ('holdtime' and 'keepalive') in conf_bgp[asn].timers ) %} +{%- if ( ('holdtime' in conf_bgp[asn].timers) and ('keepalive' in conf_bgp[asn].timers ) ) %} timers bgp {{conf_bgp[asn].timers.keepalive}} {{conf_bgp[asn].timers.holdtime}} {%- endif %} {%- endif %} |