Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dash] set OUTBOUND_CA_TO_PA attributes correctly per routing type PRIVATELINK, VNET_ENCAP #3459

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 46 additions & 36 deletions orchagent/dash/dashvnetorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,39 +294,34 @@ bool DashVnetOrch::addOutboundCaToPa(const string& key, VnetMapBulkContext& ctxt
return false;
}

for (auto action: route_type_actions.items())
if (ctxt.metadata.routing_type() == dash::route_type::ROUTING_TYPE_PRIVATELINK)
{
if (action.action_type() == dash::route_type::ACTION_TYPE_STATICENCAP)
for (auto action: route_type_actions.items())
{
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_DASH_ENCAPSULATION;
if (action.encap_type() == dash::route_type::ENCAP_TYPE_VXLAN)
{
outbound_ca_to_pa_attr.value.u32 = SAI_DASH_ENCAPSULATION_VXLAN;
}
else if (action.encap_type() == dash::route_type::ENCAP_TYPE_NVGRE)
if (action.action_type() == dash::route_type::ACTION_TYPE_STATICENCAP)
{
outbound_ca_to_pa_attr.value.u32 = SAI_DASH_ENCAPSULATION_NVGRE;
}
else
{
SWSS_LOG_ERROR("Invalid encap type %d for %s", action.encap_type(), key.c_str());
return false;
}
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);

outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_TUNNEL_KEY;
outbound_ca_to_pa_attr.value.u32 = action.vni();
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);

outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP;
to_sai(ctxt.metadata.underlay_ip(), outbound_ca_to_pa_attr.value.ipaddr);
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_DASH_ENCAPSULATION;
if (action.encap_type() == dash::route_type::ENCAP_TYPE_VXLAN)
{
outbound_ca_to_pa_attr.value.u32 = SAI_DASH_ENCAPSULATION_VXLAN;
}
else if (action.encap_type() == dash::route_type::ENCAP_TYPE_NVGRE)
{
outbound_ca_to_pa_attr.value.u32 = SAI_DASH_ENCAPSULATION_NVGRE;
}
else
{
SWSS_LOG_ERROR("Invalid encap type %d for %s", action.encap_type(), key.c_str());
return false;
}
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);

outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_TUNNEL_KEY;
outbound_ca_to_pa_attr.value.u32 = action.vni();
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
}
}
}

if (ctxt.metadata.routing_type() == dash::route_type::ROUTING_TYPE_PRIVATELINK)
{
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_ACTION;
outbound_ca_to_pa_attr.value.u32 = SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_PRIVATE_LINK_MAPPING;
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
Expand All @@ -348,21 +343,36 @@ bool DashVnetOrch::addOutboundCaToPa(const string& key, VnetMapBulkContext& ctxt
to_sai(ctxt.metadata.overlay_sip_prefix().mask(), outbound_ca_to_pa_attr.value.ipaddr);
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
}

if (ctxt.metadata.has_mac_address())
else if (ctxt.metadata.routing_type() == dash::route_type::ROUTING_TYPE_VNET_ENCAP)
{
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC;
memcpy(outbound_ca_to_pa_attr.value.mac, ctxt.metadata.mac_address().c_str(), sizeof(sai_mac_t));
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_ACTION;
outbound_ca_to_pa_attr.value.u32 = SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_TUNNEL_MAPPING;
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
}

if (ctxt.metadata.has_use_dst_vni())
if (ctxt.metadata.has_mac_address())
{
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC;
memcpy(outbound_ca_to_pa_attr.value.mac, ctxt.metadata.mac_address().c_str(), sizeof(sai_mac_t));
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
}
if (ctxt.metadata.has_use_dst_vni())
{
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_USE_DST_VNET_VNI;
outbound_ca_to_pa_attr.value.booldata = ctxt.metadata.use_dst_vni();
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
}
}
else
{
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_USE_DST_VNET_VNI;
outbound_ca_to_pa_attr.value.booldata = ctxt.metadata.use_dst_vni();
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
SWSS_LOG_ERROR("Invalid routing type %d for OutboundCaToPa", ctxt.metadata.routing_type());
return false;
}

// mandatory attr for both routing_type PRIVATELINK and VNET_ENCAP
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP;
to_sai(ctxt.metadata.underlay_ip(), outbound_ca_to_pa_attr.value.ipaddr);
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);

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());
Expand Down
4 changes: 2 additions & 2 deletions tests/dash/test_dash_vnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def test_vnet_map(self, dash_db: DashDB):
route_action = RouteTypeItem()
route_action.action_name = "action1"
route_action.action_type = ACTION_TYPE_STATICENCAP
route_action.encap_type = ENCAP_TYPE_NVGRE
route_type_msg.items.append(route_action)
dash_db.create_routing_type(self.routing_type, {"pb": route_type_msg.SerializeToString()})
pb = VnetMapping()
Expand All @@ -133,9 +132,10 @@ def test_vnet_map(self, dash_db: DashDB):

vnet_ca_to_pa_maps = dash_db.wait_for_asic_db_keys(ASIC_OUTBOUND_CA_TO_PA_TABLE, min_keys=2)
attrs = dash_db.get_asic_db_entry(ASIC_OUTBOUND_CA_TO_PA_TABLE, vnet_ca_to_pa_maps[0])
assert_sai_attribute_exists("SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_ACTION", attrs, "SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_TUNNEL_MAPPING")
assert_sai_attribute_exists("SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP", attrs, self.underlay_ip)
assert_sai_attribute_exists("SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC", attrs, self.mac_address)
assert_sai_attribute_exists("SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_DASH_ENCAPSULATION", attrs, "SAI_DASH_ENCAPSULATION_NVGRE")
assert_sai_attribute_exists("SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_USE_DST_VNET_VNI", attrs, "false")

vnet_pa_validation_maps = dash_db.wait_for_asic_db_keys(ASIC_PA_VALIDATION_TABLE)
pa_validation_attrs = dash_db.get_asic_db_entry(ASIC_PA_VALIDATION_TABLE, vnet_pa_validation_maps[0])
Expand Down
Loading