Skip to content

Commit

Permalink
IPv6 outbound routing support for overlay processing (sonic-net#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanif authored May 19, 2022
1 parent cf074d7 commit e420737
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 9 deletions.
8 changes: 5 additions & 3 deletions sirius-pipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ table_add direction_lookup set_direction 70 => 2
table_add eni_lookup_from_vm outbound.set_eni cc:cc:cc:cc:cc:cc => 7
table_add eni_lookup_to_vm inbound.set_eni c:cc:cc:cc:cc:cc => 7
table_add eni_to_vni set_vni 7 => 9
table_add routing route_vnet 7 0x01010100/24 => 14
table_add ca_to_pa set_tunnel_mapping 14 0x01010102 => 0x02020202 88:88:88:88:88:88 1
table_add ca_to_pa set_tunnel_mapping 14 0x01010103 => 0x02020202 88:88:88:88:88:88 0
table_add routing route_vnet 7 0 0x01010100/24 => 14
table_add ca_to_pa set_tunnel_mapping 14 0 0x01010102 => 0x02020202 88:88:88:88:88:88 1
table_add ca_to_pa set_tunnel_mapping 14 0 0x01010103 => 0x02020202 88:88:88:88:88:88 0
table_add appliance set_appliance 0&&&0 => 77:77:77:77:77:77 66:66:66:66:66:66 0x02020201 0
table_add ca_to_pa set_tunnel_mapping 14 1 0x01010104 => 0x02020202 88:88:88:88:88:88 1
table_add ca_to_pa set_tunnel_mapping 14 1 0x01010105 => 0x02020202 88:88:88:88:88:88 0
```

# Sirius Pipeline P4 Behavior Models
Expand Down
1 change: 1 addition & 0 deletions sirius-pipeline/bmv2/sirius_headers.p4
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
typedef bit<48> EthernetAddress;
typedef bit<32> IPv4Address;
typedef bit<128> IPv6Address;
typedef bit<128> IPv4ORv6Address;

header ethernet_t {
EthernetAddress dst_addr;
Expand Down
2 changes: 2 additions & 0 deletions sirius-pipeline/bmv2/sirius_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct metadata_t {
bit<16> eni;
bit<16> vm_id;
bit<8> appliance_id;
bit<1> is_dst_ip_v6;
IPv4ORv6Address dst_ip_addr;
conntrack_data_t conntrack_data;
}

Expand Down
10 changes: 6 additions & 4 deletions sirius-pipeline/bmv2/sirius_outbound.p4
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ control outbound(inout headers_t hdr,
table routing {
key = {
meta.eni : exact @name("meta.eni:eni");
hdr.ipv4.dst_addr : lpm @name("hdr.ipv4.dst_addr:destination");
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");
}

actions = {
Expand Down Expand Up @@ -62,7 +63,8 @@ control outbound(inout headers_t hdr,
key = {
/* Flow for express route */
meta.encap_data.dest_vnet_vni : exact @name("meta.encap_data.dest_vnet_vni:dest_vni");
hdr.ipv4.dst_addr : exact @name("hdr.ipv4.dst_addr:dip");
meta.is_dst_ip_v6 : exact @name("meta.is_dst_ip_v6:v4_or_v6");
meta.dst_ip_addr : exact @name("meta.dst_ip_addr:dip");
}

actions = {
Expand Down Expand Up @@ -107,8 +109,8 @@ control outbound(inout headers_t hdr,
meta.encap_data.underlay_sip,
meta.encap_data.overlay_dmac,
meta.encap_data.vni);
}
}
}
}
}
}

Expand Down
24 changes: 22 additions & 2 deletions sirius-pipeline/bmv2/sirius_parser.p4
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ error {
#define UDP_PORT_VXLAN 4789
#define UDP_PROTO 17
#define TCP_PROTO 6
#define IPV4_ETHTYPE 0x800
#define IPV4_ETHTYPE 0x0800
#define IPV6_ETHTYPE 0x86dd

parser sirius_parser(packet_in packet,
Expand All @@ -22,7 +22,8 @@ parser sirius_parser(packet_in packet,
state start {
packet.extract(hd.ethernet);
transition select(hd.ethernet.ether_type) {
0x0800: parse_ipv4;
IPV4_ETHTYPE: parse_ipv4;
IPV6_ETHTYPE: parse_ipv6;
default: accept;
}
}
Expand All @@ -38,6 +39,15 @@ parser sirius_parser(packet_in packet,
}
}

state parse_ipv6 {
packet.extract(hd.ipv6);
transition select(hd.ipv6.next_header) {
UDP_PROTO: parse_udp;
TCP_PROTO: parse_tcp;
default: accept;
}
}

state parse_udp {
packet.extract(hd.udp);
transition select(hd.udp.dst_port) {
Expand All @@ -60,6 +70,7 @@ parser sirius_parser(packet_in packet,
packet.extract(hd.inner_ethernet);
transition select(hd.ethernet.ether_type) {
IPV4_ETHTYPE: parse_inner_ipv4;
IPV6_ETHTYPE: parse_inner_ipv6;
default: accept;
}
}
Expand All @@ -75,6 +86,15 @@ parser sirius_parser(packet_in packet,
}
}

state parse_inner_ipv6 {
packet.extract(hd.inner_ipv6);
transition select(hd.inner_ipv6.next_header) {
UDP_PROTO: parse_inner_udp;
TCP_PROTO: parse_inner_tcp;
default: accept;
}
}

state parse_inner_tcp {
packet.extract(hd.inner_tcp);
transition accept;
Expand Down
9 changes: 9 additions & 0 deletions sirius-pipeline/bmv2/sirius_pipeline.p4
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ control sirius_ingress(inout headers_t hdr,
inbound_routing.apply();
}

meta.dst_ip_addr = 0;
meta.is_dst_ip_v6 = 0;
if (hdr.ipv6.isValid()) {
meta.dst_ip_addr = hdr.ipv6.dst_addr;
meta.is_dst_ip_v6 = 1;
} else if (hdr.ipv4.isValid()) {
meta.dst_ip_addr = (bit<128>)hdr.ipv4.dst_addr;
}

/* At this point the processing is done on customer headers */

/* Put VM's MAC in the direction agnostic metadata field */
Expand Down

0 comments on commit e420737

Please sign in to comment.