Skip to content

Commit 0023d5a

Browse files
authored
Adds basic support for IPv6 (#255)
* Adds basic support for IPv6 - Adds IPv6 support to the OPTE API and main engine types. This includes fleshing out some missing edges for IPv6 addresses and CIDRs, and adding support for specifying IPv6 addresses in router entries, etc. The main type expanded here is the `VpcCfg`, which now supports an `IpCfg` that specifies all L3 information. That supports exactly one IPv4 or IPv6, or one of each, for private addresses. An optional SNAT and external address for each are also supported. - Updates the `opte-ioctl` and `opteadm` crates to support IPv6, and to use a `VpcCfg` as the argument, rather than a bunch of disparate arguments. Fleshes out handling for IPv6 in router entries, port info and printing, and layer / rule printing. - Adds a few niceties to the D scripts for pretty-printing IPv6 - Renames a lot of IPv4 specific types, such as `Dhcp4Reply` to `DhcpReply`. Types without a prefix will be assumed to refer to IPv4, and IPv6 will always have a version number. - Adds an `icmpv6` layer to `opte` and the `oxide-vpc`, and inserts it in the configuration created by the `xde` driver. This supports ICMPv6 echo requests from the guest to the gateway only. An integration test verifying the hairpinned echo reply is also here. - Updates the API version check script to compare all commits relative to the `master` branch, rather than the last. * Review feedback - Better router error message - Better error messages when parsing IpAddr / IpCidr - Better comments throughout, some better type names - DCE - Fix ARP handling to unconditionally drop outbound requests for anything other than the gateway, and all inbound requests. * Review feedback 2 - Renamed `public_ip` -> `external_ip` fields on NAT-related types. This is important because the "outside" IP address for NAT need not actually be an address that's routable on the public Internet. It can be any address in any network on the other side of the NAT node. - Fix location of Copy derive
1 parent a24dbb9 commit 0023d5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2143
-951
lines changed

dtrace/common.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
*this->src_ip6 = fvar->src_ip6; \
2828
*this->dst_ip6 = fvar->dst_ip6; \
2929
svar = protos[fvar->proto]; \
30-
svar = strjoin(svar, ","); \
30+
svar = strjoin(svar, ",["); \
3131
svar = strjoin(svar, inet_ntoa6(this->src_ip6)); \
32-
svar = strjoin(svar, ":"); \
32+
svar = strjoin(svar, "]:"); \
3333
svar = strjoin(svar, lltostr(ntohs(fvar->src_port))); \
34-
svar = strjoin(svar, ","); \
34+
svar = strjoin(svar, ",["); \
3535
svar = strjoin(svar, inet_ntoa6(this->dst_ip6)); \
36-
svar = strjoin(svar, ":"); \
36+
svar = strjoin(svar, "]:"); \
3737
svar = strjoin(svar, lltostr(ntohs(fvar->dst_port)));
3838

3939
#define ETH_FMT(svar, evar) \

dtrace/opte-flow-expire.d

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@
66
* dtrace -L ./lib -I . -Cqs ./opte-flow-expire.d
77
*/
88
#include "common.h"
9+
#include "protos.d"
910

1011
#define HDR_FMT "%-24s %-18s %s\n"
1112

1213
BEGIN {
13-
/*
14-
* Use an associative array to stringify the protocol number.
15-
*/
16-
protos[1]= "ICMP";
17-
protos[2] = "IGMP";
18-
protos[6] = "TCP";
19-
protos[17] = "UDP";
20-
2114
printf(HDR_FMT, "PORT", "FT NAME", "FLOW");
2215
num = 0;
2316
}

dtrace/opte-gen-desc-fail.d

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,11 @@
44
* dtrace -L ./lib -I . -Cqs ./opte-gen-desc-fail.d
55
*/
66
#include "common.h"
7+
#include "protos.d"
78

89
#define HDR_FMT "%-12s %-12s %-4s %-48s %s\n"
910

1011
BEGIN {
11-
/*
12-
* Use an associative array to stringify the protocol number.
13-
*/
14-
protos[1] = "ICMP";
15-
protos[2] = "IGMP";
16-
protos[6] = "TCP";
17-
protos[17] = "UDP";
18-
1912
printf(HDR_FMT, "PORT", "LAYER", "DIR", "FLOW", "MSG");
2013
num = 0;
2114
}

dtrace/opte-gen-ht-fail.d

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44
* dtrace -L ./lib -I . -Cqs ./opte-gen-desc-fail.d
55
*/
66
#include "common.h"
7+
#include "protos.d"
78

89
#define HDR_FMT "%-12s %-12s %-4s %-48s %s\n"
910

1011
BEGIN {
11-
/*
12-
* Use an associative array to stringify the protocol number.
13-
*/
14-
protos[1] = "ICMP";
15-
protos[2] = "IGMP";
16-
protos[6] = "TCP";
17-
protos[17] = "UDP";
1812

1913
printf(HDR_FMT, "PORT", "LAYER", "DIR", "FLOW", "MSG");
2014
num = 0;

dtrace/opte-guest-loopback.d

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@
44
* dtrace -L ./lib -I . -Cqs ./opte-guest-loopback.d
55
*/
66
#include "common.h"
7+
#include "protos.d"
78

89
#define HDR_FMT "%-43s %-12s %-12s\n"
910

1011
BEGIN {
11-
/*
12-
* Use an associative array to stringify the protocol number.
13-
*/
14-
protos[1] = "ICMP";
15-
protos[2] = "IGMP";
16-
protos[6] = "TCP";
17-
protos[17] = "UDP";
18-
protos[255] = "XXX";
19-
2012
printf(HDR_FMT, "FLOW", "SRC PORT", "DST PORT");
2113
num = 0;
2214
}

dtrace/opte-ht.d

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
/*
2-
* Track Header Transpositions as they happen.
2+
* Track Header Transformations as they happen.
33
*
44
* dtrace -L ./lib -I . -Cqs ./opte-ht.d
55
*/
66
#include "common.h"
7+
#include "protos.d"
78

89
#define HDR_FMT "%-3s %-12s %-12s %-40s %-40s\n"
910

1011
BEGIN {
11-
/*
12-
* Use an associative array to stringify the protocol number.
13-
*/
14-
protos[1]= "ICMP";
15-
protos[2] = "IGMP";
16-
protos[6] = "TCP";
17-
protos[17] = "UDP";
18-
1912
printf(HDR_FMT, "DIR", "PORT", "LOCATION", "BEFORE", "AFTER");
2013
num = 0;
2114
}

dtrace/opte-layer-process.d

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,11 @@
77
* dtrace -L ./lib -I . -Cqs ./opte-layer-process.d
88
*/
99
#include "common.h"
10+
#include "protos.d"
1011

1112
#define HDR_FMT "%-16s %-16s %-3s %-48s %s\n"
1213

1314
BEGIN {
14-
/*
15-
* Use an associative array to stringify the protocol number.
16-
*/
17-
protos[1] = "ICMP";
18-
protos[2] = "IGMP";
19-
protos[6] = "TCP";
20-
protos[17] = "UDP";
21-
protos[255] = "XXX";
22-
2315
printf(HDR_FMT, "PORT", "LAYER", "DIR", "FLOW", "RES");
2416
num = 0;
2517
}

dtrace/opte-port-process.d

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* dtrace -L ./lib -I . -Cqs ./opte-port-process.d
55
*/
66
#include "common.h"
7+
#include "protos.d"
78

89
#define HDR_FMT "%-12s %-3s %-8s %-43s %-5s %s\n"
910
#define LINE_FMT "%-12s %-3s %-8u %-43s %-5u %s\n"
@@ -12,11 +13,6 @@ BEGIN {
1213
/*
1314
* Use an associative array to stringify the protocol number.
1415
*/
15-
protos[1] = "ICMP";
16-
protos[2] = "IGMP";
17-
protos[6] = "TCP";
18-
protos[17] = "UDP";
19-
protos[255] = "XXX";
2016

2117
printf(HDR_FMT, "NAME", "DIR", "EPOCH", "FLOW", "LEN", "RESULT");
2218
num = 0;

dtrace/opte-rule-match.d

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@
44
* dtrace -L ./lib -I . -Cqs ./opte-rule-match.d
55
*/
66
#include "common.h"
7+
#include "protos.d"
78

89
#define HDR_FMT "%-8s %-12s %-6s %-3s %-43s %s\n"
910

1011
BEGIN {
11-
/*
12-
* Use an associative array to stringify the protocol number.
13-
*/
14-
protos[1] = "ICMP";
15-
protos[2] = "IGMP";
16-
protos[6] = "TCP";
17-
protos[17] = "UDP";
18-
protos[255] = "XXX";
19-
2012
printf(HDR_FMT, "PORT", "LAYER", "MATCH", "DIR", "FLOW", "ACTION");
2113
num = 0;
2214
}

dtrace/opte-tcp-flow-state.d

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44
* dtrace -L ./lib -I . -Cqs ./opte-tcp-flow-state.d
55
*/
66
#include "common.h"
7+
#include "protos.d"
78

89
#define FMT "%-16s %-12s %-12s %s\n"
910

1011
BEGIN {
11-
/*
12-
* Use an associative array to stringify the protocol number.
13-
* It's always going to be TCP but we need this declared so
14-
* the FLOW_FMT macros work.
15-
*/
16-
protos[6] = "TCP";
17-
1812
/*
1913
* Use an associative array to stringify the TCP state
2014
* values.

dtrace/opte-uft-invaildate.d

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,12 @@
88
* dtrace -L ./lib -I . -Cqs ./opte-uft-invalidate.d
99
*/
1010
#include "common.h"
11+
#include "protos.d"
1112

1213
#define HDR_FMT "%-8s %-3s %-43s %s\n"
1314
#define LINE_FMT "%-8s %-3s %-43s %u\n"
1415

1516
BEGIN {
16-
/*
17-
* Use an associative array to stringify the protocol number.
18-
*/
19-
protos[1] = "ICMP";
20-
protos[2] = "IGMP";
21-
protos[6] = "TCP";
22-
protos[17] = "UDP";
23-
protos[255] = "XXX";
24-
2517
printf(HDR_FMT, "PORT", "DIR", "FLOW", "EPOCH");
2618
num = 0;
2719
}

dtrace/protos.d

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Definitions of the IP protocol numbers as an associative array.
3+
*/
4+
BEGIN {
5+
protos[1] = "ICMP";
6+
protos[2] = "IGMP";
7+
protos[6] = "TCP";
8+
protos[17] = "UDP";
9+
protos[58] = "ICMPv6";
10+
protos[255] = "XXX";
11+
}

opte-api/check-api-version.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22
#
3-
# If there is a change to an opte-api source file in the last commit,
4-
# then verify that the API_VERSION value has increased.
5-
if git log -1 -p master..HEAD | grep '^diff.*opte-api/src'
3+
# If there is a change to an opte-api source file relative to the `master`
4+
# branch, # then verify that the API_VERSION value has increased.
5+
if git diff master..HEAD | grep '^diff.*opte-api/src'
66
then
7-
git log -p -1 master..HEAD | awk -f check-api-version.awk
7+
git diff master..HEAD | awk -f check-api-version.awk
88
fi

opte-api/src/cmd.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Copyright 2022 Oxide Computer Company
66

77
use super::encap::Vni;
8+
use super::ip::IpCidr;
89
use super::mac::MacAddr;
910
use super::API_VERSION;
1011
use illumos_sys_hdrs::{c_int, size_t};
@@ -24,21 +25,21 @@ pub const XDE_DLD_OPTE_CMD: i32 = XDE_DLD_PREFIX | 7777;
2425
#[derive(Clone, Copy, Debug)]
2526
#[repr(C)]
2627
pub enum OpteCmd {
27-
ListPorts = 1, // list all ports
28-
AddFwRule = 20, // add firewall rule
29-
RemFwRule = 21, // remove firewall rule
30-
SetFwRules = 22, // set/replace all firewall rules at once
31-
DumpTcpFlows = 30, // dump TCP flows
32-
DumpLayer = 31, // dump the specified Layer
33-
DumpUft = 32, // dump the Unified Flow Table
34-
ListLayers = 33, // list the layers on a given port
35-
ClearUft = 40, // clear the UFT
36-
SetVirt2Phys = 50, // set a v2p mapping
37-
DumpVirt2Phys = 51, // dump the v2p mappings
38-
AddRouterEntryIpv4 = 60, // add a router entry for IPv4 dest
39-
CreateXde = 70, // create a new xde device
40-
DeleteXde = 71, // delete an xde device
41-
SetXdeUnderlay = 72, // set xde underlay devices
28+
ListPorts = 1, // list all ports
29+
AddFwRule = 20, // add firewall rule
30+
RemFwRule = 21, // remove firewall rule
31+
SetFwRules = 22, // set/replace all firewall rules at once
32+
DumpTcpFlows = 30, // dump TCP flows
33+
DumpLayer = 31, // dump the specified Layer
34+
DumpUft = 32, // dump the Unified Flow Table
35+
ListLayers = 33, // list the layers on a given port
36+
ClearUft = 40, // clear the UFT
37+
SetVirt2Phys = 50, // set a v2p mapping
38+
DumpVirt2Phys = 51, // dump the v2p mappings
39+
AddRouterEntry = 60, // add a router entry for IP dest
40+
CreateXde = 70, // create a new xde device
41+
DeleteXde = 71, // delete an xde device
42+
SetXdeUnderlay = 72, // set xde underlay devices
4243
}
4344

4445
impl TryFrom<c_int> for OpteCmd {
@@ -57,7 +58,7 @@ impl TryFrom<c_int> for OpteCmd {
5758
40 => Ok(Self::ClearUft),
5859
50 => Ok(Self::SetVirt2Phys),
5960
51 => Ok(Self::DumpVirt2Phys),
60-
60 => Ok(Self::AddRouterEntryIpv4),
61+
60 => Ok(Self::AddRouterEntry),
6162
70 => Ok(Self::CreateXde),
6263
71 => Ok(Self::DeleteXde),
6364
72 => Ok(Self::SetXdeUnderlay),
@@ -146,7 +147,7 @@ pub enum OpteError {
146147
DeserCmdErr(String),
147148
DeserCmdReq(String),
148149
FlowExists(String),
149-
InvalidRouteDest(String),
150+
InvalidRouterEntry { dest: IpCidr, target: String },
150151
LayerNotFound(String),
151152
MacExists { port: String, vni: Vni, mac: MacAddr },
152153
MaxCapacity(u64),
@@ -181,7 +182,7 @@ impl OpteError {
181182
Self::DeserCmdErr(_) => ENOMSG,
182183
Self::DeserCmdReq(_) => ENOMSG,
183184
Self::FlowExists(_) => EEXIST,
184-
Self::InvalidRouteDest(_) => EINVAL,
185+
Self::InvalidRouterEntry { .. } => EINVAL,
185186
Self::LayerNotFound(_) => ENOENT,
186187
Self::MacExists { .. } => EEXIST,
187188
Self::MaxCapacity(_) => ENFILE,

0 commit comments

Comments
 (0)