Skip to content

Commit e420737

Browse files
authored
IPv6 outbound routing support for overlay processing (sonic-net#97)
1 parent cf074d7 commit e420737

File tree

6 files changed

+45
-9
lines changed

6 files changed

+45
-9
lines changed

sirius-pipeline/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ table_add direction_lookup set_direction 70 => 2
2828
table_add eni_lookup_from_vm outbound.set_eni cc:cc:cc:cc:cc:cc => 7
2929
table_add eni_lookup_to_vm inbound.set_eni c:cc:cc:cc:cc:cc => 7
3030
table_add eni_to_vni set_vni 7 => 9
31-
table_add routing route_vnet 7 0x01010100/24 => 14
32-
table_add ca_to_pa set_tunnel_mapping 14 0x01010102 => 0x02020202 88:88:88:88:88:88 1
33-
table_add ca_to_pa set_tunnel_mapping 14 0x01010103 => 0x02020202 88:88:88:88:88:88 0
31+
table_add routing route_vnet 7 0 0x01010100/24 => 14
32+
table_add ca_to_pa set_tunnel_mapping 14 0 0x01010102 => 0x02020202 88:88:88:88:88:88 1
33+
table_add ca_to_pa set_tunnel_mapping 14 0 0x01010103 => 0x02020202 88:88:88:88:88:88 0
3434
table_add appliance set_appliance 0&&&0 => 77:77:77:77:77:77 66:66:66:66:66:66 0x02020201 0
35+
table_add ca_to_pa set_tunnel_mapping 14 1 0x01010104 => 0x02020202 88:88:88:88:88:88 1
36+
table_add ca_to_pa set_tunnel_mapping 14 1 0x01010105 => 0x02020202 88:88:88:88:88:88 0
3537
```
3638

3739
# Sirius Pipeline P4 Behavior Models

sirius-pipeline/bmv2/sirius_headers.p4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
typedef bit<48> EthernetAddress;
55
typedef bit<32> IPv4Address;
66
typedef bit<128> IPv6Address;
7+
typedef bit<128> IPv4ORv6Address;
78

89
header ethernet_t {
910
EthernetAddress dst_addr;

sirius-pipeline/bmv2/sirius_metadata.p4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ struct metadata_t {
3232
bit<16> eni;
3333
bit<16> vm_id;
3434
bit<8> appliance_id;
35+
bit<1> is_dst_ip_v6;
36+
IPv4ORv6Address dst_ip_addr;
3537
conntrack_data_t conntrack_data;
3638
}
3739

sirius-pipeline/bmv2/sirius_outbound.p4

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ control outbound(inout headers_t hdr,
3232
table routing {
3333
key = {
3434
meta.eni : exact @name("meta.eni:eni");
35-
hdr.ipv4.dst_addr : lpm @name("hdr.ipv4.dst_addr:destination");
35+
meta.is_dst_ip_v6 : exact @name("meta.is_dst_ip_v6:v4_or_v6");
36+
meta.dst_ip_addr : lpm @name("meta.dst_ip_addr:destination");
3637
}
3738

3839
actions = {
@@ -62,7 +63,8 @@ control outbound(inout headers_t hdr,
6263
key = {
6364
/* Flow for express route */
6465
meta.encap_data.dest_vnet_vni : exact @name("meta.encap_data.dest_vnet_vni:dest_vni");
65-
hdr.ipv4.dst_addr : exact @name("hdr.ipv4.dst_addr:dip");
66+
meta.is_dst_ip_v6 : exact @name("meta.is_dst_ip_v6:v4_or_v6");
67+
meta.dst_ip_addr : exact @name("meta.dst_ip_addr:dip");
6668
}
6769

6870
actions = {
@@ -107,8 +109,8 @@ control outbound(inout headers_t hdr,
107109
meta.encap_data.underlay_sip,
108110
meta.encap_data.overlay_dmac,
109111
meta.encap_data.vni);
110-
}
111-
}
112+
}
113+
}
112114
}
113115
}
114116

sirius-pipeline/bmv2/sirius_parser.p4

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ error {
1111
#define UDP_PORT_VXLAN 4789
1212
#define UDP_PROTO 17
1313
#define TCP_PROTO 6
14-
#define IPV4_ETHTYPE 0x800
14+
#define IPV4_ETHTYPE 0x0800
1515
#define IPV6_ETHTYPE 0x86dd
1616

1717
parser sirius_parser(packet_in packet,
@@ -22,7 +22,8 @@ parser sirius_parser(packet_in packet,
2222
state start {
2323
packet.extract(hd.ethernet);
2424
transition select(hd.ethernet.ether_type) {
25-
0x0800: parse_ipv4;
25+
IPV4_ETHTYPE: parse_ipv4;
26+
IPV6_ETHTYPE: parse_ipv6;
2627
default: accept;
2728
}
2829
}
@@ -38,6 +39,15 @@ parser sirius_parser(packet_in packet,
3839
}
3940
}
4041

42+
state parse_ipv6 {
43+
packet.extract(hd.ipv6);
44+
transition select(hd.ipv6.next_header) {
45+
UDP_PROTO: parse_udp;
46+
TCP_PROTO: parse_tcp;
47+
default: accept;
48+
}
49+
}
50+
4151
state parse_udp {
4252
packet.extract(hd.udp);
4353
transition select(hd.udp.dst_port) {
@@ -60,6 +70,7 @@ parser sirius_parser(packet_in packet,
6070
packet.extract(hd.inner_ethernet);
6171
transition select(hd.ethernet.ether_type) {
6272
IPV4_ETHTYPE: parse_inner_ipv4;
73+
IPV6_ETHTYPE: parse_inner_ipv6;
6374
default: accept;
6475
}
6576
}
@@ -75,6 +86,15 @@ parser sirius_parser(packet_in packet,
7586
}
7687
}
7788

89+
state parse_inner_ipv6 {
90+
packet.extract(hd.inner_ipv6);
91+
transition select(hd.inner_ipv6.next_header) {
92+
UDP_PROTO: parse_inner_udp;
93+
TCP_PROTO: parse_inner_tcp;
94+
default: accept;
95+
}
96+
}
97+
7898
state parse_inner_tcp {
7999
packet.extract(hd.inner_tcp);
80100
transition accept;

sirius-pipeline/bmv2/sirius_pipeline.p4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ control sirius_ingress(inout headers_t hdr,
121121
inbound_routing.apply();
122122
}
123123

124+
meta.dst_ip_addr = 0;
125+
meta.is_dst_ip_v6 = 0;
126+
if (hdr.ipv6.isValid()) {
127+
meta.dst_ip_addr = hdr.ipv6.dst_addr;
128+
meta.is_dst_ip_v6 = 1;
129+
} else if (hdr.ipv4.isValid()) {
130+
meta.dst_ip_addr = (bit<128>)hdr.ipv4.dst_addr;
131+
}
132+
124133
/* At this point the processing is done on customer headers */
125134

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

0 commit comments

Comments
 (0)