Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sflow] Fix ansible test problems caused by enabling sflow #1252

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 0 additions & 49 deletions orchagent/copporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ CoppOrch::CoppOrch(vector<TableConnector> &tableConnectors) :
initDefaultHostIntfTable();
initDefaultTrapGroup();
initDefaultTrapIds();
enable_sflow_trap = false;
};

void CoppOrch::initDefaultHostIntfTable()
Expand Down Expand Up @@ -477,14 +476,6 @@ task_process_status CoppOrch::processCoppRule(Consumer& consumer)
if (fvField(*i) == copp_trap_id_list)
{
trap_id_list = tokenize(fvValue(*i), list_item_delimiter);
auto it = std::find(trap_id_list.begin(), trap_id_list.end(), "sample_packet");
if (it != trap_id_list.end())
{
if (!enable_sflow_trap)
{
return task_process_status::task_need_retry;
}
}
}
else if (fvField(*i) == copp_queue_field)
{
Expand Down Expand Up @@ -775,49 +766,9 @@ task_process_status CoppOrch::processCoppRule(Consumer& consumer)
return task_process_status::task_success;
}

/* Program Sflow trap once we get sflow enable command */
void CoppOrch::coppProcessSflow(Consumer &consumer)
{
auto it = consumer.m_toSync.begin();

while (it != consumer.m_toSync.end())
{
auto tuple = it->second;
string op = kfvOp(tuple);

/*
* Need to handled just 'config sflow enable' command to install the sflow trap group
* for the first time to ensure support of genetlink attributes. Rest of the fields or
* disable value or DEL command are not required to be handled
*
*/
if (op == SET_COMMAND)
{
for (auto i : kfvFieldsValues(tuple))
{
if (fvField(i) == "admin_state")
{
if (fvValue(i) == "up")
{
enable_sflow_trap = true;
}
}
}
}
it = consumer.m_toSync.erase(it);
}
}

void CoppOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();
string table_name = consumer.getTableName();

if (table_name == CFG_SFLOW_TABLE_NAME)
{
coppProcessSflow(consumer);
return;
}

if (!gPortsOrch->allPortsReady())
{
Expand Down
1 change: 0 additions & 1 deletion orchagent/copporch.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class CoppOrch : public Orch
CoppOrch(std::vector<TableConnector> &tableConnectors);
protected:
object_map m_trap_group_map;
bool enable_sflow_trap;

TrapGroupPolicerTable m_trap_group_policer_map;
TrapIdTrapObjectsTable m_syncdTrapIds;
Expand Down
2 changes: 0 additions & 2 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ bool OrchDaemon::init()
gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, gIntfsOrch);
gRouteOrch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, gNeighOrch, gIntfsOrch, vrf_orch);

TableConnector confDbSflowTable(m_configDb, CFG_SFLOW_TABLE_NAME);
TableConnector appCoppTable(m_applDb, APP_COPP_TABLE_NAME);

vector<TableConnector> copp_table_connectors = {
confDbSflowTable,
appCoppTable
};
CoppOrch *copp_orch = new CoppOrch(copp_table_connectors);
Expand Down
16 changes: 16 additions & 0 deletions swssconfig/sample/00-copp.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,21 @@
"red_action":"drop"
},
"OP": "SET"
},
{
"COPP_TABLE:trap.group.sflow": {
"trap_ids": "sample_packet",
"trap_action":"trap",
"trap_priority":"1",
"queue": "2",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"1000",
"cbs":"1000",
"red_action":"drop",
"genetlink_name":"psample",
"genetlink_mcgrp_name":"packets"
},
"OP": "SET"
}
]