-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathfrr.bgp.j2
More file actions
74 lines (68 loc) · 2.17 KB
/
frr.bgp.j2
File metadata and controls
74 lines (68 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{% if 'bgp' in srv6.igp|default([]) %}
interface ${SRv6_DEV}
ipv6 address {{ srv6.locator }}
{% endif %}
router bgp {{ bgp.as }}
! bgp default software-version-capability latest-encoding
segment-routing srv6
locator {{ inventory_hostname }}
exit
{% if 'bgp' in srv6.igp|default([]) %}
address-family ipv6 unicast
network {{ srv6.locator }}
exit-address-family
{% endif %}
{#
The core bgp module only provisions neighbors for which the transport matches the address family, i.e. IPv4 over v4
and IPv6 over v6. This template modifies IPv6 neighbors, adding VPNv4/6 AF over IPv6 transport and setting various
next hop handling flags
#}
{% macro bgp_neighbor(n,peer,af) %}
neighbor {{ peer }} activate
neighbor {{ peer }} encapsulation-srv6
neighbor {{ peer }} send-community both
{% if n.next_hop_unchanged is defined %}
neighbor {{ peer }} attribute-unchanged next-hop
{% endif %}
{% if n.type=='ibgp' and bgp.next_hop_self|default(True) %}
neighbor {{ peer }} next-hop-self
{% endif %}
{% endmacro -%}
{% if srv6.vpn is defined or srv6.bgp is defined %}
{% for n in bgp.neighbors|default([]) if n.ipv6 is defined %}
{% set peer = n.ipv6 %}
neighbor {{ peer }} remote-as {{ n.as }}
neighbor {{ peer }} description {{ n.name }} (SRv6)
{% if n.extended_nexthop is defined %}
neighbor {{ peer }} capability extended-nexthop
{% endif %}
{%- for af in ['ipv4','ipv6'] %}
{% if srv6.bgp is defined and n.type in srv6.bgp.get(af,[]) %}
address-family {{ af }} unicast
!
sid export auto
{{ bgp_neighbor(n,peer,af) -}}
!
{% endif %}
{% if srv6.vpn is defined and n.type in srv6.vpn.get(af,[]) %}
address-family {{ af }} vpn
!
{{ bgp_neighbor(n,peer,af) -}}
!
{% endif %}
{% endfor %}
{% endfor %}
!
{% if vrfs is defined %}
{% for vname,vdata in vrfs.items() %}
router bgp {{ vdata.as|default(bgp.as) }} vrf {{ vname }}
sid vpn per-vrf export auto
no bgp network import-check
{% for af in ['ipv4','ipv6'] if 'ebgp' in srv6.vpn.get(af,[]) %}
address-family {{ af }} unicast
nexthop vpn export {{ loopback.ipv6|ansible.utils.ipaddr('address') }}
{% endfor %}
!
{% endfor %}
{% endif %}
{% endif %}