Skip to content

Adds basic support for IPv6 #255

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

Merged
merged 3 commits into from
Sep 19, 2022
Merged
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
8 changes: 4 additions & 4 deletions dtrace/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
*this->src_ip6 = fvar->src_ip6; \
*this->dst_ip6 = fvar->dst_ip6; \
svar = protos[fvar->proto]; \
svar = strjoin(svar, ","); \
svar = strjoin(svar, ",["); \
svar = strjoin(svar, inet_ntoa6(this->src_ip6)); \
svar = strjoin(svar, ":"); \
svar = strjoin(svar, "]:"); \
svar = strjoin(svar, lltostr(ntohs(fvar->src_port))); \
svar = strjoin(svar, ","); \
svar = strjoin(svar, ",["); \
svar = strjoin(svar, inet_ntoa6(this->dst_ip6)); \
svar = strjoin(svar, ":"); \
svar = strjoin(svar, "]:"); \
svar = strjoin(svar, lltostr(ntohs(fvar->dst_port)));

#define ETH_FMT(svar, evar) \
Expand Down
9 changes: 1 addition & 8 deletions dtrace/opte-flow-expire.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@
* dtrace -L ./lib -I . -Cqs ./opte-flow-expire.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
*/
protos[1]= "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";

printf(HDR_FMT, "PORT", "FT NAME", "FLOW");
num = 0;
}
Expand Down
9 changes: 1 addition & 8 deletions dtrace/opte-gen-desc-fail.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@
* dtrace -L ./lib -I . -Cqs ./opte-gen-desc-fail.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
*/
protos[1] = "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";

printf(HDR_FMT, "PORT", "LAYER", "DIR", "FLOW", "MSG");
num = 0;
}
Expand Down
8 changes: 1 addition & 7 deletions dtrace/opte-gen-ht-fail.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
* dtrace -L ./lib -I . -Cqs ./opte-gen-desc-fail.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
*/
protos[1] = "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";

printf(HDR_FMT, "PORT", "LAYER", "DIR", "FLOW", "MSG");
num = 0;
Expand Down
10 changes: 1 addition & 9 deletions dtrace/opte-guest-loopback.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@
* dtrace -L ./lib -I . -Cqs ./opte-guest-loopback.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
*/
protos[1] = "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";
protos[255] = "XXX";

printf(HDR_FMT, "FLOW", "SRC PORT", "DST PORT");
num = 0;
}
Expand Down
11 changes: 2 additions & 9 deletions dtrace/opte-ht.d
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
/*
* Track Header Transpositions as they happen.
* Track Header Transformations as they happen.
*
* dtrace -L ./lib -I . -Cqs ./opte-ht.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
*/
protos[1]= "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";

printf(HDR_FMT, "DIR", "PORT", "LOCATION", "BEFORE", "AFTER");
num = 0;
}
Expand Down
10 changes: 1 addition & 9 deletions dtrace/opte-layer-process.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@
* dtrace -L ./lib -I . -Cqs ./opte-layer-process.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
*/
protos[1] = "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";
protos[255] = "XXX";

printf(HDR_FMT, "PORT", "LAYER", "DIR", "FLOW", "RES");
num = 0;
}
Expand Down
6 changes: 1 addition & 5 deletions dtrace/opte-port-process.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* dtrace -L ./lib -I . -Cqs ./opte-port-process.d
*/
#include "common.h"
#include "protos.d"

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

printf(HDR_FMT, "NAME", "DIR", "EPOCH", "FLOW", "LEN", "RESULT");
num = 0;
Expand Down
10 changes: 1 addition & 9 deletions dtrace/opte-rule-match.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@
* dtrace -L ./lib -I . -Cqs ./opte-rule-match.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
*/
protos[1] = "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";
protos[255] = "XXX";

printf(HDR_FMT, "PORT", "LAYER", "MATCH", "DIR", "FLOW", "ACTION");
num = 0;
}
Expand Down
8 changes: 1 addition & 7 deletions dtrace/opte-tcp-flow-state.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
* dtrace -L ./lib -I . -Cqs ./opte-tcp-flow-state.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
* It's always going to be TCP but we need this declared so
* the FLOW_FMT macros work.
*/
protos[6] = "TCP";

/*
* Use an associative array to stringify the TCP state
* values.
Expand Down
10 changes: 1 addition & 9 deletions dtrace/opte-uft-invaildate.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@
* dtrace -L ./lib -I . -Cqs ./opte-uft-invalidate.d
*/
#include "common.h"
#include "protos.d"

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

BEGIN {
/*
* Use an associative array to stringify the protocol number.
*/
protos[1] = "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";
protos[255] = "XXX";

printf(HDR_FMT, "PORT", "DIR", "FLOW", "EPOCH");
num = 0;
}
Expand Down
11 changes: 11 additions & 0 deletions dtrace/protos.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Definitions of the IP protocol numbers as an associative array.
*/
BEGIN {
protos[1] = "ICMP";
protos[2] = "IGMP";
protos[6] = "TCP";
protos[17] = "UDP";
protos[58] = "ICMPv6";
protos[255] = "XXX";
}
8 changes: 4 additions & 4 deletions opte-api/check-api-version.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
#
# If there is a change to an opte-api source file in the last commit,
# then verify that the API_VERSION value has increased.
if git log -1 -p master..HEAD | grep '^diff.*opte-api/src'
# If there is a change to an opte-api source file relative to the `master`
# branch, # then verify that the API_VERSION value has increased.
if git diff master..HEAD | grep '^diff.*opte-api/src'
then
git log -p -1 master..HEAD | awk -f check-api-version.awk
git diff master..HEAD | awk -f check-api-version.awk
fi
37 changes: 19 additions & 18 deletions opte-api/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Copyright 2022 Oxide Computer Company

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

impl TryFrom<c_int> for OpteCmd {
Expand All @@ -57,7 +58,7 @@ impl TryFrom<c_int> for OpteCmd {
40 => Ok(Self::ClearUft),
50 => Ok(Self::SetVirt2Phys),
51 => Ok(Self::DumpVirt2Phys),
60 => Ok(Self::AddRouterEntryIpv4),
60 => Ok(Self::AddRouterEntry),
70 => Ok(Self::CreateXde),
71 => Ok(Self::DeleteXde),
72 => Ok(Self::SetXdeUnderlay),
Expand Down Expand Up @@ -146,7 +147,7 @@ pub enum OpteError {
DeserCmdErr(String),
DeserCmdReq(String),
FlowExists(String),
InvalidRouteDest(String),
InvalidRouterEntry { dest: IpCidr, target: String },
LayerNotFound(String),
MacExists { port: String, vni: Vni, mac: MacAddr },
MaxCapacity(u64),
Expand Down Expand Up @@ -181,7 +182,7 @@ impl OpteError {
Self::DeserCmdErr(_) => ENOMSG,
Self::DeserCmdReq(_) => ENOMSG,
Self::FlowExists(_) => EEXIST,
Self::InvalidRouteDest(_) => EINVAL,
Self::InvalidRouterEntry { .. } => EINVAL,
Self::LayerNotFound(_) => ENOENT,
Self::MacExists { .. } => EEXIST,
Self::MaxCapacity(_) => ENFILE,
Expand Down
Loading