-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MACsec]: Fix Bug: MACsec device will be terminated exceptionally if …
…the MACsec port was disabled in runtime (#875) * Add MACsec filter state guard Signed-off-by: Ze Gan <ganze718@gmail.com> * Add volatile qualifer for state Signed-off-by: Ze Gan <ganze718@gmail.com> * Polish code format Signed-off-by: Ze Gan <ganze718@gmail.com> * Fix the macsec device was shutdown by ouutside Signed-off-by: Ze Gan <ganze718@gmail.com> * fix typo Signed-off-by: Ze Gan <ganze718@gmail.com> * Remove overkill qualifier Signed-off-by: Ze Gan <ganze718@gmail.com> * fix typo Signed-off-by: Ze Gan <ganze718@gmail.com> * Fix spell warning Signed-off-by: Ze Gan <ganze718@gmail.com> * Fix bug Signed-off-by: Ze Gan <ganze718@gmail.com> * Format code Signed-off-by: Ze Gan <ganze718@gmail.com> * Fix unittest Signed-off-by: Ze Gan <ganze718@gmail.com> * Add unittest for State guard Signed-off-by: Ze Gan <ganze718@gmail.com> * Update Makefile.am for testing MACsec Filter State Guard Signed-off-by: Ze Gan <ganze718@gmail.com>
- Loading branch information
Showing
12 changed files
with
161 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "MACsecFilterStateGuard.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
using namespace saivs; | ||
|
||
TEST(MACsecFilterStateGuard, ctr) | ||
{ | ||
MACsecFilter::MACsecFilterState state = MACsecFilter::MACsecFilterState::MACSEC_FILTER_STATE_IDLE; | ||
|
||
{ | ||
MACsecFilterStateGuard guard(state, MACsecFilter::MACsecFilterState::MACSEC_FILTER_STATE_BUSY); | ||
|
||
EXPECT_EQ(state, MACsecFilter::MACsecFilterState::MACSEC_FILTER_STATE_BUSY); | ||
} | ||
|
||
EXPECT_EQ(state, MACsecFilter::MACsecFilterState::MACSEC_FILTER_STATE_IDLE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "MACsecFilterStateGuard.h" | ||
|
||
#include <swss/logger.h> | ||
|
||
using namespace saivs; | ||
|
||
MACsecFilterStateGuard::MACsecFilterStateGuard( | ||
_Inout_ MACsecFilter::MACsecFilterState &guarded_state, | ||
_In_ MACsecFilter::MACsecFilterState target_state): | ||
m_guarded_state(guarded_state) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_old_state = m_guarded_state; | ||
m_guarded_state = target_state; | ||
} | ||
|
||
MACsecFilterStateGuard::~MACsecFilterStateGuard() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_guarded_state = m_old_state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "MACsecFilter.h" | ||
|
||
namespace saivs | ||
{ | ||
class MACsecFilterStateGuard | ||
{ | ||
public: | ||
|
||
MACsecFilterStateGuard( | ||
_Inout_ MACsecFilter::MACsecFilterState &guarded_state, | ||
_In_ MACsecFilter::MACsecFilterState target_state); | ||
|
||
~MACsecFilterStateGuard(); | ||
|
||
private: | ||
|
||
MACsecFilter::MACsecFilterState m_old_state; | ||
MACsecFilter::MACsecFilterState &m_guarded_state; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters