|
8 | 8 |
|
9 | 9 | #include <inttypes.h> |
10 | 10 |
|
| 11 | +#include <boost/algorithm/string/join.hpp> |
| 12 | + |
11 | 13 | #include <set> |
12 | 14 |
|
13 | 15 | // 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( |
3093 | 3095 | return SAI_STATUS_SUCCESS; |
3094 | 3096 | } |
3095 | 3097 |
|
| 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 | + |
3096 | 3117 | sai_status_t Meta::meta_sai_validate_outbound_routing_entry( |
3097 | 3118 | _In_ const sai_outbound_routing_entry_t* outbound_routing_entry, |
3098 | 3119 | _In_ bool create, |
@@ -3139,6 +3160,44 @@ sai_status_t Meta::meta_sai_validate_outbound_routing_entry( |
3139 | 3160 | return SAI_STATUS_SUCCESS; |
3140 | 3161 | } |
3141 | 3162 |
|
| 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 | + |
3142 | 3201 | sai_status_t Meta::meta_sai_validate_outbound_ca_to_pa_entry( |
3143 | 3202 | _In_ const sai_outbound_ca_to_pa_entry_t* outbound_ca_to_pa_entry, |
3144 | 3203 | _In_ bool create, |
@@ -3223,6 +3282,25 @@ sai_status_t Meta::meta_sai_validate_meter_bucket_entry( |
3223 | 3282 | return SAI_STATUS_NOT_IMPLEMENTED; |
3224 | 3283 | } |
3225 | 3284 |
|
| 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 | + |
3226 | 3304 | sai_status_t Meta::meta_generic_validation_create( |
3227 | 3305 | _In_ const sai_object_meta_key_t& meta_key, |
3228 | 3306 | _In_ sai_object_id_t switch_id, |
@@ -6744,24 +6822,14 @@ void Meta::meta_sai_on_port_state_change_single( |
6744 | 6822 |
|
6745 | 6823 | auto ot = objectTypeQuery(data.port_id); |
6746 | 6824 |
|
6747 | | - bool valid = false; |
| 6825 | + bool valid = isPortObjectIdValid(ot); |
6748 | 6826 |
|
6749 | | - switch (ot) |
| 6827 | + if (!valid) |
6750 | 6828 | { |
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()); |
6765 | 6833 | } |
6766 | 6834 |
|
6767 | 6835 | if (valid && !m_oids.objectReferenceExists(data.port_id)) |
@@ -7181,3 +7249,46 @@ void Meta::populate( |
7181 | 7249 | } |
7182 | 7250 | } |
7183 | 7251 | } |
| 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 | +} |
0 commit comments