Skip to content

Commit

Permalink
[meta] Add support for ignored attributes names (sonic-net#836)
Browse files Browse the repository at this point in the history
During SAI development, some existing attributes could be deprecated and marked ignored in headers, but old value name still can be used in redis database in current running systems. When doing sonic upgrade, old value needs to be correctly interpreted and translated to new name. This PR addresses this issue.
  • Loading branch information
kcudnik authored Jun 16, 2021
1 parent c163238 commit d819f97
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions meta/saiserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3305,6 +3305,12 @@ void sai_deserialize_attr_id(

auto m = sai_metadata_get_attr_metadata_by_attr_id_name(s.c_str());

if (m == NULL)
{
// check ignored attributes names for backward compatibility
m = sai_metadata_get_ignored_attr_metadata_by_attr_id_name(s.c_str());
}

if (m == NULL)
{
SWSS_LOG_THROW("invalid attr id: %s", s.c_str());
Expand Down
8 changes: 8 additions & 0 deletions tests/BCM56850.pl
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,16 @@ sub test_sairedis_client
}
}

sub test_ignore_attributes
{
fresh_start;

play "ignore_attributes.rec";
}

# RUN TESTS

test_ignore_attributes;
test_sairedis_client;
test_macsec_p2p_establishment;
test_no_lag_label;
Expand Down
7 changes: 7 additions & 0 deletions tests/BCM56850/ignore_attributes.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
2017-06-14.01:55:46.543987|a|INIT_VIEW
2017-06-14.01:55:46.551164|A|SAI_STATUS_SUCCESS
2017-06-14.01:55:46.555975|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true
2017-06-14.01:56:05.520538|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_PORT_NUMBER=0
2017-06-14.01:56:05.525938|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_NUMBER=32
2017-06-14.01:56:06.151337|a|APPLY_VIEW
2017-06-14.01:56:06.156740|A|SAI_STATUS_SUCCESS

0 comments on commit d819f97

Please sign in to comment.