Skip to content

Commit

Permalink
Initial Private Link
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Sep 25, 2023
1 parent 1729021 commit 87ebe16
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
4 changes: 3 additions & 1 deletion dash-pipeline/bmv2/dash_inbound.p4
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ control inbound(inout headers_t hdr,
#ifdef PNA_CONNTRACK
ConntrackIn.apply(hdr, meta);

if (meta.encap_data.original_overlay_sip != 0) {
if (meta.flag_mvp == 1) {
meta.encap_data.original_overlay_sip = 0; //FIXME: ER gateway private ip?
meta.encap_data.original_overlay_dip = (IPv4Address)hdr.ipv6.dst_addr;
service_tunnel_decode(hdr,
meta.encap_data.original_overlay_sip,
meta.encap_data.original_overlay_dip);
Expand Down
1 change: 1 addition & 0 deletions dash-pipeline/bmv2/dash_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct metadata_t {
bit<16> mapping_meter_class;
bit<16> meter_class;
bit<32> meter_bucket_index;
bit<1> flag_mvp;
}

#endif /* _SIRIUS_METADATA_P4_ */
21 changes: 21 additions & 0 deletions dash-pipeline/bmv2/dash_nvgre.p4
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,25 @@ action nvgre_encap(inout headers_t hdr,

}

action nvgre_decap(inout headers_t hdr) {
hdr.ethernet = hdr.inner_ethernet;
hdr.inner_ethernet.setInvalid();

hdr.ipv4 = hdr.inner_ipv4;
hdr.inner_ipv4.setInvalid();

hdr.ipv6 = hdr.inner_ipv6;
hdr.inner_ipv6.setInvalid();

hdr.vxlan.setInvalid();
hdr.udp.setInvalid();

hdr.tcp = hdr.inner_tcp;
hdr.inner_tcp.setInvalid();

hdr.udp = hdr.inner_udp;
hdr.inner_udp.setInvalid();
}


#endif /* _DASH_NVGRE_P4_ */
10 changes: 10 additions & 0 deletions dash-pipeline/bmv2/dash_parser.p4
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ parser dash_parser(
transition select(hd.ipv4.protocol) {
UDP_PROTO: parse_udp;
TCP_PROTO: parse_tcp;
NVGRE_PROTO: parse_nvgre;
default: accept;
}
}
Expand All @@ -66,6 +67,7 @@ parser dash_parser(
transition select(hd.ipv6.next_header) {
UDP_PROTO: parse_udp;
TCP_PROTO: parse_tcp;
NVGRE_PROTO: parse_nvgre;
default: accept;
}
}
Expand All @@ -83,6 +85,14 @@ parser dash_parser(
transition accept;
}

state parse_nvgre {
packet.extract(hd.nvgre);
transition select(hd.nvgre.protocol_type) {
0x6558: parse_inner_ethernet;
default: accept;
}
}

state parse_vxlan {
packet.extract(hd.vxlan);
transition parse_inner_ethernet;
Expand Down
13 changes: 9 additions & 4 deletions dash-pipeline/bmv2/dash_pipeline.p4
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,15 @@ control dash_ingress(
if (meta.direction == dash_direction_t.OUTBOUND) {
vxlan_decap(hdr);
} else if (meta.direction == dash_direction_t.INBOUND) {
switch (inbound_routing.apply().action_run) {
vxlan_decap_pa_validate: {
pa_validation.apply();
vxlan_decap(hdr);
if (hdr.nvgre.protocol_type == 0x6558) { // From PLS
meta.flag_mvp = 1;
nvgre_decap(hdr);
} else {
switch (inbound_routing.apply().action_run) {
vxlan_decap_pa_validate: {
pa_validation.apply();
vxlan_decap(hdr);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dash-pipeline/bmv2/dash_service_tunnel.p4
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ action service_tunnel_encode(inout headers_t hdr,
hdr.ipv6.payload_length = hdr.ipv4.total_len - IPV4_HDR_SIZE;
hdr.ipv6.next_header = hdr.ipv4.protocol;
hdr.ipv6.hop_limit = hdr.ipv4.ttl;
hdr.ipv6.dst_addr = ((IPv6Address)hdr.ipv4.dst_addr & ~st_dst_mask) | (st_dst & st_dst_mask);
hdr.ipv6.dst_addr = st_dst;
hdr.ipv6.src_addr = ((IPv6Address)hdr.ipv4.src_addr & ~st_src_mask) | (st_src & st_src_mask);

hdr.ipv4.setInvalid();
Expand Down

0 comments on commit 87ebe16

Please sign in to comment.