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

[multi-ASIC] util changes with the BGP_INTERNAL_NEIGHBOR table. #5760

Merged
merged 3 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
!
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
{# set the bgp neighbor timers if they have not default values #}
{% if (bgp_session['keepalive'] is defined and bgp_session['keepalive'] | int != 60)
or (bgp_session['holdtime'] is defined and bgp_session['holdtime'] | int != 180) %}
neighbor {{ neighbor_addr }} timers {{ bgp_session['keepalive'] | default("60") }} {{ bgp_session['holdtime'] | default("180") }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to use minimal timers here. We expect this sessions are live 100% of time

{% endif %}
!
{% if neighbor_addr | ipv4 %}
address-family ipv4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description remote_peer
neighbor 10.10.10.10 timers 5 30
neighbor 10.10.10.10 shutdown
address-family ipv4
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4
neighbor 10.10.10.10 route-map FROM_BGP_INTERNAL_PEER_V4 in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
neighbor fc::10 remote-as 555
neighbor fc::10 description remote_peer
neighbor fc::10 timers 5 30
neighbor fc::10 shutdown
address-family ipv6
neighbor fc::10 peer-group INTERNAL_PEER_V6
neighbor fc::10 route-map FROM_BGP_INTERNAL_PEER_V6 in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description remote_peer
neighbor 10.10.10.10 timers 5 30
neighbor 10.10.10.10 shutdown
address-family ipv4
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4
neighbor 10.10.10.10 next-hop-self force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
neighbor fc::10 remote-as 555
neighbor fc::10 description remote_peer
neighbor fc::10 timers 5 30
neighbor fc::10 shutdown
address-family ipv6
neighbor fc::10 peer-group INTERNAL_PEER_V6
neighbor fc::10 next-hop-self force
Expand Down
12 changes: 12 additions & 0 deletions src/sonic-bgpcfgd/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ def test_general_instance():
test_data = load_tests("general", "instance.conf")
run_tests("general_instance", *test_data)

def test_internal_policies():
test_data = load_tests("internal", "policies.conf")
run_tests("internal_policies", *test_data)

def test_internal_pg():
test_data = load_tests("internal", "peer-group.conf")
run_tests("internal_pg", *test_data)

def test_internal_instance():
test_data = load_tests("internal", "instance.conf")
run_tests("internal_instance", *test_data)

def test_dynamic_policies():
test_data = load_tests("dynamic", "policies.conf")
run_tests("dynamic_policies", *test_data)
Expand Down
17 changes: 4 additions & 13 deletions src/sonic-py-common/sonic_py_common/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
PORT_CHANNEL_CFG_DB_TABLE = 'PORTCHANNEL'
PORT_CFG_DB_TABLE = 'PORT'
BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR'
BGP_INTERNAL_NEIGH_CFG_DB_TABLE = 'BGP_INTERNAL_NEIGHBOR'
NEIGH_DEVICE_METADATA_CFG_DB_TABLE = 'DEVICE_NEIGHBOR_METADATA'
DEFAULT_NAMESPACE = ''
PORT_ROLE = 'role'
Expand Down Expand Up @@ -332,20 +333,10 @@ def is_bgp_session_internal(bgp_neigh_ip, namespace=None):
for ns in ns_list:

config_db = connect_config_db_for_ns(ns)
bgp_sessions = config_db.get_table(BGP_NEIGH_CFG_DB_TABLE)
if bgp_neigh_ip not in bgp_sessions:
continue

bgp_neigh_name = bgp_sessions[bgp_neigh_ip]['name']
neighbor_metadata = config_db.get_table(
NEIGH_DEVICE_METADATA_CFG_DB_TABLE)

if ((neighbor_metadata) and
(neighbor_metadata[bgp_neigh_name]['type'].lower() ==
ASIC_NAME_PREFIX)):
bgp_sessions = config_db.get_table(BGP_INTERNAL_NEIGH_CFG_DB_TABLE)
if bgp_neigh_ip in bgp_sessions:
return True
else:
return False

return False

def get_front_end_namespaces():
Expand Down