From 995cede0474d389e99fcef6fdd7c6a928370b17d Mon Sep 17 00:00:00 2001
From: sever-sever <v.gletenko@vyos.io>
Date: Tue, 3 Nov 2020 08:42:57 +0000
Subject: bgp: T2850: Fixing the priority of template processing and missing
 params

---
 data/templates/frr/bgp.frr.tmpl | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/data/templates/frr/bgp.frr.tmpl b/data/templates/frr/bgp.frr.tmpl
index 6fb126f8d..d0857ac2c 100644
--- a/data/templates/frr/bgp.frr.tmpl
+++ b/data/templates/frr/bgp.frr.tmpl
@@ -381,6 +381,12 @@ router bgp {{ asn }}
 {#- END attribute-unchanged ipv6 #}
 
 {%- if 'capability' in conf_peer_group.address_family.ipv6_unicast %}
+{%-   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
@@ -479,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 %}
@@ -506,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 %}
@@ -601,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 %}
@@ -989,6 +995,10 @@ 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] %}
-- 
cgit v1.2.3