Skip to content

Commit ea222a1

Browse files
authored
Use bgp.advertise attribute in global Junos BGP advertise policy (#3242)
* We have to generate per-AF route-filter-list (thank you, Juniper) * The per-AF route-filter-lists are used in bgp-advertise policy statement instead of interface/static/... matches * This will also work with the bgp.advertise attribute once #3236 is merged
1 parent 7d4946c commit ea222a1

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

netsim/ansible/templates/bgp/junos.policy.j2

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ policy-options {
2727

2828
policy-options {
2929

30-
route-filter-list bgp-announce {
31-
{% for pfx in bgp.originate|default([]) %}
32-
{{ pfx|ansible.utils.ipaddr('0') }} exact;
33-
{% endfor %}
30+
{% for bgp_af in af %}
31+
{% for pfx in bgp.advertise|default([]) if bgp_af in pfx %}
32+
{% if loop.first %}
33+
route-filter-list bgp-announce-{{ bgp_af }} {
34+
{% endif %}
35+
{{ pfx[bgp_af] }} exact;
36+
{% if loop.last %}
3437
}
38+
{% endif %}
39+
{% endfor %}
40+
{% endfor %}
3541

3642
{% for af in ('ipv4','ipv6') %}
3743
{% for nh in ['ebgp','all'] %}
@@ -53,32 +59,21 @@ policy-options {
5359
{% endfor %}
5460

5561
policy-statement bgp-advertise {
56-
term advertise {
57-
from {
58-
protocol direct;
59-
interface [
60-
{% if bgp.advertise_loopback %} lo0.0 {% endif %}
61-
{%- for l in interfaces if l.bgp.advertise|default("") and not 'vrf' in l %}
62-
{{ l.ifname }}
63-
{% endfor %} ];
64-
}
65-
then {
66-
community add x-route-permit-mark;
67-
next policy;
68-
}
69-
}
70-
71-
term originate {
62+
{% for bgp_af in af %}
63+
{% for pfx in bgp.advertise|default([]) if bgp_af in pfx %}
64+
{% if loop.first %}
65+
term advertise-{{ bgp_af }} {
7266
from {
73-
protocol static;
74-
route-filter-list bgp-announce;
67+
route-filter-list bgp-announce-{{ bgp_af }};
7568
}
7669
then {
7770
community add x-route-permit-mark;
7871
next policy;
7972
}
8073
}
81-
74+
{% endif %}
75+
{% endfor %}
76+
{% endfor %}
8277
}
8378

8479
policy-statement bgp-redistribute {

0 commit comments

Comments
 (0)