Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion netsim/daemons/bird/bgp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{% if 'router_id' in bgp %}
router id {{ bgp.router_id }};
{% endif %}
{{ bgp_config.bgp_default_originate_routes(bgp) }}
{% for _af in ['ipv4','ipv6'] if _af in af %}
{{ bgp_config.bgp_default_originate_routes(bgp,_af) }}
{% endfor %}
{{ bgp_config.bgp_advertise_list('bgp_advertise',bgp.advertise) }}
{{ bgp_config.bgp_prefixes_function('bgp_prefixes',bgp,'bgp_advertise',bgp.import|default([]),True) }}
{{ bgp_config.bgp_export_filters('bgp_export_','bgp_prefixes') }}
Expand Down
16 changes: 10 additions & 6 deletions netsim/daemons/bird/bgp.macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
{#
# bgp_default_originate_routes: Render reject static routes used to originate default routes toward selected BGP neighbors.
#}
{% macro bgp_default_originate_routes(bgp_data) %}
{% macro bgp_default_originate_routes(bgp_data,bgp_af,proto_suffix='',table_name='') %}
{% for ngb in bgp_data.neighbors|default([]) if ngb.default_originate|default(False) %}
{% if loop.first %}
{% for _af in ['ipv4','ipv6'] if _af in af %}
protocol static static_bgp_default_{{ _af }} {
{{ _af }};
route {{ '0.0.0.0/0' if _af=='ipv4' else '::/0' }} reject;
protocol static static_bgp_default{{ proto_suffix }}_{{ bgp_af }} {
{% if table_name %}
{{ bgp_af }} {
table {{ table_name }};
};
{% else %}
{{ bgp_af }};
{% endif %}
route {{ '0.0.0.0/0' if bgp_af=='ipv4' else '::/0' }} reject;
}
{% endfor %}
{% endif %}
{% endfor %}
{% endmacro %}
Expand Down
5 changes: 4 additions & 1 deletion netsim/daemons/bird/vrf-daemon.j2
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ protocol static static_vrf_leak_{{ vname }}_{{ dst_name }}_{{ sr_af }} {

{# VRF BGP configuration #}
{% if vdata.bgp is defined %}
{% for _af in vdata.af %}
{{ bird_bgp.bgp_default_originate_routes(vdata.bgp,_af,'_vrf_' + vname,vrf_table(vname,_af)) }}
{% endfor %}
{{ bird_bgp.bgp_advertise_list('bgp_advertise_vrf_' + vname,vdata.bgp.advertise) }}
{{ bird_bgp.bgp_prefixes_function('bgp_prefixes_vrf_' + vname,vdata.bgp,'bgp_advertise_vrf_' + vname,vdata.bgp.import|default(['connected','ospf']),False) }}
{{ bird_bgp.bgp_prefixes_function('bgp_prefixes_vrf_' + vname,vdata.bgp,'bgp_advertise_vrf_' + vname,vdata.bgp.import|default(['connected','ospf']),True) }}
{{ bird_bgp.bgp_export_filters('bgp_export_vrf_' + vname + '_','bgp_prefixes_vrf_' + vname) }}
{% for n in vdata.bgp.neighbors|default([]) %}
{{ bird_bgp.bgp_session(n,bgp,vname,vdata,netlab_interfaces) }}
Expand Down