From 215319973ac9216e96ded0b9cadf159e45b9f39c Mon Sep 17 00:00:00 2001 From: Judy Joseph Date: Fri, 30 Oct 2020 14:06:21 -0700 Subject: [PATCH 1/3] Follow up on util changes with the BGP_INTERNAL_NEIGHBOR table. --- .../bgpd/templates/internal/instance.conf.j2 | 5 +++++ .../sonic_py_common/multi_asic.py | 17 ++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2 index 49497e4fcaaa..a33425339722 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2 @@ -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") }} +{% endif %} ! {% if neighbor_addr | ipv4 %} address-family ipv4 diff --git a/src/sonic-py-common/sonic_py_common/multi_asic.py b/src/sonic-py-common/sonic_py_common/multi_asic.py index cb80635dbc0a..a1c68367fa55 100644 --- a/src/sonic-py-common/sonic_py_common/multi_asic.py +++ b/src/sonic-py-common/sonic_py_common/multi_asic.py @@ -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' @@ -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(): From e6bc380482421133dd63213d24ad2c4a22173cca Mon Sep 17 00:00:00 2001 From: Judy Joseph Date: Fri, 30 Oct 2020 22:37:04 -0700 Subject: [PATCH 2/3] Updates to the internal tests data + add all of it to template tests. --- .../data/internal/instance.conf/result_back_v4.conf | 1 - .../data/internal/instance.conf/result_back_v6.conf | 1 - .../data/internal/instance.conf/result_front_v4.conf | 1 - .../data/internal/instance.conf/result_front_v6.conf | 1 - src/sonic-bgpcfgd/tests/test_templates.py | 12 ++++++++++++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf index 4664395bbf27..2bfea3bd5116 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf @@ -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 diff --git a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf index 08cffe632815..3c3f522325fb 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf @@ -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 diff --git a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf index aba5cfac0b1f..5c3b84eb0b94 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf @@ -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 diff --git a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf index 362900d57403..33e8c8d382a2 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf @@ -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 diff --git a/src/sonic-bgpcfgd/tests/test_templates.py b/src/sonic-bgpcfgd/tests/test_templates.py index f5f5f2155253..9904e7adce4f 100644 --- a/src/sonic-bgpcfgd/tests/test_templates.py +++ b/src/sonic-bgpcfgd/tests/test_templates.py @@ -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) From 9def6c52a633767e39b0be7d8e2dea95b3935ae6 Mon Sep 17 00:00:00 2001 From: Judy Joseph Date: Wed, 4 Nov 2020 14:33:47 -0800 Subject: [PATCH 3/3] Updates based on the review comments to keep the timers minimal. This is because these are internal sessions which will allways be up. --- .../frr/bgpd/templates/internal/instance.conf.j2 | 6 +----- .../tests/data/internal/instance.conf/result_back_v4.conf | 2 +- .../tests/data/internal/instance.conf/result_back_v6.conf | 2 +- .../tests/data/internal/instance.conf/result_front_v4.conf | 2 +- .../tests/data/internal/instance.conf/result_front_v6.conf | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2 index a33425339722..baa51cf35041 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/templates/internal/instance.conf.j2 @@ -3,11 +3,7 @@ ! 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") }} -{% endif %} + neighbor {{ neighbor_addr }} timers 3 10 ! {% if neighbor_addr | ipv4 %} address-family ipv4 diff --git a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf index 2bfea3bd5116..9cf5e3d13c4a 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v4.conf @@ -3,7 +3,7 @@ ! 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 timers 3 10 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 diff --git a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf index 3c3f522325fb..41aa2ae7f800 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_back_v6.conf @@ -3,7 +3,7 @@ ! neighbor fc::10 remote-as 555 neighbor fc::10 description remote_peer - neighbor fc::10 timers 5 30 + neighbor fc::10 timers 3 10 address-family ipv6 neighbor fc::10 peer-group INTERNAL_PEER_V6 neighbor fc::10 route-map FROM_BGP_INTERNAL_PEER_V6 in diff --git a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf index 5c3b84eb0b94..c327e417f0f6 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v4.conf @@ -3,7 +3,7 @@ ! 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 timers 3 10 address-family ipv4 neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4 neighbor 10.10.10.10 next-hop-self force diff --git a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf index 33e8c8d382a2..c73003823375 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/instance.conf/result_front_v6.conf @@ -3,7 +3,7 @@ ! neighbor fc::10 remote-as 555 neighbor fc::10 description remote_peer - neighbor fc::10 timers 5 30 + neighbor fc::10 timers 3 10 address-family ipv6 neighbor fc::10 peer-group INTERNAL_PEER_V6 neighbor fc::10 next-hop-self force