Skip to content

Commit

Permalink
[RouteOrch] Publish route state for route to Loopback interface (#3013)
Browse files Browse the repository at this point in the history
* [RouteOrch] Publish route state for route to Loopback interface
Route to loopback interface is not advertised to peers when FIB suppression is enabled.

Route is queued:
```
admin@sonic:~$ show ipv6 route |grep q
       > - selected route, * - FIB route, q - queued route, r - rejected route
S>qfc00:1::/64 [1/0] is directly connected, Loopback0, 00:02:00
```

With this change:
```
admin@sonic:~$ show ipv6 route | grep q
       > - selected route, * - FIB route, q - queued route, r - rejected route
```

The proper way would be to program route to HW and then publish the
route state, however to keep the existing behaviour this W/A is proposed
until a final solution.
  • Loading branch information
stepanblyschak authored Jan 19, 2024
1 parent 7702b8a commit 09ffb25
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down
22 changes: 22 additions & 0 deletions tests/mock_tests/routeorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ namespace routeorch_test
static_cast<Orch *>(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" },
Expand Down Expand Up @@ -484,4 +488,22 @@ namespace routeorch_test

gMockResponsePublisher.reset();
}

TEST_F(RouteOrchTest, RouteOrchLoopbackRoute)
{
gMockResponsePublisher = std::make_unique<MockResponsePublisher>();

std::deque<KeyOpFieldsValuesTuple> entries;
std::string key = "fc00:1::/64";
std::vector<FieldValueTuple> fvs{{"ifname", "Loopback"}, {"nexthop", "::"}, {"protocol", "static"}};
entries.push_back({key, "SET", fvs});

auto consumer = dynamic_cast<Consumer *>(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME));
consumer->addToSync(entries);

EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{{"protocol", "static"}}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1);
static_cast<Orch *>(gRouteOrch)->doTask();

gMockResponsePublisher.reset();
}
}

0 comments on commit 09ffb25

Please sign in to comment.