diff --git a/orchagent/dash/dashorch.cpp b/orchagent/dash/dashorch.cpp index 95dde9f888..d7c7818e5a 100644 --- a/orchagent/dash/dashorch.cpp +++ b/orchagent/dash/dashorch.cpp @@ -277,9 +277,11 @@ bool DashOrch::setEniAdminState(const string& eni, const EniEntry& entry) { SWSS_LOG_ENTER(); + bool eni_enable = entry.metadata.admin_state() == dash::eni::State::STATE_ENABLED; + sai_attribute_t eni_attr; eni_attr.id = SAI_ENI_ATTR_ADMIN_STATE; - eni_attr.value.booldata = entry.metadata.admin_state(); + eni_attr.value.booldata = eni_enable; sai_status_t status = sai_dash_eni_api->set_eni_attribute(eni_entries_[eni].eni_id, &eni_attr); @@ -293,7 +295,7 @@ bool DashOrch::setEniAdminState(const string& eni, const EniEntry& entry) } } eni_entries_[eni].metadata.set_admin_state(entry.metadata.admin_state()); - SWSS_LOG_NOTICE("Set ENI %s admin state to %s", eni.c_str(), entry.metadata.admin_state() ? "UP" : "DOWN"); + SWSS_LOG_NOTICE("Set ENI %s admin state to %s", eni.c_str(), eni_enable ? "UP" : "DOWN"); return true; } diff --git a/tests/test_dash_vnet.py b/tests/test_dash_vnet.py index 031fd7a0ef..ec9c56b2a0 100644 --- a/tests/test_dash_vnet.py +++ b/tests/test_dash_vnet.py @@ -223,6 +223,17 @@ def test_eni(self, dvs): for fv in fvs.items(): if fv[0] == "SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID": assert fv[1] == str(self.eni_oid) + + # test admin state update + pb.admin_state = State.STATE_DISABLED + dashobj.create_eni(self.mac_string, {"pb": pb.SerializeToString()}) + time.sleep(3) + enis = dashobj.asic_eni_table.get_keys() + assert len(enis) == 1 + assert enis[0] == self.eni_oid + eni_attrs = dashobj.asic_eni_table[self.eni_oid] + assert eni_attrs["SAI_ENI_ATTR_ADMIN_STATE"] == "false" + return dashobj def test_vnet_map(self, dvs):