Skip to content

Commit

Permalink
Assume ntf pointers are the same if both set, or both are nullptr (so…
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored and lguohan committed May 19, 2019
1 parent 1b0d609 commit 0f6144c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions saiplayer/saiplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ void update_notifications_pointers(
continue;
}

if (attr.value.ptr == nullptr) // allow nulls
continue;

switch (attr.id)
{
Expand Down
24 changes: 24 additions & 0 deletions syncd/syncd_applyview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2241,6 +2241,30 @@ bool hasEqualAttribute(
const auto &currentAttr = current->getSaiAttr(id);
const auto &temporaryAttr = temporary->getSaiAttr(id);

if (currentAttr->getAttrMetadata()->attrvaluetype == SAI_ATTR_VALUE_TYPE_POINTER)
{
auto c = currentAttr->getSaiAttr()->value.ptr;
auto t = temporaryAttr->getSaiAttr()->value.ptr;

/*
* When comparing pointers, actual value's can't be checked since
* actual value is pointer in sairedis/OA address space. Syncd
* translates those pointers before executing SAI API. Pointers are
* considered equal if they are both null, or both not null since
* the same handler method in syncd is used.
*/

if (c == nullptr && t == nullptr)
return true;

if (c != nullptr && t != nullptr)
return true;

SWSS_LOG_NOTICE("current ptr on %s is %p, tmp ptr is %p", currentAttr->getAttrMetadata()->attridname, c, t);

return false;
}

if (currentAttr->getStrAttrValue() == temporaryAttr->getStrAttrValue())
{
/*
Expand Down
14 changes: 14 additions & 0 deletions tests/brcm.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/perl

BEGIN { push @INC,'.'; }

use strict;
use warnings;
use diagnostics;
Expand Down Expand Up @@ -419,8 +421,20 @@ sub test_acl_mask
for (1..8) { play "acl_mask.rec", 0; }
}

sub test_ntf
{
fresh_start;

play "ntf1.rec";
play "ntf2.rec", 1;
play "ntf2.rec", 0;
play "ntf1.rec", 1;
play "ntf1.rec", 0;
}

# RUN TESTS

test_ntf;
test_acl_mask;
test_empty_lag_buffer_acl;
test_brcm_config_acl;
Expand Down
5 changes: 5 additions & 0 deletions tests/brcm/ntf1.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
2019-02-14.20:16:47.696163|a|INIT_VIEW
2019-02-14.20:17:09.080480|A|SAI_STATUS_SUCCESS
2019-02-14.20:17:09.083395|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true|SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY=0x42c410|SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY=0x42c420|SAI_SWITCH_ATTR_SWITCH_SHUTDOWN_REQUEST_NOTIFY=0x42c430|SAI_SWITCH_ATTR_SRC_MAC_ADDRESS=00:1C:73:F1:55:AE
2019-02-14.20:17:14.021109|a|APPLY_VIEW
2019-02-14.20:17:09.080480|A|SAI_STATUS_SUCCESS
5 changes: 5 additions & 0 deletions tests/brcm/ntf2.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
2019-02-14.20:16:47.696163|a|INIT_VIEW
2019-02-14.20:17:09.080480|A|SAI_STATUS_SUCCESS
2019-02-14.20:17:09.083395|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true|SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY=0x52c410|SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY=0x52c420|SAI_SWITCH_ATTR_SWITCH_SHUTDOWN_REQUEST_NOTIFY=0x0|SAI_SWITCH_ATTR_SRC_MAC_ADDRESS=00:1C:73:F1:55:AE
2019-02-14.20:17:14.021109|a|APPLY_VIEW
2019-02-14.20:17:09.080480|A|SAI_STATUS_SUCCESS

0 comments on commit 0f6144c

Please sign in to comment.