Skip to content

Commit

Permalink
[portsyncd]: Fix portsyncd restart case (#1019)
Browse files Browse the repository at this point in the history
I noticed that after swss restart in VS orchagent does not receive
PortInitDone. I looked at the comment about "g_portSet" says that:

 When this LinkSync class is
 * initialized, we check the database to see if some of the ports' host
 * interfaces are already created and remove them from this set.
However g_portSet was filled after LinkSync is initialized, so I
considered this is a bug causing orchagent does not receive PortInitDone
when portsyncd starts after host interfaces were created.

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
  • Loading branch information
stepanblyschak authored and stcheng committed Aug 8, 2019
1 parent fcddc0f commit 2902ba0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 9 additions & 2 deletions portsyncd/linksync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,27 @@ LinkSync::LinkSync(DBConnector *appl_db, DBConnector *state_db) :
if (!WarmStart::isWarmStart())
{
/* See the comments for g_portSet in portsyncd.cpp */
for (string port : g_portSet)
for (auto port_iter = g_portSet.begin(); port_iter != g_portSet.end();)
{
string port = *port_iter;
vector<FieldValueTuple> temp;
bool portFound = false;
if (m_portTable.get(port, temp))
{
for (auto it : temp)
{
if (fvField(it) == "admin_status")
{
g_portSet.erase(port);
port_iter = g_portSet.erase(port_iter);
portFound = true;
break;
}
}
}
if (!portFound)
{
++port_iter;
}
}

for (idx_p = if_ni;
Expand Down
8 changes: 4 additions & 4 deletions portsyncd/portsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ int main(int argc, char **argv)
WarmStart::checkWarmStart("portsyncd", "swss");
const bool warm = WarmStart::isWarmStart();

LinkSync sync(&appl_db, &state_db);
NetDispatcher::getInstance().registerMessageHandler(RTM_NEWLINK, &sync);
NetDispatcher::getInstance().registerMessageHandler(RTM_DELLINK, &sync);

try
{
NetLink netlink;
Expand All @@ -102,6 +98,10 @@ int main(int argc, char **argv)
}
}

LinkSync sync(&appl_db, &state_db);
NetDispatcher::getInstance().registerMessageHandler(RTM_NEWLINK, &sync);
NetDispatcher::getInstance().registerMessageHandler(RTM_DELLINK, &sync);

s.addSelectable(&netlink);
s.addSelectable(&portCfg);

Expand Down

0 comments on commit 2902ba0

Please sign in to comment.