Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to not miss the entire set of counters to be added in addObject for CounterContext::updateSupportedCount #1493

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

judyjoseph
Copy link
Contributor

@judyjoseph judyjoseph commented Jan 7, 2025

Fixes issue: sonic-net/sonic-buildimage#21232

In MACSEC there are two set of counters one for INGRESS another for EGRESS which gets mapped to the same COUNTER type - CounterType::MACSEC_SA ( https://github.com/sonic-net/sonic-swss/blob/c20902f3195b5bf8a941045e131aa1b863b69fd0/orchagent/macsecorch.cpp#L2145 )

In the releases after 202205 we started seeing this behavior where the MACSEC RX counters were missing as mentioned in the issue 21232. Further debugging pointed to issue seen after this PR : #1073 was merged.

In this case when macsec orch tries to addCounter for INGRESS SA after the EGRESS SA, and it don't go through as the m_supportedCounters is not empty.

For a fix I am removing the check in CounterContext::updateSupportedCount, which I think is ok as we anyways do a check later on in getSupportedCounters() API using isCounterSupported() before calling collectData()

if (isCounterSupported(counter))

After the fix the macsec SA ingress counters are seen

                ---------------------------------------  ----------------------------------------------------------------
MACsec port(Ethernet216)
---------------------  ---------------
cipher_suite           GCM-AES-XPN-256
enable                 true
enable_encrypt         true
enable_protect         true
enable_replay_protect  false
profile                MACSEC_PROFILE
replay_window          0
send_sci               true
---------------------  ---------------
        MACsec Egress SC (xxx)
        -----------  -
        encoding_an  0
        -----------  -
                MACsec Egress SA (0)
                -------------------------------------  ----------------------------------------------------------------
                auth_key                               xxx
                next_pn                                1
                sak                                    xxx
                salt                                   xxx
                ssci                                   1
                SAI_MACSEC_SA_ATTR_CURRENT_XPN         99
                SAI_MACSEC_SA_STAT_OCTETS_ENCRYPTED    17947
                SAI_MACSEC_SA_STAT_OCTETS_PROTECTED    0
                SAI_MACSEC_SA_STAT_OUT_PKTS_ENCRYPTED  98
                SAI_MACSEC_SA_STAT_OUT_PKTS_PROTECTED  0
                -------------------------------------  ----------------------------------------------------------------
        MACsec Ingress SC (xxx)
                MACsec Ingress SA (0)
                ---------------------------------------  ----------------------------------------------------------------
                active                                   true
                auth_key                                 xxx
                lowest_acceptable_pn                     1
                sak                                      xxx
                salt                                     xxx
                ssci                                     2
                SAI_MACSEC_SA_ATTR_CURRENT_XPN           203
                SAI_MACSEC_SA_STAT_IN_PKTS_DELAYED       0                              <<<<<<<<<<<<<<<<<<<<
                SAI_MACSEC_SA_STAT_IN_PKTS_INVALID       0
                SAI_MACSEC_SA_STAT_IN_PKTS_LATE          0
                SAI_MACSEC_SA_STAT_IN_PKTS_NOT_USING_SA  0
                SAI_MACSEC_SA_STAT_IN_PKTS_NOT_VALID     0
                SAI_MACSEC_SA_STAT_IN_PKTS_OK            5
                SAI_MACSEC_SA_STAT_IN_PKTS_UNCHECKED     0
                SAI_MACSEC_SA_STAT_IN_PKTS_UNUSED_SA     0
                SAI_MACSEC_SA_STAT_OCTETS_ENCRYPTED      512
                SAI_MACSEC_SA_STAT_OCTETS_PROTECTED      0                          <<<<<<<<<<<<<<<<<<<<<
                ---------------------------------------  ----------------------------------------------------------------

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@judyjoseph judyjoseph changed the title Remove check to see if m_supportedCounters is empty in CounterContext::updateSupportedCount Remove !m_supportedCounters.empty check in CounterContext::updateSupportedCount Jan 7, 2025
@Junchao-Mellanox
Copy link
Contributor

Maybe we can set always_check_supported_counters to true for macsec counters?

@judyjoseph
Copy link
Contributor Author

Maybe we can set always_check_supported_counters to true for macsec counters?

I thought of this approach, but from code I see it resets the current m_supportedCounters counter list -- which will not help, as it clears the existing list ?

    if (always_check_supported_counters)
    {
        m_supportedCounters.clear();
    }

@Junchao-Mellanox
Copy link
Contributor

Removing the check will cause it check supported counter each time adding an object. I am afraid it will cause performance degradation. Could you please add one more attribute like dont_clear_support_counter and set it to true for macsec counter?

@judyjoseph judyjoseph changed the title Remove !m_supportedCounters.empty check in CounterContext::updateSupportedCount Fix to not miss the entire set of counters to be added in addObject for CounterContext::updateSupportedCount Jan 7, 2025
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@judyjoseph judyjoseph requested a review from kcudnik January 7, 2025 21:10
@judyjoseph
Copy link
Contributor Author

judyjoseph commented Jan 7, 2025

Removing the check will cause it check supported counter each time adding an object. I am afraid it will cause performance degradation. Could you please add one more attribute like dont_clear_support_counter and set it to true for macsec counter?

Added a new flag 'dont_clear_support_counter', do review

@rlhui rlhui added the P0 label Jan 8, 2025
@rlhui rlhui requested a review from liamkearney-msft January 8, 2025 18:26
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liamkearney-msft
Copy link

can you add a snippit of the macsec counters tests run on this change? thanks

@judyjoseph
Copy link
Contributor Author

can you add a snippit of the macsec counters tests run on this change? thanks

I have updated the PR description with the show macsec o/p. Will add the test result also soon.

@judyjoseph judyjoseph merged commit 9697baf into sonic-net:master Jan 9, 2025
15 checks passed
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202405: #1503

@mssonicbld
Copy link
Collaborator

@judyjoseph cherry pick PR didn't pass PR checker. Please check!!!
#1503

3 similar comments
@mssonicbld
Copy link
Collaborator

@judyjoseph cherry pick PR didn't pass PR checker. Please check!!!
#1503

@mssonicbld
Copy link
Collaborator

@judyjoseph cherry pick PR didn't pass PR checker. Please check!!!
#1503

@mssonicbld
Copy link
Collaborator

@judyjoseph cherry pick PR didn't pass PR checker. Please check!!!
#1503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants