diff --git a/orchagent/muxorch.cpp b/orchagent/muxorch.cpp index eeae6b4cb2aa..4131b5a2357d 100644 --- a/orchagent/muxorch.cpp +++ b/orchagent/muxorch.cpp @@ -76,6 +76,7 @@ const map 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 }, @@ -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()) diff --git a/tests/test_mux.py b/tests/test_mux.py index c9aa578f7956..e9eb027a9d1b 100644 --- a/tests/test_mux.py +++ b/tests/test_mux.py @@ -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