Skip to content

Commit

Permalink
[bgpd]: support multiple peer range in single peer group (#807)
Browse files Browse the repository at this point in the history
  • Loading branch information
sihuihan88 authored and lguohan committed Jul 13, 2017
1 parent f49cac0 commit 1176508
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dockers/docker-fpm-quagga/bgpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ router bgp {{ minigraph_bgp_asn }}
neighbor {{ bgp_peer['name'] }} update-source Loopback0
neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in
neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out
bgp listen range {{ bgp_peer['ip_range'] }} peer-group {{ bgp_peer['name'] }}
{% for ip_range in bgp_peer['ip_range'] %}
bgp listen range {{ip_range}} peer-group {{ bgp_peer['name'] }}
{% endfor %}
{% endfor %}
{% endblock bgp_peers_with_range %}
!
Expand Down
3 changes: 2 additions & 1 deletion src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ def parse_cpg(cpg, hname):
if bgpPeer.find(str(QName(ns1, "PeersRange"))) is not None:
name = bgpPeer.find(str(QName(ns1, "Name"))).text
ip_range = bgpPeer.find(str(QName(ns1, "PeersRange"))).text
ip_range_group = ip_range.split(';') if ip_range and ip_range != "" else []
bgp_peers_with_range.append({
'name': name,
'ip_range': ip_range
'ip_range': ip_range_group
})
else:
for bgp_session in bgp_sessions:
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/t0-sample-bgp-speaker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<BGPPeer>
<Address>10.1.0.32</Address>
<a:Name>BGPSLBPassive</a:Name>
<a:PeersRange>10.10.10.10/26</a:PeersRange>
<a:PeersRange>10.10.10.10/26;100.100.100.100/26</a:PeersRange>
</BGPPeer>
</a:Peers>
<a:RouteMaps/>
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_minigraph_neighbors(self):
def test_minigraph_peers_with_range(self):
argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v minigraph_bgp_peers_with_range'
output = self.run_script(argument)
self.assertEqual(output.strip(), "[{'name': 'BGPSLBPassive', 'ip_range': '10.10.10.10/26'}]")
self.assertEqual(output.strip(), "[{'name': 'BGPSLBPassive', 'ip_range': ['10.10.10.10/26', '100.100.100.100/26']}]")

def test_minigraph_deployment_id(self):
argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v deployment_id'
Expand Down

0 comments on commit 1176508

Please sign in to comment.