Skip to content

Commit 0329d7d

Browse files
committed
2 parents 43b6f44 + e18530c commit 0329d7d

38 files changed

+1336
-43
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
jobs:
1717
analyze:
1818
name: Analyze
19-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-22.04
2020
permissions:
2121
actions: read
2222
contents: read
@@ -55,11 +55,11 @@ jobs:
5555
libzmq3-dev \
5656
libzmq5 \
5757
swig4.0 \
58-
libpython2.7-dev \
58+
libpython3-dev \
5959
libgtest-dev \
6060
libgmock-dev \
61-
libboost1.71-dev \
62-
libboost-serialization1.71-dev \
61+
libboost-dev \
62+
libboost-serialization-dev \
6363
dh-exec \
6464
doxygen \
6565
cdbs \
@@ -69,8 +69,7 @@ jobs:
6969
autoconf-archive \
7070
uuid-dev \
7171
libjansson-dev \
72-
nlohmann-json3-dev \
73-
python
72+
nlohmann-json3-dev
7473
7574
- if: matrix.language == 'cpp'
7675
name: Build sonic-swss-common
@@ -79,7 +78,7 @@ jobs:
7978
git clone https://github.com/sonic-net/sonic-swss-common
8079
pushd sonic-swss-common
8180
./autogen.sh
82-
dpkg-buildpackage -rfakeroot -us -uc -b -j$(nproc)
81+
dpkg-buildpackage -rfakeroot -us -uc -b -Pnoyangmod,nopython2 -j$(nproc)
8382
popd
8483
dpkg-deb -x libswsscommon_${SWSSCOMMON_VER}_amd64.deb $(dirname $GITHUB_WORKSPACE)
8584
dpkg-deb -x libswsscommon-dev_${SWSSCOMMON_VER}_amd64.deb $(dirname $GITHUB_WORKSPACE)

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
path = SAI
33
url = https://github.com/opencomputeproject/SAI.git
44
ignore = dirty
5-
branch = v1.3
5+
branch = v1.16

SAI

Submodule SAI updated 93 files

meta/Meta.cpp

Lines changed: 127 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <inttypes.h>
1010

11+
#include <boost/algorithm/string/join.hpp>
12+
1113
#include <set>
1214

1315
// TODO add validation for all oids belong to the same switch
@@ -3093,6 +3095,25 @@ sai_status_t Meta::meta_sai_validate_pa_validation_entry(
30933095
return SAI_STATUS_SUCCESS;
30943096
}
30953097

