Skip to content

Commit 5538efe

Browse files
authored
Merge branch 'master' into remove-enforce-wred-drop
2 parents 0b02be3 + b62c716 commit 5538efe

40 files changed

+1762
-434
lines changed

cfgmgr/buffermgrdyn.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -3110,8 +3110,7 @@ task_process_status BufferMgrDynamic::handleSingleBufferQueueEntry(const string
31103110

31113111
if (op == SET_COMMAND)
31123112
{
3113-
auto &portQueue = m_portQueueLookup[port][queues];
3114-
3113+
bool successful = false;
31153114
SWSS_LOG_INFO("Inserting entry BUFFER_QUEUE_TABLE:%s to APPL_DB", key.c_str());
31163115

31173116
for (auto i : kfvFieldsValues(tuple))
@@ -3122,8 +3121,10 @@ task_process_status BufferMgrDynamic::handleSingleBufferQueueEntry(const string
31223121
auto rc = checkBufferProfileDirection(fvValue(i), BUFFER_EGRESS);
31233122
if (rc != task_process_status::task_success)
31243123
return rc;
3125-
portQueue.running_profile_name = fvValue(i);
3124+
3125+
m_portQueueLookup[port][queues].running_profile_name = fvValue(i);
31263126
SWSS_LOG_NOTICE("Queue %s has been configured on the system, referencing profile %s", key.c_str(), fvValue(i).c_str());
3127+
successful = true;
31273128
}
31283129
else
31293130
{
@@ -3134,8 +3135,15 @@ task_process_status BufferMgrDynamic::handleSingleBufferQueueEntry(const string
31343135
SWSS_LOG_INFO("Inserting field %s value %s", fvField(i).c_str(), fvValue(i).c_str());
31353136
}
31363137

3138+
if (!successful)
3139+
{
3140+
SWSS_LOG_ERROR("Invalid BUFFER_QUEUE configuration on %s: no profile configured", key.c_str());
3141+
return task_process_status::task_failed;
3142+
}
3143+
31373144
// TODO: check overlap. Currently, assume there is no overlap
31383145

3146+
auto &portQueue = m_portQueueLookup[port][queues];
31393147
if (PORT_ADMIN_DOWN == portInfo.state)
31403148
{
31413149
handleSetSingleBufferObjectOnAdminDownPort(BUFFER_QUEUE, port, key, portQueue.running_profile_name);

cfgmgr/nbrmgr.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ void NbrMgr::doStateSystemNeighTask(Consumer &consumer)
397397

398398
if (!addKernelNeigh(nbr_odev, ip_address, mac_address))
399399
{
400-
SWSS_LOG_ERROR("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
400+
SWSS_LOG_INFO("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
401401
// Delete neigh to take care of deletion of exiting nbr for mac change. This makes sure that
402402
// re-try will be successful and route addtion (below) will be attempted and be successful
403403
delKernelNeigh(nbr_odev, ip_address);
@@ -411,7 +411,7 @@ void NbrMgr::doStateSystemNeighTask(Consumer &consumer)
411411

412412
if (!addKernelRoute(nbr_odev, ip_address))
413413
{
414-
SWSS_LOG_ERROR("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
414+
SWSS_LOG_INFO("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
415415
delKernelNeigh(nbr_odev, ip_address);
416416
// Delete route to take care of deletion of exiting route of nbr for mac change.
417417
delKernelRoute(ip_address);
@@ -522,8 +522,8 @@ bool NbrMgr::addKernelRoute(string odev, IpAddress ip_addr)
522522

523523
if(ret)
524524
{
525-
/* Just log error and return */
526-
SWSS_LOG_ERROR("Failed to add route for %s, error: %d", ip_str.c_str(), ret);
525+
/* This failure the caller expects is due to mac move */
526+
SWSS_LOG_INFO("Failed to add route for %s, error: %d", ip_str.c_str(), ret);
527527
return false;
528528
}
529529

@@ -586,8 +586,8 @@ bool NbrMgr::addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr)
586586

587587
if(ret)
588588
{
589-
/* Just log error and return */
590-
SWSS_LOG_ERROR("Failed to add Nbr for %s, error: %d", ip_str.c_str(), ret);
589+
/* This failure the caller expects is due to mac move */
590+
SWSS_LOG_INFO("Failed to add Nbr for %s, error: %d", ip_str.c_str(), ret);
591591
return false;
592592
}
593593

neighsyncd/neighsync.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
6363
string key;
6464
string family;
6565
string intfName;
66+
std::vector<std::string> peerSwitchKeys;
67+
m_cfgPeerSwitchTable.getKeys(peerSwitchKeys);
68+
bool is_dualtor = peerSwitchKeys.size() > 0;
6669

6770
if ((nlmsg_type != RTM_NEWNEIGH) && (nlmsg_type != RTM_GETNEIGH) &&
6871
(nlmsg_type != RTM_DELNEIGH))
@@ -81,11 +84,11 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
8184

8285
nl_addr2str(rtnl_neigh_get_dst(neigh), ipStr, MAX_ADDR_SIZE);
8386

84-
/* Ignore IPv4 link-local addresses as neighbors */
87+
/* Ignore IPv4 link-local addresses as neighbors if subtype is dualtor */
8588
IpAddress ipAddress(ipStr);
86-
if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE)
89+
if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE && is_dualtor)
8790
{
88-
SWSS_LOG_INFO("Link Local address received, ignoring for %s", ipStr);
91+
SWSS_LOG_INFO("Link Local address received on dualtor, ignoring for %s", ipStr);
8992
return;
9093
}
9194

@@ -109,11 +112,8 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
109112
return;
110113
}
111114

112-
std::vector<std::string> peerSwitchKeys;
113115
bool delete_key = false;
114116
bool use_zero_mac = false;
115-
m_cfgPeerSwitchTable.getKeys(peerSwitchKeys);
116-
bool is_dualtor = peerSwitchKeys.size() > 0;
117117
if (is_dualtor && (state == NUD_INCOMPLETE || state == NUD_FAILED))
118118
{
119119
SWSS_LOG_INFO("Unable to resolve %s, setting zero MAC", key.c_str());

orchagent/aclorch.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,11 @@ const vector<AclRangeConfig>& AclRule::getRangeConfig() const
14771477
return m_rangeConfig;
14781478
}
14791479

1480+
bool AclRule::getCreateCounter() const
1481+
{
1482+
return m_createCounter;
1483+
}
1484+
14801485
shared_ptr<AclRule> AclRule::makeShared(AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple& data)
14811486
{
14821487
shared_ptr<AclRule> aclRule;
@@ -1624,6 +1629,13 @@ bool AclRule::createCounter()
16241629
bool AclRule::removeRanges()
16251630
{
16261631
SWSS_LOG_ENTER();
1632+
if (!m_ranges.size())
1633+
{
1634+
//The Acl Rules which have mirror action will not have ranges created till the mirror becomes active
1635+
SWSS_LOG_INFO("No Acl Range created for ACL Rule %s in table %s", m_id.c_str(), m_pTable->getId().c_str());
1636+
return true;
1637+
}
1638+
16271639
for (const auto& rangeConfig: m_rangeConfig)
16281640
{
16291641
if (!AclRange::remove(rangeConfig.rangeType, rangeConfig.min, rangeConfig.max))
@@ -1924,6 +1936,16 @@ bool AclRuleMirror::activate()
19241936
setAction(it.first, attr.value.aclaction);
19251937
}
19261938

1939+
// If the rule with mirror action is removed and then mirror is activated, create the counter before rule is created
1940+
if (!hasCounter())
1941+
{
1942+
if (getCreateCounter() && !createCounter())
1943+
{
1944+
SWSS_LOG_ERROR("createCounter failed for Rule %s session %s", m_id.c_str(), m_sessionName.c_str());
1945+
return false;
1946+
}
1947+
}
1948+
19271949
if (!AclRule::createRule())
19281950
{
19291951
return false;
@@ -2885,6 +2907,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
28852907
platform == MRVL_PLATFORM_SUBSTRING ||
28862908
platform == INVM_PLATFORM_SUBSTRING ||
28872909
platform == NPS_PLATFORM_SUBSTRING ||
2910+
platform == XS_PLATFORM_SUBSTRING ||
28882911
platform == VS_PLATFORM_SUBSTRING)
28892912
{
28902913
m_mirrorTableCapabilities =
@@ -2913,6 +2936,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
29132936
if (platform == MLNX_PLATFORM_SUBSTRING ||
29142937
platform == CISCO_8000_PLATFORM_SUBSTRING ||
29152938
platform == MRVL_PLATFORM_SUBSTRING ||
2939+
platform == XS_PLATFORM_SUBSTRING ||
29162940
(platform == BRCM_PLATFORM_SUBSTRING && sub_platform == BRCM_DNX_PLATFORM_SUBSTRING))
29172941
{
29182942
m_isCombinedMirrorV6Table = false;

orchagent/aclorch.h

+1
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ class AclRule
263263
sai_object_id_t getCounterOid() const;
264264
bool hasCounter() const;
265265
vector<sai_object_id_t> getInPorts() const;
266+
bool getCreateCounter() const;
266267

267268
const vector<AclRangeConfig>& getRangeConfig() const;
268269
static shared_ptr<AclRule> makeShared(AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple&);

orchagent/bfdorch.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ BfdOrch::BfdOrch(DBConnector *db, string tableName, TableConnector stateDbBfdSes
5959
DBConnector *notificationsDb = new DBConnector("ASIC_DB", 0);
6060
m_bfdStateNotificationConsumer = new swss::NotificationConsumer(notificationsDb, "NOTIFICATIONS");
6161
auto bfdStateNotificatier = new Notifier(m_bfdStateNotificationConsumer, this, "BFD_STATE_NOTIFICATIONS");
62+
63+
// Clean up state database BFD entries
64+
vector<string> keys;
65+
66+
m_stateBfdSessionTable.getKeys(keys);
67+
68+
for (auto alias : keys)
69+
{
70+
m_stateBfdSessionTable.del(alias);
71+
}
72+
6273
Orch::addExecutor(bfdStateNotificatier);
6374
register_state_change_notif = false;
6475
}

orchagent/bufferorch.cpp

+100-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "tokenize.h"
22
#include "bufferorch.h"
3+
#include "directory.h"
34
#include "logger.h"
45
#include "sai_serialize.h"
56
#include "warm_restart.h"
@@ -16,6 +17,7 @@ extern sai_switch_api_t *sai_switch_api;
1617
extern sai_buffer_api_t *sai_buffer_api;
1718

1819
extern PortsOrch *gPortsOrch;
20+
extern Directory<Orch*> gDirectory;
1921
extern sai_object_id_t gSwitchId;
2022

2123
#define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"
@@ -42,6 +44,9 @@ map<string, string> buffer_to_ref_table_map = {
4244
{buffer_profile_list_field_name, APP_BUFFER_PROFILE_TABLE_NAME}
4345
};
4446

47+
std::map<string, std::map<size_t, string>> pg_port_flags;
48+
std::map<string, std::map<size_t, string>> queue_port_flags;
49+
4550
BufferOrch::BufferOrch(DBConnector *applDb, DBConnector *confDb, DBConnector *stateDb, vector<string> &tableNames) :
4651
Orch(applDb, tableNames),
4752
m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)),
@@ -812,7 +817,54 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
812817
return handle_status;
813818
}
814819
}
820+
// create/remove a port queue counter for the queue buffer
821+
else
822+
{
823+
auto flexCounterOrch = gDirectory.get<FlexCounterOrch*>();
824+
auto queues = tokens[1];
825+
if (op == SET_COMMAND && flexCounterOrch->getQueueCountersState())
826+
{
827+
gPortsOrch->createPortBufferQueueCounters(port, queues);
828+
}
829+
else if (op == DEL_COMMAND && flexCounterOrch->getQueueCountersState())
830+
{
831+
gPortsOrch->removePortBufferQueueCounters(port, queues);
832+
}
833+
}
834+
}
835+
836+
/* when we apply buffer configuration we need to increase the ref counter of this port
837+
* or decrease the ref counter for this port when we remove buffer cfg
838+
* so for each priority cfg in each port we will increase/decrease the ref counter
839+
* also we need to know when the set command is for creating a buffer cfg or modifying buffer cfg -
840+
* we need to increase ref counter only on create flow.
841+
* so we added a map that will help us to know what was the last command for this port and priority -
842+
* if the last command was set command then it is a modify command and we dont need to increase the buffer counter
843+
* all other cases (no last command exist or del command was the last command) it means that we need to increase the ref counter */
844+
if (op == SET_COMMAND)
845+
{
846+
if (queue_port_flags[port_name][ind] != SET_COMMAND)
847+
{
848+
/* if the last operation was not "set" then it's create and not modify - need to increase ref counter */
849+
gPortsOrch->increasePortRefCount(port_name);
850+
}
851+
}
852+
else if (op == DEL_COMMAND)
853+
{
854+
if (queue_port_flags[port_name][ind] == SET_COMMAND)
855+
{
856+
/* we need to decrease ref counter only if the last operation was "SET_COMMAND" */
857+
gPortsOrch->decreasePortRefCount(port_name);
858+
}
859+
}
860+
else
861+
{
862+
SWSS_LOG_ERROR("operation value is not SET or DEL (op = %s)", op.c_str());
863+
return task_process_status::task_invalid_entry;
815864
}
865+
/* save the last command (set or delete) */
866+
queue_port_flags[port_name][ind] = op;
867+
816868
}
817869
}
818870

@@ -871,7 +923,7 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
871923
if (op == SET_COMMAND)
872924
{
873925
ref_resolve_status resolve_result = resolveFieldRefValue(m_buffer_type_maps, buffer_profile_field_name,
874-
buffer_to_ref_table_map.at(buffer_profile_field_name), tuple,
926+
buffer_to_ref_table_map.at(buffer_profile_field_name), tuple,
875927
sai_buffer_profile, buffer_profile_name);
876928
if (ref_resolve_status::success != resolve_result)
877929
{
@@ -944,8 +996,55 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
944996
return handle_status;
945997
}
946998
}
999+
// create or remove a port PG counter for the PG buffer
1000+
else
1001+
{
1002+
auto flexCounterOrch = gDirectory.get<FlexCounterOrch*>();
1003+
auto pgs = tokens[1];
1004+
if (op == SET_COMMAND && flexCounterOrch->getPgWatermarkCountersState())
1005+
{
1006+
gPortsOrch->createPortBufferPgCounters(port, pgs);
1007+
}
1008+
else if (op == DEL_COMMAND && flexCounterOrch->getPgWatermarkCountersState())
1009+
{
1010+
gPortsOrch->removePortBufferPgCounters(port, pgs);
1011+
}
1012+
}
9471013
}
9481014
}
1015+
1016+
/* when we apply buffer configuration we need to increase the ref counter of this port
1017+
* or decrease the ref counter for this port when we remove buffer cfg
1018+
* so for each priority cfg in each port we will increase/decrease the ref counter
1019+
* also we need to know when the set command is for creating a buffer cfg or modifying buffer cfg -
1020+
* we need to increase ref counter only on create flow.
1021+
* so we added a map that will help us to know what was the last command for this port and priority -
1022+
* if the last command was set command then it is a modify command and we dont need to increase the buffer counter
1023+
* all other cases (no last command exist or del command was the last command) it means that we need to increase the ref counter */
1024+
if (op == SET_COMMAND)
1025+
{
1026+
if (pg_port_flags[port_name][ind] != SET_COMMAND)
1027+
{
1028+
/* if the last operation was not "set" then it's create and not modify - need to increase ref counter */
1029+
gPortsOrch->increasePortRefCount(port_name);
1030+
}
1031+
}
1032+
else if (op == DEL_COMMAND)
1033+
{
1034+
if (pg_port_flags[port_name][ind] == SET_COMMAND)
1035+
{
1036+
/* we need to decrease ref counter only if the last operation was "SET_COMMAND" */
1037+
gPortsOrch->decreasePortRefCount(port_name);
1038+
}
1039+
}
1040+
else
1041+
{
1042+
SWSS_LOG_ERROR("operation value is not SET or DEL (op = %s)", op.c_str());
1043+
return task_process_status::task_invalid_entry;
1044+
}
1045+
/* save the last command (set or delete) */
1046+
pg_port_flags[port_name][ind] = op;
1047+
9491048
}
9501049
}
9511050

orchagent/bulker.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class EntityBulker
224224
auto& attrs = it->second.first;
225225
attrs.insert(attrs.end(), attr_list, attr_list + attr_count);
226226
it->second.second = object_status;
227-
SWSS_LOG_INFO("EntityBulker.create_entry %zu, %zu, %d, %d\n", creating_entries.size(), it->second.first.size(), (int)it->second.first[0].id, inserted);
227+
SWSS_LOG_INFO("EntityBulker.create_entry %zu, %zu, %d\n", creating_entries.size(), it->second.first.size(), inserted);
228228
*object_status = SAI_STATUS_NOT_EXECUTED;
229229
return *object_status;
230230
}

0 commit comments

Comments
 (0)