Skip to content

Commit

Permalink
Insert neighbor BGP policies at the AF level, use 'replace' instead o…
Browse files Browse the repository at this point in the history
…f 'update'
  • Loading branch information
ipspace committed Aug 30, 2024
1 parent 8c6e2ed commit 3f1c5e3
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions netsim/extra/bgp.policy/srlinux.j2
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{% macro ebgp_neighbor(n,af,vrf) -%}
- path: /network-instance[name={{vrf}}]/protocols/bgp
value:
{% if n.type=='ebgp' and n[af] is true %}
group:
- group-name: intf-{{ n.local_if }}
{% else %}
neighbor:
- peer-address: {{ n[af]|ipaddr('address') }}
{% for direction in [ 'in','out' ] if direction in n.policy %}
{% set p_path = 'import-policy' if direction == 'in' else 'export-policy' %}
{% set p_path = 'afi-safi[afi-safi-name='+af+'-unicast]/'+p_path %}
{% if n.type=='ebgp' and n[af] is true %}
- path: /network-instance[name={{vrf}}]/protocols/bgp/group[group-name=intf-{{ n.local_if }}]/{{ p_path }}
{% else %}
- path: /network-instance[name={{vrf}}]/protocols/bgp/neighbor[peer-address={{ n[af]|ipaddr('address') }}]/{{ p_path }}
{% endif %}
{% for direction in [ 'in','out' ] if direction in n.policy %}
{{ 'import' if direction=='in' else 'export' }}-policy: [ {{ n.policy[direction] }} ]
value: [ {{ n.policy[direction] }} ]
{% endfor %}
{%- endmacro %}

updates:
replace:
{% for af in ['ipv4','ipv6'] %}
{% for n in bgp.neighbors if n[af] is defined and 'policy' in n %}
{{ ebgp_neighbor(n,af,'default') -}}
Expand Down

0 comments on commit 3f1c5e3

Please sign in to comment.