Skip to content

Commit c084473

Browse files
committed
Use BGP neighbor attributes from #2575 in EOS, FRR, and IOS templates
1 parent a9d47b5 commit c084473

File tree

4 files changed

+10
-27
lines changed

4 files changed

+10
-27
lines changed

netsim/ansible/templates/bgp/eos.j2

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,11 @@ router bgp {{ bgp.as }}
8080
{% for n in bgp.neighbors if n[af] is defined and n.activate[af] is defined and n.activate[af] %}
8181
{% set peer = 'ebgp_intf_' + n.local_if if n.local_if is defined else n[af] %}
8282
neighbor {{ peer }} activate
83-
{% if n.type == 'ibgp' and bgp.next_hop_self|default(False) %}
83+
{% set nhs = n.next_hop_self|default(False) %}
84+
{% if nhs == 'ebgp' %}
8485
neighbor {{ peer }} route-map next-hop-self-{{ af }} out
85-
{% endif %}
86-
{% if n.type == 'confed_ebgp' and bgp.next_hop_self|default(False) %}
87-
neighbor {{ peer }} next-hop-self
88-
{% endif %}
89-
{% if n.type == 'localas_ibgp' %}
86+
{% else %}
9087
neighbor {{ peer }} next-hop-self
91-
neighbor {{ peer }} route-reflector-client
9288
{% endif %}
9389
{% if n.local_if is defined and af == 'ipv4' %}
9490
neighbor {{ peer }} next-hop address-family ipv6 originate

netsim/ansible/templates/bgp/eos.macro.j2

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@
1616
{% if n._source_intf is defined %}
1717
neighbor {{ peer }} update-source {{ n._source_intf.ifname }}
1818
{% endif %}
19-
{% if n.type == 'localas_ibgp' %}
20-
neighbor {{ peer }} next-hop-peer
21-
{% endif %}
22-
{% if 'ibgp' in n.type %}
23-
{% if bgp.rr|default('') and not n.rr|default('') %}
19+
{% if n.rr_client|default(False) %}
2420
neighbor {{ peer }} route-reflector-client
25-
{% endif %}
2621
{% endif %}
2722
{% if n.type in bgp.community|default({}) %}
2823
neighbor {{ peer }} send-community {%

netsim/ansible/templates/bgp/frr.j2

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,12 @@ router bgp {{ bgp.as }}
6868
else False %}
6969
{% if peer %}
7070
neighbor {{ peer }} activate
71-
{% if n.type in ['ibgp','confed_ebgp'] and bgp.next_hop_self|default(False) %}
72-
neighbor {{ peer }} next-hop-self
71+
{% if n.next_hop_self|default(False) %}
72+
neighbor {{ peer }} next-hop-self{% if n.next_hop_self == 'all' %} force{% endif +%}
7373
{% endif %}
74-
{% if n.type == 'ibgp' and bgp.rr|default('') and not n.rr|default('') %}
74+
{% if n.rr_client|default(False) %}
7575
neighbor {{ peer }} route-reflector-client
7676
{% endif %}
77-
{% if n.type == 'localas_ibgp' %}
78-
neighbor {{ peer }} route-reflector-client
79-
neighbor {{ peer }} next-hop-self force
80-
{% endif %}
8177
{% if n.type in bgp.community|default({}) %}
8278
no neighbor {{ peer }} send-community all
8379
{% for c_type in bgp.community[n.type] %}

netsim/ansible/templates/bgp/ios.macro.j2

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@
1919
{% macro neighbor_af(n,ip,bgp) %}
2020
neighbor {{ ip }} activate
2121
neighbor {{ ip }} advertisement-interval 0
22-
{% if n.type in ['ibgp','confed_ebgp'] and bgp.next_hop_self|default(False) %}
23-
neighbor {{ ip }} next-hop-self
22+
{% if n.next_hop_self|default(False) %}
23+
neighbor {{ ip }} next-hop-self{% if n.next_hop_self == 'all' %} all{% endif +%}
2424
{% endif %}
25-
{% if n.type == 'ibgp' and bgp.rr|default('') and not n.rr|default('') %}
25+
{% if n.rr_client|default(False) %}
2626
neighbor {{ ip }} route-reflector-client
2727
{% endif %}
28-
{% if n.type == 'localas_ibgp' %}
29-
neighbor {{ ip }} route-reflector-client
30-
neighbor {{ ip }} next-hop-self all
31-
{% endif %}
3228
{% if n.type in bgp.community|default({}) %}
3329
{% for c_type in bgp.community[n.type] %}
3430
neighbor {{ ip }} send-community {{ c_type }}

0 commit comments

Comments
 (0)