Skip to content
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

Support for nhopself, keepalive and holdtime timers, prefer global ebgp nexthop and fix python warning. #1024

Merged
merged 14 commits into from
Oct 11, 2017
Merged
13 changes: 13 additions & 0 deletions dockers/docker-fpm-frr/bgpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% if bgp_session['asn'] | int != 0 %}
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
neighbor {{ neighbor_addr }} timers {{ bgp_session['keepalive'] }} {{ bgp_session['holdtime'] }}
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
neighbor {{ neighbor_addr }} allowas-in 1
{% endif %}
Expand All @@ -59,6 +60,9 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
neighbor {{ neighbor_addr }} activate
{% if bgp_session['rrclient'] | int != 0 %}
neighbor {{ neighbor_addr }} route-reflector-client
{% endif %}
{% if bgp_session['nhopself'] | int != 0 %}
neighbor {{ neighbor_addr }} next-hop-self
{% endif %}
maximum-paths 64
exit-address-family
Expand All @@ -68,6 +72,12 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
neighbor {{ neighbor_addr }} activate
{% if bgp_session['rrclient'] | int != 0 %}
neighbor {{ neighbor_addr }} route-reflector-client
{% endif %}
{% if bgp_session['nhopself'] | int != 0 %}
neighbor {{ neighbor_addr }} next-hop-self
{% endif %}
{% if bgp_session['asn'] != DEVICE_METADATA['localhost']['bgp_asn'] %}
neighbor {{ neighbor_addr }} route-map set-next-hop-global-v6 in
{% endif %}
maximum-paths 64
exit-address-family
Expand All @@ -81,3 +91,6 @@ maximum-paths 64
route-map ISOLATE permit 10
set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
!
route-map set-next-hop-global-v6 permit 10
set ipv6 next-hop prefer-global
!
33 changes: 26 additions & 7 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,44 @@ def parse_cpg(cpg, hname):
start_peer = session.find(str(QName(ns, "StartPeer"))).text
end_router = session.find(str(QName(ns, "EndRouter"))).text
end_peer = session.find(str(QName(ns, "EndPeer"))).text
if session.find(str(QName(ns, "RRClient"))) is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using one line python assignment statements?

rrclient = 1
else:
rrclient = 0
if session.find(str(QName(ns, "HoldTime"))) is not None:
holdtime = session.find(str(QName(ns, "HoldTime"))).text
else:
holdtime = 180
if session.find(str(QName(ns, "KeepAliveTime"))) is not None:
keepalive = session.find(str(QName(ns, "KeepAliveTime"))).text
else:
keepalive = 60
if session.find(str(QName(ns, "NextHopSelf"))) is not None:
nhopself = 1
else:
nhopself = 0
if end_router == hname:
bgp_sessions[start_peer] = {
'name': start_router,
'local_addr': end_peer
'local_addr': end_peer,
'rrclient': rrclient,
'holdtime': holdtime,
'keepalive': keepalive,
'nhopself': nhopself
}
else:
bgp_sessions[end_peer] = {
'name': end_router,
'local_addr': start_peer
'local_addr': start_peer,
'rrclient': rrclient,
'holdtime': holdtime,
'keepalive': keepalive,
'nhopself': nhopself
}
elif child.tag == str(QName(ns, "Routers")):
for router in child.findall(str(QName(ns1, "BGPRouterDeclaration"))):
asn = router.find(str(QName(ns1, "ASN"))).text
hostname = router.find(str(QName(ns1, "Hostname"))).text
if router.find(str(QName(ns1, "RRClient"))):
rrclient = '1'
else:
rrclient = '0'
if hostname == hname:
myasn = asn
peers = router.find(str(QName(ns1, "Peers")))
Expand All @@ -252,7 +272,6 @@ def parse_cpg(cpg, hname):
bgp_session = bgp_sessions[peer]
if hostname == bgp_session['name']:
bgp_session['asn'] = asn
bgp_session['rrclient'] = rrclient

return bgp_sessions, myasn, bgp_peers_with_range

Expand Down