Skip to content

Commit

Permalink
Simplify the IBGP route map with the new 'next-hop: self' action
Browse files Browse the repository at this point in the history
  • Loading branch information
ipspace committed Sep 7, 2024
1 parent 465bdf3 commit f810f47
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
24 changes: 13 additions & 11 deletions netsim/ansible/templates/bgp/srlinux.macro.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
mask-length-range: exact
{% endmacro %}

{% macro bgp_export_policy(vrf,type,nh=None,import=[]) %}
{% macro bgp_export_policy(vrf,type,nhs=False,import=[]) %}
{% if vrf == 'default' and type == 'bgp' %}
- path: /routing-policy/prefix-set[name={{ vrf }}_bgp_advertise]
value:
Expand All @@ -25,22 +25,26 @@
action:
policy-result: next-policy
{% endif %}
{% if 'ibgp' in type and nh %}
{% if 'ibgp' in type and nhs %}
- name: rr-next-hop-unchanged
match:
protocol: bgp
bgp:
community-set: ibgp-mark
action:
policy-result: next-policy
bgp:
communities:
remove:
ibgp-mark
- name: ebgp-next-hop-self
match:
protocol: bgp
action:
policy-result: next-policy
bgp:
next-hop:
set: "{{ nh }}"
set: self
{% else %}
- name: bgp
match:
Expand Down Expand Up @@ -102,7 +106,7 @@
admin-state: enable
{% set nh_self = bgp.next_hop_self|default(False) and type == 'ibgp' %}
{% set nh_self_rr = nh_self and vrf_bgp.rr|default(False) %}
{% set ep_name = (vrf + "_ibgp-" + af + "_export") if nh_self_rr else (vrf + "_bgp_export") %}
{% set ep_name = (vrf + "_ibgp-nhs_export") if nh_self_rr else (vrf + "_bgp_export") %}
{{ bgp_families(neighbor,import=[ "ibgp-mark" if nh_self_rr else "accept_all" ],export=[ ep_name, 'accept_all' ]) }}
timers:
connect-retry: 10
Expand Down Expand Up @@ -143,13 +147,11 @@
only once)
#}
{{ bgp_export_policy(vrf,'bgp',import=vrf_bgp.import|default([])) }}
{% if bgp.next_hop_self|default(False) %}
{% for afm in vrf_context.af %}
{% for n in vrf_bgp.neighbors|default([]) if afm in n and n.type == 'ibgp' %}
{% if loop.first %}
{{ bgp_export_policy(vrf,'ibgp-'+afm,loopback[afm]|ipaddr('address'),import=vrf_bgp.import|default([])) }}
{% endif %}
{% endfor %}
{% if bgp.next_hop_self|default(False) and bgp.rr|default(False) %}
{% for n in vrf_bgp.neighbors|default([]) if n.type == 'ibgp' %}
{% if loop.first %}
{{ bgp_export_policy(vrf,'ibgp-nhs',nhs=true,import=vrf_bgp.import|default([])) }}
{% endif %}
{% endfor %}
{% endif %}

Expand Down
11 changes: 6 additions & 5 deletions tests/integration/bgp/03-ibgp-rr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ validate:
wait: 5
nodes: [ r2 ]
plugin: bgp_prefix('172.0.42.0/24',peer=nodes.dut.bgp.router_id)
# inact:
# description: Check route reflection of inactive routes on DUT
# wait: 5
# nodes: [ r2 ]
# plugin: bgp_prefix('10.0.0.10/32',peer=nodes.dut.bgp.router_id)
inact:
description: Check route reflection of inactive routes on DUT
wait: 2
nodes: [ r2 ]
level: warning
plugin: bgp_prefix('10.0.0.10/32',peer=nodes.dut.bgp.router_id)
nhu:
description: Check next-hop handling of reflected routes
nodes: [ r2 ]
Expand Down

0 comments on commit f810f47

Please sign in to comment.