diff --git a/orchagent/dash/dashvnetorch.cpp b/orchagent/dash/dashvnetorch.cpp index 18cd692505..a143c31484 100644 --- a/orchagent/dash/dashvnetorch.cpp +++ b/orchagent/dash/dashvnetorch.cpp @@ -274,7 +274,7 @@ void DashVnetOrch::doTaskVnetTable(ConsumerBase& consumer) } } -void DashVnetOrch::addOutboundCaToPa(const string& key, VnetMapBulkContext& ctxt) +bool DashVnetOrch::addOutboundCaToPa(const string& key, VnetMapBulkContext& ctxt) { SWSS_LOG_ENTER(); @@ -291,6 +291,7 @@ void DashVnetOrch::addOutboundCaToPa(const string& key, VnetMapBulkContext& ctxt if (!dash_orch->getRouteTypeActions(ctxt.metadata.routing_type(), route_type_actions)) { SWSS_LOG_INFO("Failed to get route type actions for %s", key.c_str()); + return false; } for (auto action: route_type_actions.items()) @@ -309,7 +310,7 @@ void DashVnetOrch::addOutboundCaToPa(const string& key, VnetMapBulkContext& ctxt else { SWSS_LOG_ERROR("Invalid encap type %d for %s", action.encap_type(), key.c_str()); - return; + return false; } outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr); @@ -359,9 +360,10 @@ void DashVnetOrch::addOutboundCaToPa(const string& key, VnetMapBulkContext& ctxt object_statuses.emplace_back(); outbound_ca_to_pa_bulker_.create_entry(&object_statuses.back(), &outbound_ca_to_pa_entry, (uint32_t)outbound_ca_to_pa_attrs.size(), outbound_ca_to_pa_attrs.data()); + return true; } -void DashVnetOrch::addPaValidation(const string& key, VnetMapBulkContext& ctxt) +bool DashVnetOrch::addPaValidation(const string& key, VnetMapBulkContext& ctxt) { SWSS_LOG_ENTER(); @@ -380,7 +382,7 @@ void DashVnetOrch::addPaValidation(const string& key, VnetMapBulkContext& ctxt) SWSS_LOG_INFO("Increment PA refcount to %u for PA IP %s", pa_refcount_table_[pa_ref_key], underlay_ip_str.c_str()); - return; + return true; } uint32_t attr_count = 1; @@ -399,6 +401,7 @@ void DashVnetOrch::addPaValidation(const string& key, VnetMapBulkContext& ctxt) pa_refcount_table_[pa_ref_key] = 1; SWSS_LOG_INFO("Initialize PA refcount to 1 for PA IP %s", underlay_ip_str.c_str()); + return true; } bool DashVnetOrch::addVnetMap(const string& key, VnetMapBulkContext& ctxt) @@ -408,17 +411,14 @@ bool DashVnetOrch::addVnetMap(const string& key, VnetMapBulkContext& ctxt) bool exists = (vnet_map_table_.find(key) != vnet_map_table_.end()); if (!exists) { + bool vnet_exists = (gVnetNameToId.find(ctxt.vnet_name) != gVnetNameToId.end()); - if (vnet_exists) - { - addOutboundCaToPa(key, ctxt); - addPaValidation(key, ctxt); - } - else + if (!vnet_exists) { SWSS_LOG_INFO("Not creating VNET map for %s since VNET %s doesn't exist", key.c_str(), ctxt.vnet_name.c_str()); + return false; } - return false; + return addOutboundCaToPa(key, ctxt) && addPaValidation(key, ctxt); } /* * If the VNET map is already added, don't add it to the bulker and diff --git a/orchagent/dash/dashvnetorch.h b/orchagent/dash/dashvnetorch.h index 3a5a06fd98..4a3acc5845 100644 --- a/orchagent/dash/dashvnetorch.h +++ b/orchagent/dash/dashvnetorch.h @@ -91,11 +91,11 @@ class DashVnetOrch : public ZmqOrch bool addVnetPost(const std::string& key, const DashVnetBulkContext& ctxt); bool removeVnet(const std::string& key, DashVnetBulkContext& ctxt); bool removeVnetPost(const std::string& key, const DashVnetBulkContext& ctxt); - void addOutboundCaToPa(const std::string& key, VnetMapBulkContext& ctxt); + bool addOutboundCaToPa(const std::string& key, VnetMapBulkContext& ctxt); bool addOutboundCaToPaPost(const std::string& key, const VnetMapBulkContext& ctxt); void removeOutboundCaToPa(const std::string& key, VnetMapBulkContext& ctxt); bool removeOutboundCaToPaPost(const std::string& key, const VnetMapBulkContext& ctxt); - void addPaValidation(const std::string& key, VnetMapBulkContext& ctxt); + bool addPaValidation(const std::string& key, VnetMapBulkContext& ctxt); bool addPaValidationPost(const std::string& key, const VnetMapBulkContext& ctxt); void removePaValidation(const std::string& key, VnetMapBulkContext& ctxt); bool removePaValidationPost(const std::string& key, const VnetMapBulkContext& ctxt); diff --git a/tests/dash/test_dash_pl.py b/tests/dash/test_dash_pl.py index ffc9dba3d2..e66018ff17 100644 --- a/tests/dash/test_dash_pl.py +++ b/tests/dash/test_dash_pl.py @@ -30,12 +30,12 @@ @pytest.fixture(autouse=True) def common_setup_teardown(dash_db: DashDB): - dash_db.set_app_db_entry(APP_DASH_ROUTING_TYPE_TABLE_NAME, PRIVATELINK, ROUTING_TYPE_PL_CONFIG) dash_db.set_app_db_entry(APP_DASH_APPLIANCE_TABLE_NAME, APPLIANCE_ID, APPLIANCE_CONFIG) dash_db.set_app_db_entry(APP_DASH_VNET_TABLE_NAME, VNET1, VNET_CONFIG) dash_db.set_app_db_entry(APP_DASH_ENI_TABLE_NAME, ENI_ID, ENI_CONFIG) dash_db.set_app_db_entry(APP_DASH_VNET_MAPPING_TABLE_NAME, VNET1, VNET_MAP_IP1, VNET_MAPPING_CONFIG_PRIVATELINK) dash_db.set_app_db_entry(APP_DASH_ROUTE_GROUP_TABLE_NAME, ROUTE_GROUP1, ROUTE_GROUP1_CONFIG) + dash_db.set_app_db_entry(APP_DASH_ROUTING_TYPE_TABLE_NAME, PRIVATELINK, ROUTING_TYPE_PL_CONFIG) # Don't set DASH_ROUTE_TABLE and DASH_ENI_ROUTE_TABLE entries here for flexibility, test cases will set them as needed yield @@ -79,3 +79,4 @@ def test_pl_outbound_ca_to_pa_attrs(dash_db: DashDB): assert_sai_attribute_exists(SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DIP_MASK, outbound_attrs, PL_OVERLAY_DIP_MASK) assert_sai_attribute_exists(SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_TUNNEL_KEY, outbound_attrs, ENCAP_VNI) assert_sai_attribute_exists(SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_DASH_ENCAPSULATION, outbound_attrs, SAI_DASH_ENCAPSULATION_NVGRE) + assert_sai_attribute_exists(SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP, outbound_attrs, UNDERLAY_IP) diff --git a/tests/dash/test_dash_route_group.py b/tests/dash/test_dash_route_group.py index 10860465f2..459507aaa1 100644 --- a/tests/dash/test_dash_route_group.py +++ b/tests/dash/test_dash_route_group.py @@ -15,7 +15,7 @@ APP_DASH_ROUTE_GROUP_TABLE_NAME, ) -@pytest.fixture(scope='module', autouse=True) +@pytest.fixture(autouse=True) def common_setup_teardown(dash_db: DashDB): dash_db.set_app_db_entry(APP_DASH_APPLIANCE_TABLE_NAME, APPLIANCE_ID, APPLIANCE_CONFIG) dash_db.set_app_db_entry(APP_DASH_ROUTING_TYPE_TABLE_NAME, PRIVATELINK, ROUTING_TYPE_PL_CONFIG) diff --git a/tests/sai_attrs.py b/tests/sai_attrs.py index 207eb545ed..9f1be411df 100644 --- a/tests/sai_attrs.py +++ b/tests/sai_attrs.py @@ -1,7 +1,11 @@ +SAI_DIRECTION_LOOKUP_ENTRY_ATTR_ACTION = "SAI_DIRECTION_LOOKUP_ENTRY_ATTR_ACTION" +SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION = "SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION" + SAI_ENI_ATTR_PL_SIP = 'SAI_ENI_ATTR_PL_SIP' SAI_ENI_ATTR_PL_SIP_MASK = 'SAI_ENI_ATTR_PL_SIP_MASK' SAI_ENI_ATTR_PL_UNDERLAY_SIP = 'SAI_ENI_ATTR_PL_UNDERLAY_SIP' SAI_ENI_ATTR_OUTBOUND_ROUTING_GROUP_ID = 'SAI_ENI_ATTR_OUTBOUND_ROUTING_GROUP_ID' + SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_TUNNEL_MAPPING = 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_TUNNEL_MAPPING' SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_PRIVATE_LINK_MAPPING = 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_PRIVATE_LINK_MAPPING' SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DIP = 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DIP' @@ -13,5 +17,7 @@ SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DIP_MASK = 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DIP_MASK' SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_DASH_ENCAPSULATION = 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_DASH_ENCAPSULATION' SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_TUNNEL_KEY = 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_TUNNEL_KEY' +SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP = 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP' SAI_DASH_ENCAPSULATION_NVGRE = 'SAI_DASH_ENCAPSULATION_NVGRE' -SAI_OUTBOUND_ROUTING_ENTRY_ATTR_UNDERLAY_SIP = 'SAI_OUTBOUND_ROUTING_ENTRY_ATTR_UNDERLAY_SIP' \ No newline at end of file + +SAI_OUTBOUND_ROUTING_ENTRY_ATTR_UNDERLAY_SIP = 'SAI_OUTBOUND_ROUTING_ENTRY_ATTR_UNDERLAY_SIP'