Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "swss/warm_restart.h"
#include "swss/table.h"
#include "swss/redisapi.h"

#include "TimerWatchdog.h"

Expand Down Expand Up @@ -35,6 +36,7 @@ extern "C" {
*/
std::mutex g_mutex;

std::shared_ptr<swss::DBConnector> dbAsic;
std::shared_ptr<swss::RedisClient> g_redisClient;
std::shared_ptr<swss::ProducerTable> getResponse;
std::shared_ptr<swss::NotificationProducer> notifications;
Expand Down Expand Up @@ -89,6 +91,9 @@ volatile bool g_asicInitViewMode = false;
*/
sai_object_id_t gSwitchId;

std::string fdbFlushSha;
std::string fdbFlushLuaScriptName = "fdb_flush.lua";

struct cmdOptions
{
bool diagShell;
Expand Down Expand Up @@ -3756,7 +3761,7 @@ int syncd_main(int argc, char **argv)
}
#endif // SAITHRIFT

std::shared_ptr<swss::DBConnector> dbAsic = std::make_shared<swss::DBConnector>(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
dbAsic = std::make_shared<swss::DBConnector>(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
std::shared_ptr<swss::DBConnector> dbNtf = std::make_shared<swss::DBConnector>(ASIC_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
std::shared_ptr<swss::DBConnector> dbFlexCounter = std::make_shared<swss::DBConnector>(FLEX_COUNTER_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
std::shared_ptr<swss::DBConnector> dbState = std::make_shared<swss::DBConnector>(STATE_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0);
Expand All @@ -3778,6 +3783,9 @@ int syncd_main(int argc, char **argv)
getResponse = std::make_shared<swss::ProducerTable>(dbAsic.get(), "GETRESPONSE");
notifications = std::make_shared<swss::NotificationProducer>(dbNtf.get(), "NOTIFICATIONS");

std::string fdbFlushLuaScript = swss::loadLuaScript(fdbFlushLuaScriptName);
fdbFlushSha = swss::loadRedisScript(dbAsic.get(), fdbFlushLuaScript);

g_veryFirstRun = isVeryFirstRun();

/* ignore warm logic here if syncd starts in Mellanox fastfast boot mode */
Expand Down
2 changes: 2 additions & 0 deletions syncd/syncd.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ sai_object_type_t getObjectTypeFromVid(

extern std::shared_ptr<swss::NotificationProducer> notifications;
extern std::shared_ptr<swss::RedisClient> g_redisClient;
extern std::shared_ptr<swss::DBConnector> dbAsic;
extern std::string fdbFlushSha;

extern bool g_enableConsistencyCheck;

Expand Down
68 changes: 46 additions & 22 deletions syncd/syncd_notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,18 @@ void redisPutFdbEntryToAsicView(
{
sai_object_id_t bv_id = fdb->fdb_entry.bv_id;
sai_object_id_t port_oid = 0;
int flush_static = 0;

for (uint32_t i = 0; i < fdb->attr_count; i++)
{
if(fdb->attr[i].id == SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID)
{
port_oid = fdb->attr[i].value.oid;
}
else if(fdb->attr[i].id == SAI_FDB_ENTRY_ATTR_TYPE)
{
flush_static = (fdb->attr[i].value.s32 == SAI_FDB_ENTRY_TYPE_STATIC) ? 1 : 0;
}
}


Expand All @@ -138,24 +143,14 @@ void redisPutFdbEntryToAsicView(
*/
SWSS_LOG_NOTICE("received a flush all fdb event");
std::string pattern = ASIC_STATE_TABLE + std::string(":SAI_OBJECT_TYPE_FDB_ENTRY:*");
for (const auto &fdbkey: g_redisClient->keys(pattern))
{
/* we only remove dynamic fdb entries here, static fdb entries need to be deleted manually by user instead of flush */
auto pEntryType = g_redisClient->hget(fdbkey, "SAI_FDB_ENTRY_ATTR_TYPE");
if (pEntryType != NULL)
{
std::string strEntryType = *pEntryType;
if (strEntryType == "SAI_FDB_ENTRY_TYPE_DYNAMIC")
{
SWSS_LOG_DEBUG("remove fdb entry %s for SAI_FDB_EVENT_FLUSHED",fdbkey.c_str());
g_redisClient->del(fdbkey);
}
}
else
{
SWSS_LOG_ERROR("found unknown type fdb entry, key %s", fdbkey.c_str());
}
}
swss::RedisCommand command;
command.format(
"EVALSHA %s 3 %s %s %s",
fdbFlushSha.c_str(),
pattern.c_str(),
"",
std::to_string(flush_static).c_str());
swss::RedisReply r(dbAsic.get(), command);
}
else if (port_oid && !bv_id)
{
Expand All @@ -176,7 +171,18 @@ void redisPutFdbEntryToAsicView(
]
}]
*/
SWSS_LOG_ERROR("received a flush port fdb event, port_oid = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ", unsupported", port_oid, bv_id);
SWSS_LOG_NOTICE("received a flush port fdb event, port_oid = 0x%lx, bv_id = 0x%lx", port_oid, bv_id);
std::string pattern = ASIC_STATE_TABLE + std::string(":SAI_OBJECT_TYPE_FDB_ENTRY:*");
std::string port_str = sai_serialize_object_id(port_oid);
SWSS_LOG_NOTICE("pattern %s port_str %s", pattern.c_str(), port_str.c_str());
swss::RedisCommand command;
command.format(
"EVALSHA %s 3 %s %s %s",
fdbFlushSha.c_str(),
pattern.c_str(),
port_str.c_str(),
std::to_string(flush_static).c_str());
swss::RedisReply r(dbAsic.get(), command);
}
else if (!port_oid && bv_id)
{
Expand All @@ -197,12 +203,30 @@ void redisPutFdbEntryToAsicView(
]
}]
*/
SWSS_LOG_ERROR("received a flush vlan fdb event, port_oid = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ", unsupported", port_oid, bv_id);

SWSS_LOG_NOTICE("received a flush vlan fdb event, port_oid = 0x%lx, bv_id = 0x%lx", port_oid, bv_id);
std::string pattern = ASIC_STATE_TABLE + std::string(":SAI_OBJECT_TYPE_FDB_ENTRY:*") + sai_serialize_object_id(bv_id) + std::string("*");
swss::RedisCommand command;
command.format(
"EVALSHA %s 3 %s %s %s",
fdbFlushSha.c_str(),
pattern.c_str(),
"",
std::to_string(flush_static).c_str());
swss::RedisReply r(dbAsic.get(), command);
}
else
{
SWSS_LOG_ERROR("received a flush fdb event, port_oid = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ", unsupported", port_oid, bv_id);
SWSS_LOG_NOTICE("received a flush fdb event, port_oid = 0x%lx, bv_id = 0x%lx", port_oid, bv_id);
std::string pattern = ASIC_STATE_TABLE + std::string(":SAI_OBJECT_TYPE_FDB_ENTRY:*") + sai_serialize_object_id(bv_id) + std::string("*");
std::string port_str = sai_serialize_object_id(port_oid);
swss::RedisCommand command;
command.format(
"EVALSHA %s 3 %s %s %s",
fdbFlushSha.c_str(),
pattern.c_str(),
port_str.c_str(),
std::to_string(flush_static).c_str());
swss::RedisReply r(dbAsic.get(), command);
}

return;
Expand Down