From d819f9745dcd89bf276602e3eaaf9f2944a90375 Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Wed, 16 Jun 2021 11:56:45 +0200 Subject: [PATCH] [meta] Add support for ignored attributes names (#836) 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. --- meta/saiserialize.cpp | 6 ++++++ tests/BCM56850.pl | 8 ++++++++ tests/BCM56850/ignore_attributes.rec | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/BCM56850/ignore_attributes.rec diff --git a/meta/saiserialize.cpp b/meta/saiserialize.cpp index d05a655999e9..6f67a92bc16b 100644 --- a/meta/saiserialize.cpp +++ b/meta/saiserialize.cpp @@ -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()); diff --git a/tests/BCM56850.pl b/tests/BCM56850.pl index fd2d34671d2e..c541891c2c0d 100755 --- a/tests/BCM56850.pl +++ b/tests/BCM56850.pl @@ -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; diff --git a/tests/BCM56850/ignore_attributes.rec b/tests/BCM56850/ignore_attributes.rec new file mode 100644 index 000000000000..2d8e3fa01feb --- /dev/null +++ b/tests/BCM56850/ignore_attributes.rec @@ -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