Skip to content

Commit 3ef4446

Browse files
authored
bird: Configure static routes using 'protocol static' (#2341)
Bird used Linux static route configuration. That resulted in a working data plane, but those static routes were not redistributed into other routing protocols. This fix uses 'protocol static' to configure static routes, resulting in correct static route redistribution.
1 parent 34cbbb3 commit 3ef4446

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

netsim/daemons/bird.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ daemon_config:
66
bird: /etc/bird/bird.conf
77
bgp: /etc/bird/bgp.mod.conf
88
ospf: /etc/bird/ospf.mod.conf
9+
routing: /etc/bird/routing.mod.conf
910
clab:
1011
group_vars:
1112
netlab_show_command: [ birdc, 'show $@' ]
@@ -38,6 +39,8 @@ features:
3839
priority: true
3940
timers: true
4041
unnumbered: true
42+
routing:
43+
static.discard: true
4144
dhcp: false
4245
initial:
4346
ipv4:

netsim/daemons/bird/routing.j2

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{# Static routes #}
2+
{% macro config_sr(sr_data,af) %}
3+
{% set sr_intf = ' dev "'+sr_data.nexthop.intf+'"' if 'intf' in sr_data.nexthop else '' %}
4+
{% set sr_intf = '' %}
5+
{% set sr_nh = 'unreachable' if 'discard' in sr_data.nexthop else 'via ' + sr_data.nexthop[af] %}
6+
route {{ sr_data[af] }} {{ sr_nh }}{{ sr_intf }};
7+
{% endmacro -%}
8+
{% if routing.static|default([]) %}
9+
#
10+
# Global static routes
11+
#
12+
{% for sr_af in ['ipv4','ipv6'] %}
13+
{% for sr_data in routing.static if sr_af in sr_data and 'vrf' not in sr_data %}
14+
{% if loop.first %}
15+
protocol static {
16+
{{ sr_af }};
17+
check link;
18+
{% endif %}
19+
{{ config_sr(sr_data,sr_af) }}
20+
{% if loop.last %}
21+
}
22+
{% endif %}
23+
{% endfor %}
24+
{% endfor %}
25+
{% endif %}{# static routes #}

netsim/devices/_common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
def check_indirect_static_routes(node: Box) -> None:
99
for sr_entry in node.get('routing.static',[]):
10+
if 'discard' in sr_entry.nexthop:
11+
continue
1012
if 'intf' not in sr_entry.nexthop:
1113
report_quirk(
1214
f'static routes with indirect next hops cannot be used (node {node.name})',

0 commit comments

Comments
 (0)