Skip to content

Commit 381c014

Browse files
authored
Capability query for MACSEC ACL attribute (#3385)
What I did -Modified the MACsec orchestration logic to conditionally include or exclude the ability to match the SCI in ACL configurations based on the ASIC's capabilities. -Implemented a capability check in SONiC to determine whether the SAI_ACL_TABLE_ATTR_FIELD_MACSEC_SCI attribute is supported by the ASIC, thus ensuring that neither SAI_ACL_TABLE_ATTR_FIELD_MACSEC_SCI nor SAI_ACL_ENTRY_ATTR_FIELD_MACSEC_SCI is used when unsupported. Why I did it The current implementation attempts to use the SAI_ACL_ENTRY_ATTR_FIELD_MACSEC_SCI attribute even when it's not supported by the underlying ASIC or driver, causing failures in the vendor's SAI/SDK code. The capability check prevents these errors, ensuring compatibility with different hardware.
1 parent c20902f commit 381c014

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

orchagent/macsecorch.cpp

+19-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern sai_switch_api_t *sai_switch_api;
3838
constexpr bool DEFAULT_ENABLE_ENCRYPT = true;
3939
constexpr bool DEFAULT_SCI_IN_SECTAG = false;
4040
constexpr sai_macsec_cipher_suite_t DEFAULT_CIPHER_SUITE = SAI_MACSEC_CIPHER_SUITE_GCM_AES_128;
41+
bool saiAclFieldSciMatchSupported = true;
4142

4243
static const std::vector<std::string> macsec_sa_attrs =
4344
{
@@ -637,6 +638,17 @@ MACsecOrch::MACsecOrch(
637638
MACSEC_STAT_POLLING_INTERVAL_MS, true)
638639
{
639640
SWSS_LOG_ENTER();
641+
sai_attr_capability_t capability;
642+
if (sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_ACL_TABLE,
643+
SAI_ACL_TABLE_ATTR_FIELD_MACSEC_SCI,
644+
&capability) == SAI_STATUS_SUCCESS)
645+
{
646+
if (capability.create_implemented == false)
647+
{
648+
SWSS_LOG_DEBUG("SAI_ACL_TABLE_ATTR_FIELD_MACSEC_SCI is not supported");
649+
saiAclFieldSciMatchSupported = false;
650+
}
651+
}
640652
}
641653

642654
MACsecOrch::~MACsecOrch()
@@ -2570,9 +2582,12 @@ bool MACsecOrch::createMACsecACLTable(
25702582
attr.value.booldata = true;
25712583
attrs.push_back(attr);
25722584

2573-
attr.id = SAI_ACL_TABLE_ATTR_FIELD_MACSEC_SCI;
2574-
attr.value.booldata = sci_in_sectag;
2575-
attrs.push_back(attr);
2585+
if (saiAclFieldSciMatchSupported == true)
2586+
{
2587+
attr.id = SAI_ACL_TABLE_ATTR_FIELD_MACSEC_SCI;
2588+
attr.value.booldata = sci_in_sectag;
2589+
attrs.push_back(attr);
2590+
}
25762591

25772592
sai_status_t status = sai_acl_api->create_acl_table(
25782593
&table_id,
@@ -2738,7 +2753,7 @@ bool MACsecOrch::createMACsecACLDataEntry(
27382753
attr.value.aclaction.parameter.s32 = SAI_PACKET_ACTION_DROP;
27392754
attr.value.aclaction.enable = true;
27402755
attrs.push_back(attr);
2741-
if (sci_in_sectag)
2756+
if ((saiAclFieldSciMatchSupported == true) && sci_in_sectag)
27422757
{
27432758
attr.id = SAI_ACL_ENTRY_ATTR_FIELD_MACSEC_SCI;
27442759
attr.value.aclfield.enable = true;

0 commit comments

Comments
 (0)