From f21f91a99917ce0c36a47f1f17b102e6de29e9ef Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:44:12 -0700 Subject: [PATCH 01/10] Update values_store.cpp --- tlm_teamd/values_store.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tlm_teamd/values_store.cpp b/tlm_teamd/values_store.cpp index f883d22fd3..a955d36be7 100644 --- a/tlm_teamd/values_store.cpp +++ b/tlm_teamd/values_store.cpp @@ -366,7 +366,13 @@ void ValuesStore::update(const std::vector & dumps) { const auto & storage = from_json(dumps); const auto & old_keys = get_old_keys(storage); - remove_keys_db(old_keys); + // Do not delete te key from State Db. State DB LAB_TABLE entry is created/deleted + // from teamsyncd on detecting netlink of teamd dev as up/down. For some reason + // if we do not get state dump from teamdctl it might be transient issue. If it is + // persistent issue then teamsyncd might be able to catch it and delete state db entry + // or we can keep entry in it's current state as best effort. Similar to try_add_lag which is best effort + // to connect to teamdctl and if it fails we do not delete State Db entry. + //remove_keys_db(old_keys); remove_keys_storage(old_keys); const auto & keys_to_refresh = update_storage(storage); update_db(storage, keys_to_refresh); From f609c8da8c08b36008507d9050bafa5a09b9e0ee Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:49:32 -0700 Subject: [PATCH 02/10] Update values_store.cpp --- tlm_teamd/values_store.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tlm_teamd/values_store.cpp b/tlm_teamd/values_store.cpp index a955d36be7..957194b4c5 100644 --- a/tlm_teamd/values_store.cpp +++ b/tlm_teamd/values_store.cpp @@ -281,6 +281,14 @@ void ValuesStore::remove_keys_db(const std::vector & keys) const auto & p = split_key(key); const auto & table_name = p.first; const auto & table_key = p.second; + // Do not delete te key from State Db for table LAB_TABLE. LAB_TABLE entry is created/deleted + // from teamsyncd on detecting netlink of teamd dev as up/down. For some reason + // if we do not get state dump from teamdctl it might be transient issue. If it is + // persistent issue then teamsyncd might be able to catch it and delete state db entry + // or we can keep entry in it's current state as best effort. Similar to try_add_lag which is best effort + // to connect to teamdctl and if it fails we do not delete State Db entry. + if (table_name == "LAG_TABLE") + continue; swss::Table table(m_db, table_name); table.del(table_key); } @@ -366,13 +374,7 @@ void ValuesStore::update(const std::vector & dumps) { const auto & storage = from_json(dumps); const auto & old_keys = get_old_keys(storage); - // Do not delete te key from State Db. State DB LAB_TABLE entry is created/deleted - // from teamsyncd on detecting netlink of teamd dev as up/down. For some reason - // if we do not get state dump from teamdctl it might be transient issue. If it is - // persistent issue then teamsyncd might be able to catch it and delete state db entry - // or we can keep entry in it's current state as best effort. Similar to try_add_lag which is best effort - // to connect to teamdctl and if it fails we do not delete State Db entry. - //remove_keys_db(old_keys); + remove_keys_db(old_keys); remove_keys_storage(old_keys); const auto & keys_to_refresh = update_storage(storage); update_db(storage, keys_to_refresh); From adff6c4080668bc78f6fb7efba4b597250f241d9 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:56:23 -0700 Subject: [PATCH 03/10] Update values_store.cpp --- tlm_teamd/values_store.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tlm_teamd/values_store.cpp b/tlm_teamd/values_store.cpp index 015ed62524..957194b4c5 100644 --- a/tlm_teamd/values_store.cpp +++ b/tlm_teamd/values_store.cpp @@ -374,13 +374,7 @@ void ValuesStore::update(const std::vector & dumps) { const auto & storage = from_json(dumps); const auto & old_keys = get_old_keys(storage); - // Do not delete te key from State Db. State DB LAB_TABLE entry is created/deleted - // from teamsyncd on detecting netlink of teamd dev as up/down. For some reason - // if we do not get state dump from teamdctl it might be transient issue. If it is - // persistent issue then teamsyncd might be able to catch it and delete state db entry - // or we can keep entry in it's current state as best effort. Similar to try_add_lag which is best effort - // to connect to teamdctl and if it fails we do not delete State Db entry. - //remove_keys_db(old_keys); + remove_keys_db(old_keys); remove_keys_storage(old_keys); const auto & keys_to_refresh = update_storage(storage); update_db(storage, keys_to_refresh); From 1465f0556066808da97348c28223f2754f498d94 Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Tue, 5 Nov 2024 02:03:27 +0000 Subject: [PATCH 04/10] Added support to compile and load code to read yaml file in routesync.cpp. In routesyncd we read tag from constants.yml and take action of not to send route to appdb and also fallback to default route. Signed-off-by: Abhishek Dosi --- fpmsyncd/Makefile.am | 2 +- fpmsyncd/routesync.cpp | 30 ++++++++++++++++++++++++++++++ fpmsyncd/routesync.h | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/fpmsyncd/Makefile.am b/fpmsyncd/Makefile.am index 74d36b36c7..d275d35b74 100644 --- a/fpmsyncd/Makefile.am +++ b/fpmsyncd/Makefile.am @@ -12,7 +12,7 @@ fpmsyncd_SOURCES = fpmsyncd.cpp fpmlink.cpp routesync.cpp $(top_srcdir)/warmrest fpmsyncd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_ASAN) fpmsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_ASAN) -fpmsyncd_LDADD = $(LDFLAGS_ASAN) -lnl-3 -lnl-route-3 -lswsscommon +fpmsyncd_LDADD = $(LDFLAGS_ASAN) -lnl-3 -lnl-route-3 -lswsscommon -lyaml-cpp if GCOV_ENABLED fpmsyncd_SOURCES += ../gcovpreload/gcovpreload.cpp diff --git a/fpmsyncd/routesync.cpp b/fpmsyncd/routesync.cpp index 0f6ee41188..735895de19 100644 --- a/fpmsyncd/routesync.cpp +++ b/fpmsyncd/routesync.cpp @@ -13,6 +13,7 @@ #include "converter.h" #include #include +#include using namespace std; using namespace swss; @@ -86,6 +87,20 @@ RouteSync::RouteSync(RedisPipeline *pipeline) : m_nl_sock = nl_socket_alloc(); nl_connect(m_nl_sock, NETLINK_ROUTE); rtnl_link_alloc_cache(m_nl_sock, AF_UNSPEC, &m_link_cache); + + YAML::Node root; + try + { + root = YAML::LoadFile("/etc/sonic/constants.yml"); + route_tag_not_to_appdb = root["constants"]["bgp"]["route_do_not_send_appdb_tag"].as(); + route_tag_fallback_to_default_route = root["constants"]["bgp"]["route_eligible_for_fallback_to_default_tag"].as(); + } + catch (const exception &e) + { + cout << "Exception \"" << e.what() << "\" had been thrown in daemon in loading constants.yml" << endl; + route_tag_not_to_appdb = 0; + route_tag_fallback_to_default_route = 0; + } } char *RouteSync::prefixMac2Str(char *mac, char *buf, int size) @@ -667,6 +682,8 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf) struct rtnl_route *route_obj = (struct rtnl_route *)obj; struct nl_addr *dip; char destipprefix[IFNAMSIZ + MAX_ADDR_SIZE + 2] = {0}; + uint32_t tag = 0; + bool route_eligible_for_fallback_to_default_route = false; if (vrf) { @@ -693,6 +710,13 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf) destipprefix[strlen(vrf)] = ':'; } + tag = rtnl_route_get_priority(route_obj); + + if (tag == route_tag_not_to_appdb) + return; + else if (tag == route_tag_fallback_to_default_route) + route_eligible_for_fallback_to_default_route = true; + dip = rtnl_route_get_dst(route_obj); nl_addr2str(dip, destipprefix + strlen(destipprefix), MAX_ADDR_SIZE); @@ -833,6 +857,12 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf) fvVector.push_back(wt); } + if (route_eligible_for_fallback_to_default_route) + { + FieldValueTuple tag("fallback_to_default_route", "true"); + fvVector.push_back(tag); + } + if (!warmRestartInProgress) { m_routeTable.set(destipprefix, fvVector); diff --git a/fpmsyncd/routesync.h b/fpmsyncd/routesync.h index eb07eb8f15..ccc2953b3c 100644 --- a/fpmsyncd/routesync.h +++ b/fpmsyncd/routesync.h @@ -77,6 +77,8 @@ class RouteSync : public NetMsg ProducerStateTable m_vnet_tunnelTable; struct nl_cache *m_link_cache; struct nl_sock *m_nl_sock; + uint32_t route_tag_not_to_appdb; + uint32_t route_tag_fallback_to_default_route; bool m_isSuppressionEnabled{false}; FpmInterface* m_fpmInterface {nullptr}; From 3b456ae6503a58a295ad89c52a87abc94788cfd2 Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Thu, 14 Nov 2024 21:07:27 +0000 Subject: [PATCH 05/10] Added some more fixes Signed-off-by: Abhishek Dosi --- fpmsyncd/routesync.cpp | 4 ++-- tests/Makefile.am | 2 +- tests/mock_tests/Makefile.am | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fpmsyncd/routesync.cpp b/fpmsyncd/routesync.cpp index 735895de19..8358e71319 100644 --- a/fpmsyncd/routesync.cpp +++ b/fpmsyncd/routesync.cpp @@ -98,8 +98,8 @@ RouteSync::RouteSync(RedisPipeline *pipeline) : catch (const exception &e) { cout << "Exception \"" << e.what() << "\" had been thrown in daemon in loading constants.yml" << endl; - route_tag_not_to_appdb = 0; - route_tag_fallback_to_default_route = 0; + route_tag_not_to_appdb = 0xffffffff; + route_tag_fallback_to_default_route = 0xffffffff; } } diff --git a/tests/Makefile.am b/tests/Makefile.am index 8f2aa131c4..1dbbf654f7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,4 +25,4 @@ tests_SOURCES = swssnet_ut.cpp request_parser_ut.cpp ../orchagent/request_parser tests_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) tests_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) -I../orchagent tests_LDADD = $(LDADD_GTEST) -lnl-genl-3 -lhiredis -lhiredis -lpthread \ - -lswsscommon -lswsscommon -lgtest -lgtest_main + -lswsscommon -lswsscommon -lyaml-cpp -lgtest -lgtest_main diff --git a/tests/mock_tests/Makefile.am b/tests/mock_tests/Makefile.am index 0f5afa4486..d7b9bebde6 100644 --- a/tests/mock_tests/Makefile.am +++ b/tests/mock_tests/Makefile.am @@ -226,7 +226,7 @@ tests_teammgrd_INCLUDES = $(tests_INCLUDES) -I$(top_srcdir)/cfgmgr -I$(top_srcdi tests_teammgrd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) tests_teammgrd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) $(tests_teammgrd_INCLUDES) tests_teammgrd_LDADD = $(LDADD_GTEST) $(LDADD_SAI) -lnl-genl-3 -lhiredis -lhiredis \ - -lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread -lgmock -lgmock_main + -lswsscommon -lswsscommon -lyaml-cpp -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread -lgmock -lgmock_main ## fpmsyncd unit tests @@ -246,7 +246,7 @@ tests_fpmsyncd_INCLUDES = $(tests_INCLUDES) -I$(top_srcdir)/tests_fpmsyncd -I$(t tests_fpmsyncd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) tests_fpmsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) $(tests_fpmsyncd_INCLUDES) tests_fpmsyncd_LDADD = $(LDADD_GTEST) $(LDADD_SAI) -lnl-genl-3 -lhiredis -lhiredis \ - -lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread -lgmock -lgmock_main + -lswsscommon -lswsscommon -lyaml-cpp -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread -lgmock -lgmock_main ## response publisher unit tests @@ -263,5 +263,5 @@ tests_response_publisher_INCLUDES = $(tests_INCLUDES) tests_response_publisher_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) tests_response_publisher_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) $(tests_response_publisher_INCLUDES) tests_response_publisher_LDADD = $(LDADD_GTEST) $(LDADD_SAI) -lnl-genl-3 -lhiredis -lhiredis \ - -lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread + -lswsscommon -lswsscommon -lyaml-cpp -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread From bcc259b42d0ff71a85f8632978ba6ad2de0ee360 Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Thu, 14 Nov 2024 21:08:50 +0000 Subject: [PATCH 06/10] Fix indendation Signed-off-by: Abhishek Dosi --- fpmsyncd/routesync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpmsyncd/routesync.cpp b/fpmsyncd/routesync.cpp index 8358e71319..13f13c3dd4 100644 --- a/fpmsyncd/routesync.cpp +++ b/fpmsyncd/routesync.cpp @@ -715,7 +715,7 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf) if (tag == route_tag_not_to_appdb) return; else if (tag == route_tag_fallback_to_default_route) - route_eligible_for_fallback_to_default_route = true; + route_eligible_for_fallback_to_default_route = true; dip = rtnl_route_get_dst(route_obj); nl_addr2str(dip, destipprefix + strlen(destipprefix), MAX_ADDR_SIZE); From 9ca5ba63b1cf8ce24604739418d735f1b54b1a47 Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Tue, 19 Nov 2024 05:21:55 +0000 Subject: [PATCH 07/10] Fixed error Signed-off-by: Abhishek Dosi --- .azure-pipelines/build-template.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/build-template.yml b/.azure-pipelines/build-template.yml index 0a680e35de..11886fe1fd 100644 --- a/.azure-pipelines/build-template.yml +++ b/.azure-pipelines/build-template.yml @@ -104,7 +104,8 @@ jobs: libzmq3-dev \ swig4.0 \ libdbus-1-dev \ - libteam-dev + libteam-dev \ + libyaml-cpp-dev sudo pip3 install lcov_cobertura displayName: "Install dependencies" - task: DownloadPipelineArtifact@2 From 54de7d981199669dfce74519048f47193fb03467 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:33:15 -0800 Subject: [PATCH 08/10] Update Dockerfile --- .azure-pipelines/docker-sonic-vs/Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.azure-pipelines/docker-sonic-vs/Dockerfile b/.azure-pipelines/docker-sonic-vs/Dockerfile index d3664cb1c0..8515254c7b 100644 --- a/.azure-pipelines/docker-sonic-vs/Dockerfile +++ b/.azure-pipelines/docker-sonic-vs/Dockerfile @@ -12,15 +12,15 @@ COPY ["debs", "/debs"] # same, even though contents have changed) are checked between the previous and current layer. RUN dpkg --purge libswsscommon python3-swsscommon sonic-db-cli libsaimetadata libsairedis libsaivs syncd-vs swss sonic-eventd libdashapi -RUN dpkg -i /debs/libdashapi_1.0.0_amd64.deb \ - /debs/libswsscommon_1.0.0_amd64.deb \ - /debs/python3-swsscommon_1.0.0_amd64.deb \ - /debs/sonic-db-cli_1.0.0_amd64.deb \ - /debs/libsaimetadata_1.0.0_amd64.deb \ - /debs/libsairedis_1.0.0_amd64.deb \ - /debs/libsaivs_1.0.0_amd64.deb \ - /debs/syncd-vs_1.0.0_amd64.deb \ - /debs/swss_1.0.0_amd64.deb +RUN apt install /debs/libdashapi_1.0.0_amd64.deb \ + /debs/libswsscommon_1.0.0_amd64.deb \ + /debs/python3-swsscommon_1.0.0_amd64.deb \ + /debs/sonic-db-cli_1.0.0_amd64.deb \ + /debs/libsaimetadata_1.0.0_amd64.deb \ + /debs/libsairedis_1.0.0_amd64.deb \ + /debs/libsaivs_1.0.0_amd64.deb \ + /debs/syncd-vs_1.0.0_amd64.deb \ + /debs/swss_1.0.0_amd64.deb RUN if [ "$need_dbg" = "y" ] ; then dpkg -i /debs/swss-dbg_1.0.0_amd64.deb ; fi From 1d65e524ca92602b62922c423f2601c655caeae0 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:35:37 -0800 Subject: [PATCH 09/10] Update Dockerfile --- .azure-pipelines/docker-sonic-vs/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.azure-pipelines/docker-sonic-vs/Dockerfile b/.azure-pipelines/docker-sonic-vs/Dockerfile index 8515254c7b..66ba6e9889 100644 --- a/.azure-pipelines/docker-sonic-vs/Dockerfile +++ b/.azure-pipelines/docker-sonic-vs/Dockerfile @@ -11,7 +11,7 @@ COPY ["debs", "/debs"] # Docker's diff detection mechanism, where only the file size and the modification timestamp (which will remain the # same, even though contents have changed) are checked between the previous and current layer. RUN dpkg --purge libswsscommon python3-swsscommon sonic-db-cli libsaimetadata libsairedis libsaivs syncd-vs swss sonic-eventd libdashapi - +RUN apt-get update RUN apt install /debs/libdashapi_1.0.0_amd64.deb \ /debs/libswsscommon_1.0.0_amd64.deb \ /debs/python3-swsscommon_1.0.0_amd64.deb \ @@ -24,8 +24,6 @@ RUN apt install /debs/libdashapi_1.0.0_amd64.deb \ RUN if [ "$need_dbg" = "y" ] ; then dpkg -i /debs/swss-dbg_1.0.0_amd64.deb ; fi -RUN apt-get update - RUN apt-get -y install software-properties-common libdatetime-perl libcapture-tiny-perl build-essential libcpanel-json-xs-perl git RUN git clone -b v2.0 --single-branch --depth 1 https://github.com/linux-test-project/lcov && cd lcov && make install From 13e2d4f60ff4a69db36dd0efc171c54c31ab9bd0 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Wed, 20 Nov 2024 17:31:38 -0800 Subject: [PATCH 10/10] Update Dockerfile --- .azure-pipelines/docker-sonic-vs/Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.azure-pipelines/docker-sonic-vs/Dockerfile b/.azure-pipelines/docker-sonic-vs/Dockerfile index 66ba6e9889..711ce2fc30 100644 --- a/.azure-pipelines/docker-sonic-vs/Dockerfile +++ b/.azure-pipelines/docker-sonic-vs/Dockerfile @@ -12,15 +12,15 @@ COPY ["debs", "/debs"] # same, even though contents have changed) are checked between the previous and current layer. RUN dpkg --purge libswsscommon python3-swsscommon sonic-db-cli libsaimetadata libsairedis libsaivs syncd-vs swss sonic-eventd libdashapi RUN apt-get update -RUN apt install /debs/libdashapi_1.0.0_amd64.deb \ - /debs/libswsscommon_1.0.0_amd64.deb \ - /debs/python3-swsscommon_1.0.0_amd64.deb \ - /debs/sonic-db-cli_1.0.0_amd64.deb \ - /debs/libsaimetadata_1.0.0_amd64.deb \ - /debs/libsairedis_1.0.0_amd64.deb \ - /debs/libsaivs_1.0.0_amd64.deb \ - /debs/syncd-vs_1.0.0_amd64.deb \ - /debs/swss_1.0.0_amd64.deb +RUN apt install -y /debs/libdashapi_1.0.0_amd64.deb \ + /debs/libswsscommon_1.0.0_amd64.deb \ + /debs/python3-swsscommon_1.0.0_amd64.deb \ + /debs/sonic-db-cli_1.0.0_amd64.deb \ + /debs/libsaimetadata_1.0.0_amd64.deb \ + /debs/libsairedis_1.0.0_amd64.deb \ + /debs/libsaivs_1.0.0_amd64.deb \ + /debs/syncd-vs_1.0.0_amd64.deb \ + /debs/swss_1.0.0_amd64.deb RUN if [ "$need_dbg" = "y" ] ; then dpkg -i /debs/swss-dbg_1.0.0_amd64.deb ; fi