3098+
sai_status_t Meta::meta_sai_validate_outbound_port_map_port_range_entry(
3099+
_In_ const sai_outbound_port_map_port_range_entry_t* outbound_port_map_entry,
3100+
_In_ bool create,
3101+
_In_ bool get)
3102+
{
3103+
SWSS_LOG_ENTER();
3104+
3105+
if (outbound_port_map_entry == NULL)
3106+
{
3107+
SWSS_LOG_ERROR("outbound_port_map_entry pointer is NULL");
3108+
3109+
return SAI_STATUS_INVALID_PARAMETER;
3110+
}
3111+
3112+
// TODO FIX ME
3113+
3114+
return SAI_STATUS_NOT_IMPLEMENTED;
3115+
}
3116+
30963117
sai_status_t Meta::meta_sai_validate_outbound_routing_entry(
30973118
_In_ const sai_outbound_routing_entry_t* outbound_routing_entry,
30983119
_In_ bool create,
@@ -3139,6 +3160,44 @@ sai_status_t Meta::meta_sai_validate_outbound_routing_entry(
31393160
return SAI_STATUS_SUCCESS;
31403161
}
31413162

3163+
sai_status_t Meta::meta_sai_validate_global_trusted_vni_entry(
3164+
_In_ const sai_global_trusted_vni_entry_t* global_trusted_vni_entry,
3165+
_In_ bool create,
3166+
_In_ bool get)
3167+
{
3168+
SWSS_LOG_ENTER();
3169+
3170+
if (global_trusted_vni_entry == NULL)
3171+
{
3172+
SWSS_LOG_ERROR("global_trusted_vni_entry pointer is NULL");
3173+
3174+
return SAI_STATUS_INVALID_PARAMETER;
3175+
}
3176+
3177+
// TODO FIX ME
3178+
3179+
return SAI_STATUS_NOT_IMPLEMENTED;
3180+
}
3181+
3182+
sai_status_t Meta::meta_sai_validate_eni_trusted_vni_entry(
3183+
_In_ const sai_eni_trusted_vni_entry_t* eni_trusted_vni_entry,
3184+
_In_ bool create,
3185+
_In_ bool get)
3186+
{
3187+
SWSS_LOG_ENTER();
3188+
3189+
if (eni_trusted_vni_entry == NULL)
3190+
{
3191+
SWSS_LOG_ERROR("eni_trusted_vni_entry pointer is NULL");
3192+
3193+
return SAI_STATUS_INVALID_PARAMETER;
3194+
}
3195+
3196+
// TODO FIX ME
3197+
3198+
return SAI_STATUS_NOT_IMPLEMENTED;
3199+
}
3200+
31423201
sai_status_t Meta::meta_sai_validate_outbound_ca_to_pa_entry(
31433202
_In_ const sai_outbound_ca_to_pa_entry_t* outbound_ca_to_pa_entry,
31443203
_In_ bool create,
@@ -3223,6 +3282,25 @@ sai_status_t Meta::meta_sai_validate_meter_bucket_entry(
32233282
return SAI_STATUS_NOT_IMPLEMENTED;
32243283
}
32253284

3285+
sai_status_t Meta::meta_sai_validate_prefix_compression_entry(
3286+
_In_ const sai_prefix_compression_entry_t* prefix_compression_entry,
3287+
_In_ bool create,
3288+
_In_ bool get)
3289+
{
3290+
SWSS_LOG_ENTER();
3291+
3292+
if (prefix_compression_entry == NULL)
3293+
{
3294+
SWSS_LOG_ERROR("prefix_compression_entry pointer is NULL");
3295+
3296+
return SAI_STATUS_INVALID_PARAMETER;
3297+
}
3298+
3299+
// TODO FIX ME
3300+
3301+
return SAI_STATUS_NOT_IMPLEMENTED;
3302+
}
3303+
32263304
sai_status_t Meta::meta_generic_validation_create(
32273305
_In_ const sai_object_meta_key_t& meta_key,
32283306
_In_ sai_object_id_t switch_id,
@@ -6744,24 +6822,14 @@ void Meta::meta_sai_on_port_state_change_single(
67446822

67456823
auto ot = objectTypeQuery(data.port_id);
67466824

6747-
bool valid = false;
6825+
bool valid = isPortObjectIdValid(ot);
67486826

6749-
switch (ot)
6827+
if (!valid)
67506828
{
6751-
// TODO hardcoded types, must advance SAI repository commit to get metadata for this
6752-
case SAI_OBJECT_TYPE_PORT:
6753-
case SAI_OBJECT_TYPE_BRIDGE_PORT:
6754-
case SAI_OBJECT_TYPE_LAG:
6755-
6756-
valid = true;
6757-
break;
6758-
6759-
default:
6760-
6761-
SWSS_LOG_ERROR("data.port_id %s has unexpected type: %s, expected PORT, BRIDGE_PORT or LAG",
6762-
sai_serialize_object_id(data.port_id).c_str(),
6763-
sai_serialize_object_type(ot).c_str());
6764-
break;
6829+
SWSS_LOG_ERROR("data.port_id %s has unexpected type: %s, expected: %s",
6830+
sai_serialize_object_id(data.port_id).c_str(),
6831+
sai_serialize_object_type(ot).c_str(),
6832+
boost::algorithm::join(getValidPortObjectTypes(), ",").c_str());
67656833
}
67666834

67676835
if (valid && !m_oids.objectReferenceExists(data.port_id))
@@ -7181,3 +7249,46 @@ void Meta::populate(
71817249
}
71827250
}
71837251
}
7252+
7253+
bool Meta::isPortObjectIdValid(
7254+
_In_ sai_object_type_t object_type)
7255+
{
7256+
SWSS_LOG_ENTER();
7257+
7258+
auto members = sai_metadata_struct_members_sai_port_oper_status_notification_t;
7259+
7260+
for (size_t i = 0; members[i]; i++)
7261+
{
7262+
auto* mb = members[i];
7263+
7264+
if (mb->membername != std::string("port_id"))
7265+
continue;
7266+
7267+
for (size_t idx = 0; idx < mb->allowedobjecttypeslength; idx++)
7268+
{
7269+
if (mb->allowedobjecttypes[idx] == object_type)
7270+
return true;
7271+
}
7272+
7273+
return false;
7274+
}
7275+
7276+
SWSS_LOG_THROW("port_id member not found on sai_port_oper_status_notification");
7277+
}
7278+
7279+
std::vector<std::string> Meta::getValidPortObjectTypes()
7280+
{
7281+
SWSS_LOG_ENTER();
7282+
7283+
auto md = sai_metadata_enum_sai_object_type_t;
7284+
7285+
std::vector<std::string> v;
7286+
7287+
for (size_t i = 0; i < md.valuescount; i++)
7288+
{
7289+
if (isPortObjectIdValid((sai_object_type_t)md.values[i]))
7290+
v.push_back(md.valuesshortnames[i]);
7291+
}
7292+
7293+
return v;
7294+
}

meta/Meta.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ namespace saimeta
320320
static bool is_ipv6_mask_valid(
321321
_In_ const uint8_t* mask);
322322

323+
static bool isPortObjectIdValid(
324+
_In_ sai_object_type_t object_type);
325+
326+
static std::vector<std::string> getValidPortObjectTypes();
327+
323328
private: // unit tests helpers
324329

325330
bool meta_unittests_get_and_erase_set_readonly_flag(
@@ -544,11 +549,26 @@ namespace saimeta
544549
_In_ bool create,
545550
_In_ bool get = false);
546551

552+
sai_status_t meta_sai_validate_outbound_port_map_port_range_entry(
553+
_In_ const sai_outbound_port_map_port_range_entry_t* outbound_port_map_entry,
554+
_In_ bool create,
555+
_In_ bool get = false);
556+
547557
sai_status_t meta_sai_validate_outbound_routing_entry(
548558
_In_ const sai_outbound_routing_entry_t* outbound_routing_entry,
549559
_In_ bool create,
550560
_In_ bool get = false);
551561

562+
sai_status_t meta_sai_validate_global_trusted_vni_entry(
563+
_In_ const sai_global_trusted_vni_entry_t* global_trusted_vni_entry,
564+
_In_ bool create,
565+
_In_ bool get = false);
566+
567+
sai_status_t meta_sai_validate_eni_trusted_vni_entry(
568+
_In_ const sai_eni_trusted_vni_entry_t* eni_trusted_vni_entry,
569+
_In_ bool create,
570+
_In_ bool get = false);
571+
552572
sai_status_t meta_sai_validate_outbound_ca_to_pa_entry(
553573
_In_ const sai_outbound_ca_to_pa_entry_t* outbound_ca_to_pa_entry,
554574
_In_ bool create,
@@ -564,6 +584,11 @@ namespace saimeta
564584
_In_ bool create,
565585
_In_ bool get = false);
566586

587+
sai_status_t meta_sai_validate_prefix_compression_entry(
588+
_In_ const sai_prefix_compression_entry_t* prefix_compression_entry,
589+
_In_ bool create,
590+
_In_ bool get = false);
591+
567592
public:
568593

569594
/*

meta/SaiInterface.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,20 @@ sai_status_t SaiInterface::clearStats(
378378

379379
return SAI_STATUS_NOT_IMPLEMENTED;
380380
}
381+
382+
std::shared_ptr<SaiOptions> SaiInterface::getOptions(
383+
_In_ const std::string& key)
384+
{
385+
SWSS_LOG_ENTER();
386+
387+
return m_optionsMap[key];
388+
}
389+
390+
void SaiInterface::setOptions(
391+
_In_ const std::string& key,
392+
_In_ std::shared_ptr<SaiOptions> options)
393+
{
394+
SWSS_LOG_ENTER();
395+
396+
m_optionsMap[key] = options;
397+
}

meta/SaiInterface.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ extern "C" {
55
#include "saimetadata.h"
66
}
77

8+
#include "SaiOptions.h"
9+
10+
#include <map>
11+
#include <memory>
12+
#include <string>
13+
814
#define SAIREDIS_DECLARE_EVERY_ENTRY(_X) \
915
SAI_METADATA_DECLARE_EVERY_ENTRY(_X)
1016

@@ -345,5 +351,18 @@ namespace sairedis
345351

346352
virtual sai_log_level_t logGet(
347353
_In_ sai_api_t api);
354+
355+
public: // non SAI API - options helper
356+
357+
std::shared_ptr<SaiOptions> getOptions(
358+
_In_ const std::string& key);
359+
360+
void setOptions(
361+
_In_ const std::string& key,
362+
_In_ std::shared_ptr<SaiOptions> options);
363+
364+
private:
365+
366+
std::map<std::string, std::shared_ptr<SaiOptions>> m_optionsMap;
348367
};
349368
}

meta/SaiOptions.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
namespace sairedis
4+
{
5+
class SaiOptions
6+
{
7+
public:
8+
9+
virtual ~SaiOptions() = default;
10+
};
11+
}

0 commit comments

Comments
 (0)