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 diff --git a/.azure-pipelines/docker-sonic-vs/Dockerfile b/.azure-pipelines/docker-sonic-vs/Dockerfile index d3664cb1c0..711ce2fc30 100644 --- a/.azure-pipelines/docker-sonic-vs/Dockerfile +++ b/.azure-pipelines/docker-sonic-vs/Dockerfile @@ -11,21 +11,19 @@ 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 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-get update +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 -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 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 4d6aa708ab..4180c9dc5d 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; @@ -149,6 +150,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 = 0xffffffff; + route_tag_fallback_to_default_route = 0xffffffff; + } } char *RouteSync::prefixMac2Str(char *mac, char *buf, int size) @@ -1548,6 +1563,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) { @@ -1574,6 +1591,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); @@ -1714,6 +1738,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 fe67f6acfc..41e3818b91 100644 --- a/fpmsyncd/routesync.h +++ b/fpmsyncd/routesync.h @@ -81,6 +81,8 @@ class RouteSync : public NetMsg ProducerStateTable m_srv6SidListTable; 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}; 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 126f4e88c5..813e0a5d2c 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 @@ -250,7 +250,7 @@ tests_fpmsyncd_CXXFLAGS = -Wl,-wrap,rtnl_link_i2name 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 @@ -267,4 +267,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 +