Skip to content

Commit 1b2a8e6

Browse files
[copp]: Use non-zero trap priority for default trap group (sonic-net#3502)
* Use non-zero trap priority for default trap group This priority is used internally in some vendor SAI implementations and causes undesirable packet trapping behavior. How I verified it By running copp tests which include rate-limiting tests for TTL 1 packets on on Cisco/Mellanox/Arista platforms. By manual tests with TTL 1 packets generated by scapy
1 parent a0fcac9 commit 1b2a8e6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

orchagent/copporch.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,17 @@ void CoppOrch::initDefaultTrapIds()
188188
attr.value.oid = m_trap_group_map[default_trap_group];
189189
trap_id_attrs.push_back(attr);
190190

191-
/* Mellanox platform doesn't support trap priority setting */
192-
/* Marvell platform doesn't support trap priority. */
191+
/*
192+
* Use a default trap priority > 0 to avoid undesirable packet trapping
193+
* behavior on some platforms that use 0 as default SAI-internal priority.
194+
* Note: Mellanox and Marvell platforms don't support trap priority setting.
195+
*/
196+
193197
char *platform = getenv("platform");
194198
if (!platform || (!strstr(platform, MLNX_PLATFORM_SUBSTRING) && (!strstr(platform, MRVL_PRST_PLATFORM_SUBSTRING))))
195199
{
196200
attr.id = SAI_HOSTIF_TRAP_ATTR_TRAP_PRIORITY;
197-
attr.value.u32 = 0;
201+
attr.value.u32 = 1;
198202
trap_id_attrs.push_back(attr);
199203
}
200204

tests/test_copp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ def validate_trap_group(self, trap_oid, trap_group):
232232
queue = ""
233233
trap_action = ""
234234
trap_priority = ""
235+
default_trap_queue = "0"
236+
default_trap_prio = "1"
235237

236238
for fv in trap_fvs:
237239
if fv[0] == "SAI_HOSTIF_TRAP_ATTR_PACKET_ACTION":
@@ -262,6 +264,11 @@ def validate_trap_group(self, trap_oid, trap_group):
262264
assert trap_group_oid != "oid:0x0"
263265
if keys == "queue":
264266
assert queue == trap_group[keys]
267+
# default trap in copp config doesn't specify a trap priority
268+
# this is instead set internally in swss
269+
# confirm that default trap uses a priority 1
270+
if queue == default_trap_queue:
271+
assert trap_priority == default_trap_prio
265272
else:
266273
assert 0
267274

0 commit comments

Comments
 (0)