Skip to content

Commit

Permalink
[Mux orch] Handle setting unknown mux state (sonic-net#1984)
Browse files Browse the repository at this point in the history
* Mux handle 'unknown' state
  • Loading branch information
prsunny authored Oct 27, 2021
1 parent ac09bde commit 41fb26c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions orchagent/muxorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const map <string, MuxState> muxStateStringToVal =
{
{ "active", MuxState::MUX_STATE_ACTIVE },
{ "standby", MuxState::MUX_STATE_STANDBY },
{ "unknown", MuxState::MUX_STATE_STANDBY },
{ "init", MuxState::MUX_STATE_INIT },
{ "failed", MuxState::MUX_STATE_FAILED },
{ "pending", MuxState::MUX_STATE_PENDING },
Expand Down Expand Up @@ -396,6 +397,9 @@ void MuxCable::setState(string new_state)

MuxState ns = muxStateStringToVal.at(new_state);

/* Update new_state to handle unknown state */
new_state = muxStateValToString.at(ns);

auto it = muxStateTransition.find(make_pair(state_, ns));

if (it == muxStateTransition.end())
Expand Down
24 changes: 24 additions & 0 deletions tests/test_mux.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,30 @@ def create_and_test_acl(self, appdb, asicdb, dvs, dvs_acl):
self.set_mux_state(appdb, "Ethernet4", "active")
dvs_acl.verify_no_acl_rules()

# Set unknown state and verify the behavior as standby
self.set_mux_state(appdb, "Ethernet0", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

# Verify change while setting unknown from active
self.set_mux_state(appdb, "Ethernet4", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0","Ethernet4"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

self.set_mux_state(appdb, "Ethernet0", "active")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

self.set_mux_state(appdb, "Ethernet0", "standby")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0","Ethernet4"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

# Verify no change while setting unknown from standby
self.set_mux_state(appdb, "Ethernet0", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0","Ethernet4"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)


def create_and_test_metrics(self, appdb, statedb, dvs):

# Set to active and test attributes for start and end time
Expand Down

0 comments on commit 41fb26c

Please sign in to comment.