Skip to content

Commit 8bc6b55

Browse files
taoyl-mslguohan
authored andcommitted
[bgpd.conf] Fix template issue with multiple lo addresses (#1060)
1 parent bdbede5 commit 8bc6b55

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

dockers/docker-fpm-quagga/bgpd.conf.j2

+8-5
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
3232
bgp graceful-restart
3333
{% endif %}
3434
{% for (name, prefix) in LOOPBACK_INTERFACE %}
35-
{# TODO: use v4 lo for backward compatibility, will revisit the case with multiple lo interfaces #}
36-
{% if prefix | ipv4 %}
35+
{% if prefix | ipv4 and name == 'Loopback0' %}
3736
bgp router-id {{ prefix | ip }}
3837
{% endif %}
3938
{% endfor %}
4039
{# advertise loopback #}
4140
{% for (name, prefix) in LOOPBACK_INTERFACE %}
42-
{% if prefix | ipv4 %}
41+
{% if prefix | ipv4 and name == 'Loopback0' %}
4342
network {{ prefix | ip }}/32
44-
{% elif prefix | ipv6 %}
43+
{% elif prefix | ipv6 and name == 'Loopback0' %}
4544
address-family ipv6
4645
network {{ prefix | ip }}/64
4746
exit-address-family
@@ -97,7 +96,11 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
9796
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
9897
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
9998
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
100-
neighbor {{ bgp_peer['name'] }} update-source Loopback0
99+
{% for (name, prefix) in LOOPBACK_INTERFACE %}
100+
{% if name == 'Loopback1' %}
101+
neighbor {{ bgp_peer['name'] }} update-source {{ prefix | ip }}
102+
{% endif %}
103+
{% endfor %}
101104
neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in
102105
neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out
103106
{% for ip_range in bgp_peer['ip_range'] %}

src/sonic-config-engine/minigraph.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def parse_cpg(cpg, hname):
274274
bgp_session = bgp_sessions[peer]
275275
if hostname == bgp_session['name']:
276276
bgp_session['asn'] = asn
277-
277+
bgp_sessions = { key: bgp_sessions[key] for key in bgp_sessions if bgp_sessions[key].has_key('asn') and int(bgp_sessions[key]['asn']) != 0 }
278278
return bgp_sessions, myasn, bgp_peers_with_range
279279

280280

0 commit comments

Comments
 (0)