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

Normalize Sirius P4 pipeline tables #1

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
2 changes: 1 addition & 1 deletion dash-pipeline/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DOCKER_RUN := docker run \
--network=host \
--rm

bmv2/dash_pipeline.bmv2/dash_pipeline.json:
bmv2/dash_pipeline.bmv2/dash_pipeline.json: bmv2/*.p4
$(DOCKER_RUN) bmv2-$(USER) p4c \
-b \
bmv2 \
Expand Down
4 changes: 2 additions & 2 deletions dash-pipeline/bmv2/dash_acl.p4
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ match_kind {
@name(str(table_name##:dash_acl|dash_acl)) \
table table_name { \
key = { \
meta.eni_id : exact @name("meta.eni_id:eni_id"); \
meta. ## table_name ##_acl_group_id : exact @name("meta.acl_group_id:acl_group_id"); \
hdr.ipv4.dst_addr : LIST_MATCH @name("hdr.ipv4.dst_addr:dip"); \
hdr.ipv4.src_addr : LIST_MATCH @name("hdr.ipv4.src_addr:sip"); \
hdr.ipv4.protocol : LIST_MATCH @name("hdr.ipv4.src_addr:protocol"); \
Expand All @@ -51,7 +51,7 @@ match_kind {
deny: {return;} \
}

/*
/*
* This control results in a new set of tables every time
* it is applied, i. e. inbound ACL tables are different
* from outbound, and API will be generated for each of them
Expand Down
84 changes: 0 additions & 84 deletions dash-pipeline/bmv2/dash_inbound.p4

This file was deleted.

10 changes: 9 additions & 1 deletion dash-pipeline/bmv2/dash_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ struct metadata_t {
EthernetAddress eni_addr;
bit<16> eni_id;
eni_data_t eni_data;
bit<16> inbound_vm_id;
bit<16> stage1_acl_group_id;
bit<16> stage2_acl_group_id;
bit<16> stage3_acl_group_id;
bit<16> acl_group_id;
bit<16> route_table_id;
bit<16> tunnel_id;
bit<16> vnet;
bit<24> lookup_vni;
bit<8> appliance_id;
bit<1> is_dst_ip_v6;
IPv4ORv6Address dst_ip_addr;
IPv4Address pa_src;
conntrack_data_t conntrack_data;
}

Expand Down
54 changes: 3 additions & 51 deletions dash-pipeline/bmv2/dash_outbound.p4
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,11 @@
#define _SIRIUS_OUTBOUND_P4_

#include "dash_headers.p4"
#include "dash_acl.p4"
#include "dash_conntrack.p4"

control outbound(inout headers_t hdr,
inout metadata_t meta,
inout standard_metadata_t standard_metadata)
{
action set_vni(bit<24> vni) {
meta.encap_data.vni = vni;
}

@name("eni_to_vni|dash_vnet")
table eni_to_vni {
key = {
meta.eni_id : exact @name("meta.eni_id:eni_id");
}

actions = {
set_vni;
}
}

action route_vnet(bit<24> dest_vnet_vni) {
meta.encap_data.dest_vnet_vni = dest_vnet_vni;
}
Expand All @@ -33,7 +16,7 @@ control outbound(inout headers_t hdr,
@name("routing|dash_vnet")
table routing {
key = {
meta.eni_id : exact @name("meta.eni_id:eni_id");
meta.route_table_id : exact @name("meta.route_table_id:route_table_id");
meta.is_dst_ip_v6 : exact @name("meta.is_dst_ip_v6:v4_or_v6");
meta.dst_ip_addr : lpm @name("meta.dst_ip_addr:destination");
}
Expand All @@ -45,7 +28,7 @@ control outbound(inout headers_t hdr,
counters = routing_counter;
}

action set_tunnel_mapping(IPv4Address underlay_dip,
action set_tunnel_mapping(bit<16> tunnel_id,
EthernetAddress overlay_dmac,
bit<1> use_dst_vni) {
/*
Expand All @@ -56,7 +39,7 @@ control outbound(inout headers_t hdr,
*/
meta.encap_data.vni = meta.encap_data.vni * (bit<24>)(~use_dst_vni) + meta.encap_data.dest_vnet_vni * (bit<24>)use_dst_vni;
meta.encap_data.overlay_dmac = overlay_dmac;
meta.encap_data.underlay_dip = underlay_dip;
meta.tunnel_id = tunnel_id;
}

direct_counter(CounterType.packets_and_bytes) ca_to_pa_counter;
Expand All @@ -78,40 +61,9 @@ control outbound(inout headers_t hdr,
}

apply {
eni_to_vni.apply();

#ifdef STATEFUL_P4
ConntrackOut.apply(0);
#endif /* STATEFUL_P4 */

#ifdef PNA_CONNTRACK
ConntrackOut.apply(hdr, meta);
#endif // PNA_CONNTRACK

/* ACL */
if (!meta.conntrack_data.allow_out) {
acl.apply(hdr, meta, standard_metadata);
}

#ifdef STATEFUL_P4
ConntrackIn.apply(1);
#endif /* STATEFUL_P4 */

#ifdef PNA_CONNTRACK
ConntrackIn.apply(hdr, meta);
#endif // PNA_CONNTRACK

switch (routing.apply().action_run) {
route_vnet: {
ca_to_pa.apply();

vxlan_encap(hdr,
meta.encap_data.underlay_dmac,
meta.encap_data.underlay_smac,
meta.encap_data.underlay_dip,
meta.encap_data.underlay_sip,
meta.encap_data.overlay_dmac,
meta.encap_data.vni);
}
}
}
Expand Down
Loading