diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 4dcdb6c360..041a988d5c 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -751,6 +751,9 @@ void RouteOrch::doTask(Consumer& consumer) it = consumer.m_toSync.erase(it); else it++; + + /* Publish route state to advertise routes to Loopback interface */ + publishRouteState(ctx); continue; } @@ -2548,7 +2551,7 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx) SWSS_LOG_INFO("Remove route %s with next hop(s) %s", ipPrefix.to_string().c_str(), it_route->second.nhg_key.to_string().c_str()); - + /* Publish removal status, removes route entry from APPL STATE DB */ publishRouteState(ctx); diff --git a/tests/mock_tests/routeorch_ut.cpp b/tests/mock_tests/routeorch_ut.cpp index 8073aee92b..0bfe5ad073 100644 --- a/tests/mock_tests/routeorch_ut.cpp +++ b/tests/mock_tests/routeorch_ut.cpp @@ -282,6 +282,10 @@ namespace routeorch_test static_cast(gPortsOrch)->doTask(); Table intfTable = Table(m_app_db.get(), APP_INTF_TABLE_NAME); + intfTable.set("Loopback0", { {"NULL", "NULL" }, + {"mac_addr", "00:00:00:00:00:00" }}); + intfTable.set("Loopback0:10.1.0.32/32", { { "scope", "global" }, + { "family", "IPv4" }}); intfTable.set("Ethernet0", { {"NULL", "NULL" }, {"mac_addr", "00:00:00:00:00:00" }}); intfTable.set("Ethernet0:10.0.0.1/24", { { "scope", "global" }, @@ -484,4 +488,22 @@ namespace routeorch_test gMockResponsePublisher.reset(); } + + TEST_F(RouteOrchTest, RouteOrchLoopbackRoute) + { + gMockResponsePublisher = std::make_unique(); + + std::deque entries; + std::string key = "fc00:1::/64"; + std::vector fvs{{"ifname", "Loopback"}, {"nexthop", "::"}, {"protocol", "static"}}; + entries.push_back({key, "SET", fvs}); + + auto consumer = dynamic_cast(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME)); + consumer->addToSync(entries); + + EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector{{"protocol", "static"}}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1); + static_cast(gRouteOrch)->doTask(); + + gMockResponsePublisher.reset(); + } }