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

Override VM MAC when in DST address ENI lookup #661

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions dash-pipeline/bmv2/dash_conntrack.p4
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ control ConntrackIn(inout headers_t hdr,
inout metadata_t meta)
{

action conntrackIn_allow (IPv4Address original_overlay_sip, IPv4Address original_overlay_dip) {
action conntrackIn_allow (IPv4Address original_overlay_sip, IPv4Address original_overlay_dip, EthernetAddress vm_nic_addr) {
/* Invalidate entry based on TCP flags */
// If FIN is 1 (0b000001), or if RST is 1 (0b000100):
if ((hdr.customer_tcp.flags & 0b000101 /* FIN/RST */) != 0) {
Expand All @@ -51,6 +51,7 @@ control ConntrackIn(inout headers_t hdr,
meta.overlay_data.is_ipv6 = 0;
meta.overlay_data.sip = (IPv4ORv6Address)original_overlay_sip;
meta.overlay_data.dip = (IPv4ORv6Address)original_overlay_dip;
meta.vm_nic_addr = vm_nic_addr;
}

action conntrackIn_miss() {
Expand All @@ -60,7 +61,7 @@ control ConntrackIn(inout headers_t hdr,
if (meta.routing_actions & dash_routing_actions_t.NAT46 != 0) {
// New PNA Extern
add_entry("conntrackIn_allow",
{(IPv4Address)meta.src_ip_addr, (IPv4Address)meta.dst_ip_addr},
{(IPv4Address)meta.src_ip_addr, (IPv4Address)meta.dst_ip_addr, meta.vm_nic_addr},
EXPIRE_TIME_PROFILE_LONG);
}
//adding failure to be eventually handled
Expand Down
7 changes: 7 additions & 0 deletions dash-pipeline/bmv2/dash_inbound.p4
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ control inbound(inout headers_t hdr,
meta.u0_encap_data.underlay_sip,
dash_encapsulation_t.VXLAN,
meta.u0_encap_data.vni);

// Fix up overlay DST MAC to be VM MAC and SRC MAC to ENI MAC
if (meta.eni_mac_type == dash_eni_mac_type_t.DST_MAC) {
hdr.customer_ethernet.dst_addr = meta.vm_nic_addr;
hdr.customer_ethernet.src_addr = meta.eni_addr;
}
}

}

#endif /* _SIRIUS_INBOUND_P4_ */
1 change: 1 addition & 0 deletions dash-pipeline/bmv2/dash_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ struct metadata_t {
encap_data_t rx_encap;
#endif // TARGET_DPDK_PNA
EthernetAddress eni_addr;
EthernetAddress vm_nic_addr;
bit<16> vnet_id;
bit<16> dst_vnet_id;
bit<16> eni_id;
Expand Down
5 changes: 5 additions & 0 deletions dash-pipeline/bmv2/dash_outbound.p4
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ control outbound(inout headers_t hdr,
outbound_mapping_stage.apply(hdr, meta);

outbound_pre_routing_action_apply_stage.apply(hdr, meta);

// Fix up overlay SRC MAC to be VM MAC
if (meta.eni_mac_type == dash_eni_mac_type_t.DST_MAC) {
hdr.customer_ethernet.src_addr = meta.eni_addr;
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion dash-pipeline/bmv2/stages/eni_lookup.p4
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ control eni_lookup_stage(
meta.eni_addr = hdr.customer_ethernet.src_addr;
} else {
meta.eni_addr = hdr.customer_ethernet.dst_addr;
meta.vm_nic_addr = hdr.customer_ethernet.src_addr;
}

if (!eni_ether_address_map.apply().hit) {
Expand All @@ -44,4 +45,4 @@ control eni_lookup_stage(
}
}

#endif /* _DASH_STAGE_ENI_LOOKUP_P4_ */
#endif /* _DASH_STAGE_ENI_LOOKUP_P4_ */
Loading