Skip to content

Commit 005702b

Browse files
judyjosephabdosi
authored andcommitted
[multi-ASIC] util changes with the BGP_INTERNAL_NEIGHBOR table. (#5760)
- Why I did it Update the routine is_bgp_session_internal() by checking the BGP_INTERNAL_NEIGHBOR table. Additionally to address the review comment #5520 (comment) Add timer settings as will in the internal session templates and keep it minimal as these sessions which will always be up. Updates to the internal tests data + add all of it to template tests. - How I did it Updated the APIs and the template files. - How to verify it Verified the internal BGP sessions are displayed correctly with show commands with this API is_bgp_session_internal()
1 parent ce86621 commit 005702b

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
!
44
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
55
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
6+
neighbor {{ neighbor_addr }} timers 3 10
67
!
78
{% if neighbor_addr | ipv4 %}
89
address-family ipv4

src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
!
44
neighbor 10.10.10.10 remote-as 555
55
neighbor 10.10.10.10 description remote_peer
6-
neighbor 10.10.10.10 timers 5 30
7-
neighbor 10.10.10.10 shutdown
6+
neighbor 10.10.10.10 timers 3 10
87
address-family ipv4
98
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4
109
neighbor 10.10.10.10 route-map FROM_BGP_INTERNAL_PEER_V4 in

src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
!
44
neighbor fc::10 remote-as 555
55
neighbor fc::10 description remote_peer
6-
neighbor fc::10 timers 5 30
7-
neighbor fc::10 shutdown
6+
neighbor fc::10 timers 3 10
87
address-family ipv6
98
neighbor fc::10 peer-group INTERNAL_PEER_V6
109
neighbor fc::10 route-map FROM_BGP_INTERNAL_PEER_V6 in

src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
!
44
neighbor 10.10.10.10 remote-as 555
55
neighbor 10.10.10.10 description remote_peer
6-
neighbor 10.10.10.10 timers 5 30
7-
neighbor 10.10.10.10 shutdown
6+
neighbor 10.10.10.10 timers 3 10
87
address-family ipv4
98
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4
109
neighbor 10.10.10.10 next-hop-self force

src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
!
44
neighbor fc::10 remote-as 555
55
neighbor fc::10 description remote_peer
6-
neighbor fc::10 timers 5 30
7-
neighbor fc::10 shutdown
6+
neighbor fc::10 timers 3 10
87
address-family ipv6
98
neighbor fc::10 peer-group INTERNAL_PEER_V6
109
neighbor fc::10 next-hop-self force

src/sonic-bgpcfgd/tests/test_templates.py

+12
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ def test_general_instance():
104104
test_data = load_tests("general", "instance.conf")
105105
run_tests("general_instance", *test_data)
106106

107+
def test_internal_policies():
108+
test_data = load_tests("internal", "policies.conf")
109+
run_tests("internal_policies", *test_data)
110+
111+
def test_internal_pg():
112+
test_data = load_tests("internal", "peer-group.conf")
113+
run_tests("internal_pg", *test_data)
114+
115+
def test_internal_instance():
116+
test_data = load_tests("internal", "instance.conf")
117+
run_tests("internal_instance", *test_data)
118+
107119
def test_dynamic_policies():
108120
test_data = load_tests("dynamic", "policies.conf")
109121
run_tests("dynamic_policies", *test_data)

src/sonic-py-common/sonic_py_common/multi_asic.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
PORT_CHANNEL_CFG_DB_TABLE = 'PORTCHANNEL'
2222
PORT_CFG_DB_TABLE = 'PORT'
2323
BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR'
24+
BGP_INTERNAL_NEIGH_CFG_DB_TABLE = 'BGP_INTERNAL_NEIGHBOR'
2425
NEIGH_DEVICE_METADATA_CFG_DB_TABLE = 'DEVICE_NEIGHBOR_METADATA'
2526
DEFAULT_NAMESPACE = ''
2627
PORT_ROLE = 'role'
@@ -387,20 +388,10 @@ def is_bgp_session_internal(bgp_neigh_ip, namespace=None):
387388
for ns in ns_list:
388389

389390
config_db = connect_config_db_for_ns(ns)
390-
bgp_sessions = config_db.get_table(BGP_NEIGH_CFG_DB_TABLE)
391-
if bgp_neigh_ip not in bgp_sessions:
392-
continue
393-
394-
bgp_neigh_name = bgp_sessions[bgp_neigh_ip]['name']
395-
neighbor_metadata = config_db.get_table(
396-
NEIGH_DEVICE_METADATA_CFG_DB_TABLE)
397-
398-
if ((neighbor_metadata) and
399-
(neighbor_metadata[bgp_neigh_name]['type'].lower() ==
400-
ASIC_NAME_PREFIX)):
391+
bgp_sessions = config_db.get_table(BGP_INTERNAL_NEIGH_CFG_DB_TABLE)
392+
if bgp_neigh_ip in bgp_sessions:
401393
return True
402-
else:
403-
return False
394+
404395
return False
405396

406397
def get_front_end_namespaces():

0 commit comments

Comments
 (0)