Skip to content

Commit

Permalink
[syncd] Comparison logic log also current attr value on set operation (
Browse files Browse the repository at this point in the history
…#763)

Signed-off-by: kcudnik <kcudnik@gmail.com>
  • Loading branch information
kcudnik authored Jan 12, 2021
1 parent 7d31204 commit cc560f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions syncd/AsicOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C"{
#include "swss/table.h"

#include <memory>
#include <string>

namespace syncd
{
Expand All @@ -31,5 +32,7 @@ namespace syncd
bool m_isRemove;

std::shared_ptr<swss::KeyOpFieldsValuesTuple> m_op;

std::string m_currentValue;
};
}
8 changes: 8 additions & 0 deletions syncd/AsicView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ void AsicView::asicSetAttribute(

auto meta = attr->getAttrMetadata();

auto currentAttr = currentObj->tryGetSaiAttr(meta->attrid);

if (attr->isObjectIdAttr())
{
if (currentObj->hasAttr(meta->attrid))
Expand Down Expand Up @@ -616,6 +618,12 @@ void AsicView::asicSetAttribute(

m_asicOperations.push_back(AsicOperation(m_asicOperationId, vid, false, kco));

if (currentAttr)
{
// if current attribute exists, save it value for log purpose
m_asicOperations.rbegin()->m_currentValue = currentAttr->getStrAttrValue();
}

dumpRef("set");
}

Expand Down
14 changes: 12 additions & 2 deletions syncd/ComparisonLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3431,9 +3431,19 @@ void ComparisonLogic::executeOperationsOnAsic()

const auto &values = kfvFieldsValues(*op.m_op);

for (auto v: values)
if (op.m_currentValue.size() && opp == "set")
{
SWSS_LOG_NOTICE("- %s %s", fvField(v).c_str(), fvValue(v).c_str());
SWSS_LOG_NOTICE("- %s %s (current: %s)",
fvField(values.at(0)).c_str(),
fvValue(values.at(0)).c_str(),
op.m_currentValue.c_str());
}
else
{
for (auto v: values)
{
SWSS_LOG_NOTICE("- %s %s", fvField(v).c_str(), fvValue(v).c_str());
}
}
}

Expand Down

0 comments on commit cc560f5

Please sign in to comment.