Skip to content

BGP "Allow list" feature implementation #4563

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

Closed
Closed
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
758 changes: 747 additions & 11 deletions dockers/docker-fpm-quagga/bgpcfgd

Large diffs are not rendered by default.

39 changes: 36 additions & 3 deletions dockers/docker-fpm-quagga/bgpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
exit-address-family
{% endif %}
{% endfor %}
maximum-paths 64
{% endblock bgp_init %}
{% endif %}
{% block vlan_advertisement %}
Expand Down Expand Up @@ -126,9 +127,41 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% endblock bgp_monitors %}
!
{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %}
maximum-paths 64
!
route-map ISOLATE permit 10
set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
!
{% endif %}
!
{% if allow_list_enabled %}
route-map FROM_PEER_V4 permit 1
call ALLOW_LIST_V4
on-match next
!
{% endif %}
route-map FROM_PEER_V4 permit 10
!
{% if allow_list_enabled %}
route-map FROM_PEER_V6 permit 1
call ALLOW_LIST_V6
on-match next
!
{% endif %}
route-map FROM_PEER_V6 permit 10
!
{% if allow_list_enabled %}
route-map ALLOW_LIST_V4 {{ allow_list_default_action }} 65535
{% if allow_list_default_action.strip() == 'permit' %}
set community {{ allow_list_drop_prefix }} additive
{% endif %}
!
route-map ALLOW_LIST_V6 {{ allow_list_default_action }} 65535
{% if allow_list_default_action.strip() == 'permit' %}
set community {{ allow_list_drop_prefix }} additive
{% endif %}
!
ip prefix-list ALLOW_ADDRESS_ALLOW_ALL_V4 seq 10 permit any
!
ipv6 prefix-list ALLOW_ADDRESS_ALLOW_ALL_V6 seq 10 permit any
!
{% endif %}
!
2 changes: 2 additions & 0 deletions dockers/docker-fpm-quagga/bgpd.peer.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{% endif %}
neighbor {{ neighbor_addr }} activate
neighbor {{ neighbor_addr }} soft-reconfiguration inbound
neighbor {{ neighbor_addr }} route-map FROM_PEER_V4 in
maximum-paths 64
exit-address-family
{% endif %}
Expand All @@ -27,6 +28,7 @@
{% endif %}
neighbor {{ neighbor_addr }} activate
neighbor {{ neighbor_addr }} soft-reconfiguration inbound
neighbor {{ neighbor_addr }} route-map FROM_PEER_V6 in
maximum-paths 64
exit-address-family
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions files/image_config/asn/deployment_id_asn_map.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
deployment_id_asn_map:
"1" : 65432

allow_list_enabled: true
allow_list_default_action: permit # or deny
allow_list_drop_prefix: 5060:12345 # value of the community to identify a prefix to drop. Make sense only with allow_list_default_action equal to 'permit'
29 changes: 26 additions & 3 deletions src/sonic-config-engine/tests/sample_output/bgpd_quagga.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ router bgp 65100
address-family ipv6
network fc00:1::32/64
exit-address-family
maximum-paths 64
network 192.168.0.1/27
neighbor BGPMON peer-group
neighbor BGPMON activate
Expand All @@ -47,8 +48,30 @@ router bgp 65100
neighbor 10.20.30.40 activate
exit-address-family
!
maximum-paths 64
!
route-map ISOLATE permit 10
set as-path prepend 65100
set as-path prepend 65100
!
!
route-map FROM_PEER_V4 permit 1
call ALLOW_LIST_V4
on-match next
!
route-map FROM_PEER_V4 permit 10
!
route-map FROM_PEER_V6 permit 1
call ALLOW_LIST_V6
on-match next
!
route-map FROM_PEER_V6 permit 10
!
route-map ALLOW_LIST_V4 permit 65535
set community 5060:12345 additive
!
route-map ALLOW_LIST_V6 permit 65535
set community 5060:12345 additive
!
ip prefix-list ALLOW_ADDRESS_ALLOW_ALL_V4 seq 10 permit any
!
ipv6 prefix-list ALLOW_ADDRESS_ALLOW_ALL_V6 seq 10 permit any
!
!
3 changes: 2 additions & 1 deletion src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def setUp(self):
self.t1_mlnx_minigraph = os.path.join(self.test_dir, 't1-sample-graph-mlnx.xml')
self.mlnx_port_config = os.path.join(self.test_dir, 'sample-port-config-mlnx.ini')
self.dell6100_t0_minigraph = os.path.join(self.test_dir, 'sample-dell-6100-t0-minigraph.xml')
self.deployment_id = os.path.join(self.test_dir, "../../../files/image_config/asn/deployment_id_asn_map.yml")
self.arista7050_t0_minigraph = os.path.join(self.test_dir, 'sample-arista-7050-t0-minigraph.xml')
self.output_file = os.path.join(self.test_dir, 'output')

Expand Down Expand Up @@ -60,7 +61,7 @@ def test_lldp(self):

def test_bgpd_quagga(self):
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'bgpd.conf.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + conf_template + ' > ' + self.output_file
argument = '-y ' + self.deployment_id + ' -m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + conf_template + ' > ' + self.output_file
self.run_script(argument)
original_filename = os.path.join(self.test_dir, 'sample_output', 'bgpd_quagga.conf')
r = filecmp.cmp(original_filename, self.output_file)
Expand Down