From 602369126ce57045c882e84dddd437b7c19e0fdd Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Wed, 10 Apr 2019 21:50:36 -0700 Subject: [PATCH] [docker-fpm-quagga]: Add support for PeerAsn and UpdateAddress (#2766) --- dockers/docker-fpm-quagga/bgpd.conf.j2 | 8 ++++++++ src/sonic-config-engine/minigraph.py | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dockers/docker-fpm-quagga/bgpd.conf.j2 b/dockers/docker-fpm-quagga/bgpd.conf.j2 index 2d9d03e73f..4879736437 100644 --- a/dockers/docker-fpm-quagga/bgpd.conf.j2 +++ b/dockers/docker-fpm-quagga/bgpd.conf.j2 @@ -98,14 +98,22 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} {% for bgp_peer in BGP_PEER_RANGE.values() %} neighbor {{ bgp_peer['name'] }} peer-group neighbor {{ bgp_peer['name'] }} passive +{% if bgp_peer['peer_asn'] is defined %} + neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }} +{% else %} neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }} +{% endif %} neighbor {{ bgp_peer['name'] }} ebgp-multihop 255 neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound +{% if bgp_peer['src_address'] is defined %} + neighbor {{ bgp_peer['name'] }} update-source {{ bgp_peer['src_address'] | ip }} +{% else %} {% for (name, prefix) in LOOPBACK_INTERFACE %} {% if name == 'Loopback1' %} neighbor {{ bgp_peer['name'] }} update-source {{ prefix | ip }} {% endif %} {% endfor %} +{% endif %} neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out {% for ip_range in bgp_peer['ip_range'] %} diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index d57d9daca4..6553055b84 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -336,7 +336,7 @@ def parse_cpg(cpg, hname): peers = router.find(str(QName(ns1, "Peers"))) for bgpPeer in peers.findall(str(QName(ns, "BGPPeer"))): addr = bgpPeer.find(str(QName(ns, "Address"))).text - if bgpPeer.find(str(QName(ns1, "PeersRange"))) is not None: + if bgpPeer.find(str(QName(ns1, "PeersRange"))) is not None: # FIXME: is better to check for type BGPPeerPassive 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 [] @@ -344,6 +344,10 @@ def parse_cpg(cpg, hname): 'name': name, 'ip_range': ip_range_group } + if bgpPeer.find(str(QName(ns1, "Address"))) is not None: + bgp_peers_with_range[name]['src_address'] = bgpPeer.find(str(QName(ns1, "Address"))).text + if bgpPeer.find(str(QName(ns1, "PeerAsn"))) is not None: + bgp_peers_with_range[name]['peer_asn'] = bgpPeer.find(str(QName(ns1, "PeerAsn"))).text else: for peer in bgp_sessions: bgp_session = bgp_sessions[peer]