-
Notifications
You must be signed in to change notification settings - Fork 105
Feature: bird vrf support including bgp, ospf and route leaking #3498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
3c2dd55
Add BIRD VRF support
jbemmel eb856f8
Fix BIRD VRF OSPF router IDs
jbemmel e90f047
Fix BIRD VRF mixed redistribution
jbemmel 5333171
Add BIRD VRF route leaking
jbemmel 50f44c5
Fix BIRD VRF OSPF route leaking
jbemmel 5e56910
Use VRF names in BIRD VRF objects
jbemmel 17fc1f9
Advertise BIRD static VRF support
jbemmel 5c122dc
Use VRF names in BIRD routing protocols
jbemmel 3c053ec
Document BIRD VRF feature support
jbemmel c6d6e9d
Support BIRD VRF BGP imports
jbemmel 12eb5e6
Fix BIRD VRF BGP router IDs
jbemmel 6ca1ebd
Rename BIRD VRF template for config mapping.
jbemmel 0f1d5bc
Split BIRD containerlab config markers.
jbemmel 2589b36
Update BIRD daemon VRF config mapping.
jbemmel 224bd77
Handle BIRD config suffix during cleanup.
jbemmel 90a7e6f
Run BIRD VRF dataplane template in container.
jbemmel 5fee997
Share VRF setup template between FRR and BIRD.
jbemmel 2739d69
Move BIRD VRF protocol rendering into VRF config.
jbemmel 49c62ee
Remove unused BIRD initial marker.
jbemmel e079c6b
Align daemon config cleanup comment.
jbemmel 0826a30
Keep BIRD OSPF macro instance-only.
jbemmel 365c397
Use selected interface for BIRD BGP local address.
jbemmel 3f7e3fe
Split BIRD protocol macros into templates.
jbemmel fbafbf3
Document BIRD VRF template macros.
jbemmel 9e2cba8
Inline BIRD VRF BGP rendering.
jbemmel 1ce59db
Restore dev versions after rebase.
jbemmel cb49ff9
Update BIRD daemon VRF handling.
jbemmel e0db20c
Remove BIRD EVPN bridge patch.
jbemmel e7681d2
Cleanup shell config templates
ipspace a1136c2
Fix: Use /-based path in sysctl
ipspace 9b74343
Fix: Use shared static route config in VRF and Routing
ipspace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| #!/bin/sh | ||
| #!/bin/bash | ||
| # | ||
| set -e | ||
| # | ||
| # Placeholder: VRF data-plane configuration for BIRD | ||
| {% if vrfs is defined %} | ||
| {% include "frr.data-plane.j2" +%} | ||
| {% endif %} | ||
| # | ||
| touch /var/run/vrf.done | ||
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Create VRF tables | ||
| {% set _vrfs = vrfs|default({}) %} | ||
| {% for vname,vdata in _vrfs.items() %} | ||
| if [ ! -e /sys/devices/virtual/net/{{vname}} ]; then | ||
| ip link add {{vname}} type vrf table {{ vdata.vrfidx }} | ||
| fi | ||
| ip link set {{vname}} up | ||
| {% endfor %} | ||
|
|
||
| # Move interfaces and loopbacks to vrfs | ||
| {% for i in interfaces if i.vrf is defined %} | ||
| sysctl -qw net/ipv6/conf/{{ i.ifname }}/keep_addr_on_down=1 | ||
| ip link set {{ i.ifname }} master {{ i.vrf }} | ||
| {% endfor %} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,8 @@ | ||
| #!/bin/bash | ||
| # | ||
| set -e # Exit immediately when any command fails | ||
| set -e | ||
| # | ||
|
|
||
| # Create VRF tables | ||
| {% set _vrfs = vrfs|default({}) %} | ||
| {% for vname,vdata in _vrfs.items() %} | ||
| if [ ! -e /sys/devices/virtual/net/{{vname}} ]; then | ||
| ip link add {{vname}} type vrf table {{ vdata.vrfidx }} | ||
| fi | ||
| ip link set {{vname}} up | ||
| {% endfor %} | ||
|
|
||
| # Move interfaces and loopbacks to vrfs | ||
| {% for i in interfaces if i.vrf is defined %} | ||
| sysctl -qw net.ipv6.conf.{{ i.ifname }}.keep_addr_on_down=1 | ||
| ip link set {{ i.ifname }} master {{ i.vrf }} | ||
| {% endfor %} | ||
|
|
||
| {% if _vrfs %} | ||
| {% if vrfs is defined %} | ||
| {% include "frr.data-plane.j2" +%} | ||
| {% include "frr.frr-config.j2" +%} | ||
| {% endif %} | ||
| exit $? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,154 +1,12 @@ | ||
| {% import 'bgp.macros.j2' as bgp_config with context %} | ||
|
|
||
| {% if 'router_id' in bgp %} | ||
| router id {{ bgp.router_id }}; | ||
| {% endif %} | ||
|
|
||
| {% for ngb in bgp.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; | ||
| } | ||
| {% endfor %} | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% for pfx_af in ['ipv4','ipv6'] %} | ||
| {% for pfx in bgp.advertise|default([]) if pfx_af in pfx %} | ||
| {% if loop.first %} | ||
|
|
||
| define bgp_advertise_{{ pfx_af }} = [ | ||
| {% endif %} | ||
| {{ pfx[pfx_af] }}{% if not loop.last %},{% endif +%} | ||
| {% if loop.last %} | ||
| ]; | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endfor %} | ||
| function bgp_prefixes( bool originate_default ) { | ||
| if net.len = 0 && !originate_default | ||
| then reject "Don't originate default route"; | ||
|
|
||
| if source ~ [ RTS_BGP ] | ||
| then accept "BGP route:", net; | ||
|
|
||
| if proto ~ "static_bgp_default*" | ||
| then accept "BGP prefix origination:", net; | ||
|
|
||
| {% if bgp.import is defined %} | ||
| {% for proto in bgp.import %} | ||
| if source ~ [ {{ netlab_import_map[proto] }} ] | ||
| then accept "{{ proto }} route:", net; | ||
| {% endfor %} | ||
| {% endif %} | ||
| {% for pfx_af in ['ipv4','ipv6'] %} | ||
| {% for pfx in bgp.advertise|default([]) if pfx_af in pfx %} | ||
| {% if loop.first %} | ||
|
|
||
| if net ~ bgp_advertise_{{ pfx_af }} then accept "advertise prefix:", net; | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endfor %} | ||
|
|
||
| reject "not accepted:", net, " source=", source, " preference=", preference, " proto=", proto; | ||
| } | ||
|
|
||
| function remove_private_as() { | ||
| bgp_path.delete([64512..65534, 4200000000..4294967294]); | ||
| } | ||
|
|
||
| {# | ||
| Build a BGP export filter per neighbor type, to filter communities | ||
| #} | ||
| {% for ntype in [ 'ebgp', 'ibgp', 'localas_ibgp', 'confed_ebgp' ] %} | ||
| function bgp_export_{{ ntype }}( bool originate_default; bool rem_private_as ) { | ||
| {% set list = bgp.community[ntype]|default([]) %} | ||
| {% if 'standard' not in list %} | ||
| bgp_community.empty; | ||
| {% endif %} | ||
| {% if 'large' not in list %} | ||
| bgp_large_community.empty; | ||
| {% endif %} | ||
| {% if 'extended' not in list %} | ||
| bgp_ext_community.empty; | ||
| {% endif %} | ||
|
|
||
| if rem_private_as then remove_private_as(); | ||
| bgp_prefixes(originate_default); | ||
| } | ||
| {% endfor %} | ||
|
|
||
| {% for n in bgp.neighbors %} | ||
| {% for af in [ 'ipv4','ipv6' ] if af in n and n[af] is string %} | ||
| protocol bgp bgp_{{ n.name }}_{{ af }} { | ||
| {% set loopback = loopback|default({}) %} | ||
| {% set local_ip = loopback[af]|default('') %} | ||
| local {{ local_ip.split('/')[0] if n.type == 'ibgp' else '' }} as {{ n.local_as|default(bgp.as) }}; | ||
| {% if bgp.confederation is defined %} | ||
| confederation {{ bgp.confederation.as }}; | ||
| {% if n.type == 'confed_ebgp' %} | ||
| confederation member yes; | ||
| {% endif %} | ||
| {% endif %} | ||
| neighbor {{ n[af] }} as {{ n['as'] }}; | ||
| connect retry time 5; | ||
| error wait time 5,10; | ||
| startup hold time 10; | ||
| {% if n.local_if is defined %} | ||
| interface "{{ n.local_if }}"; | ||
| {% endif %} | ||
| {% if n.bfd is defined %} | ||
| bfd yes; | ||
| {% endif %} | ||
| {% if n.passive is defined %} | ||
| passive yes; | ||
| {% endif %} | ||
| {% if n.timers is defined %} | ||
| hold time {{ n.timers.hold|default(180) }}; | ||
| keepalive time {{ n.timers.keepalive|default(60) }}; | ||
| {% endif %} | ||
| {% if n.password is defined %} | ||
| password "{{ n.password }}"; | ||
| {% endif %} | ||
| {% if n.rs|default(False) %} | ||
| rs client; | ||
| {% endif %} | ||
| {% if n.rs_client|default(False) %} | ||
| enforce first as off; | ||
| {% endif %} | ||
| {% if n.role is defined %} | ||
| local role {{ n.role.name|replace('-', '_') }}; | ||
| {% if n.role.strict|default(False) %} | ||
| require roles; | ||
| {% endif %} | ||
| {% endif %} | ||
| {% if bgp.rr|default('') and ((not n.rr|default('') and n.type == 'ibgp') or n.type == 'localas_ibgp') %} | ||
| rr client; | ||
| {% if bgp.rr|default(False) and bgp.rr_cluster_id|default(False) %} | ||
| rr cluster id {{ bgp.rr_cluster_id }}; | ||
| {% endif %} | ||
| {% endif %} | ||
| {% if n.gtsm is defined %} | ||
| ttl security on; | ||
| {% if n.type=='ibgp' %} | ||
| multihop {{ n.gtsm }}; | ||
| {% endif %} | ||
| {% endif %} | ||
| {% for _af in [ 'ipv4','ipv6' ] if _af==af or (_af=='ipv4' and n.ipv4_rfc8950|default(False)) %} | ||
| {% if _af in n.activate and n.activate[_af] %} | ||
| {{ _af }} { | ||
| import all; | ||
| export filter { bgp_export_{{ n.type }}( {{ 'true' if n.get('default_originate') else 'false' }}, | ||
| {{ 'true' if n.get('remove_private_as') else 'false' }}); }; | ||
| {% if n.next_hop_self|default(false) %} | ||
| next hop self {{ 'on' if n.next_hop_self == 'all' else 'ebgp' }}; | ||
| {% endif %} | ||
| {% if _af=='ipv4' and n.ipv4_rfc8950|default(False) %} | ||
| extended next hop on; | ||
| # require extended next hop on; | ||
| {% endif %} | ||
| }; | ||
| {% endif %} | ||
| {% endfor %} | ||
| } | ||
| {% endfor %} | ||
| {{ bgp_config.bgp_default_originate_routes(bgp) }} | ||
| {{ 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') }} | ||
| {% for n in bgp.neighbors|default([]) %} | ||
| {{ bgp_config.bgp_session(n,bgp,'',{},netlab_interfaces) }} | ||
| {% endfor %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar issue in
netlab/netsim/ansible/templates/vlan/frr.j2
Line 27 in cfd0fae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a problem (not saying it should not be fixed) because SVI interface names don't have dots in them.