Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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: 2 additions & 0 deletions crates/opte-api/src/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ impl FromStr for IpAddr {
PartialOrd,
Serialize,
)]
#[repr(C)]
pub struct Ipv4Addr {
inner: [u8; 4],
}
Expand Down Expand Up @@ -554,6 +555,7 @@ impl Deref for Ipv4Addr {
Serialize,
Deserialize,
)]
#[repr(C)]
pub struct Ipv6Addr {
inner: [u8; 16],
}
Expand Down
2 changes: 1 addition & 1 deletion crates/opte-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub use ulp::*;
///
/// We rely on CI and the check-api-version.sh script to verify that
/// this number is incremented anytime the oxide-api code changes.
pub const API_VERSION: u64 = 29;
pub const API_VERSION: u64 = 30;

/// Major version of the OPTE package.
pub const MAJOR_VERSION: u64 = 0;
Expand Down
19 changes: 11 additions & 8 deletions dtrace/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@
#define FLOW_FMT(svar, fvar) \
this->src_ip = (ipaddr_t *)alloca(4); \
this->dst_ip = (ipaddr_t *)alloca(4); \
*this->src_ip = fvar->src_ip4; \
*this->dst_ip = fvar->dst_ip4; \
*this->src_ip = fvar->addrs.ip4.src; \
*this->dst_ip = fvar->addrs.ip4.dst; \
svar = protos[fvar->proto]; \
svar = strjoin(svar, ","); \
svar = strjoin(svar, inet_ntoa(this->src_ip)); \
svar = strjoin(svar, ":"); \
svar = strjoin(svar, lltostr(ntohs(fvar->src_port))); \
svar = strjoin(svar, lltostr(fvar->src_port)); \
svar = strjoin(svar, ","); \
svar = strjoin(svar, inet_ntoa(this->dst_ip)); \
svar = strjoin(svar, ":"); \
svar = strjoin(svar, lltostr(ntohs(fvar->dst_port)));
svar = strjoin(svar, lltostr(fvar->dst_port));

#define FLOW_FMT6(svar, fvar) \
this->src_ip6 = (in6_addr_t *)alloca(16); \
this->dst_ip6 = (in6_addr_t *)alloca(16); \
*this->src_ip6 = fvar->src_ip6; \
*this->dst_ip6 = fvar->dst_ip6; \
*this->src_ip6 = fvar->addrs.ip6.src; \
*this->dst_ip6 = fvar->addrs.ip6.dst; \
svar = protos[fvar->proto]; \
svar = strjoin(svar, ",["); \
svar = strjoin(svar, inet_ntoa6(this->src_ip6)); \
svar = strjoin(svar, "]:"); \
svar = strjoin(svar, lltostr(ntohs(fvar->src_port))); \
svar = strjoin(svar, lltostr(fvar->src_port)); \
svar = strjoin(svar, ",["); \
svar = strjoin(svar, inet_ntoa6(this->dst_ip6)); \
svar = strjoin(svar, "]:"); \
svar = strjoin(svar, lltostr(ntohs(fvar->dst_port)));
svar = strjoin(svar, lltostr(fvar->dst_port));

#define ETH_FMT(svar, evar) \
svar = substr(lltostr(evar[0], 16), 2); \
Expand All @@ -55,3 +55,6 @@
* 2 = Outbound
*/
#define DIR_STR(dir) ((dir) == 1 ? "IN" : "OUT")

#define EL_DELIMIT "->"
#define EL_FMT "->%s"
26 changes: 16 additions & 10 deletions dtrace/lib/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
#pragma D depends_on provider ip

typedef struct flow_id_sdt_arg {
int af;
ipaddr_t src_ip4;
ipaddr_t dst_ip4;
in6_addr_t src_ip6;
in6_addr_t dst_ip6;
uint8_t proto;
uint16_t af;
union addrs {
struct {
ipaddr_t src;
ipaddr_t dst;
} ip4;
struct {
in6_addr_t src;
in6_addr_t dst;
} ip6;
} addrs;
uint16_t src_port;
uint16_t dst_port;
uint8_t proto;
} flow_id_sdt_arg_t;

typedef struct rule_match_sdt_arg {
Expand Down Expand Up @@ -48,8 +54,8 @@ typedef struct opte_cmd_ioctl {
} opte_cmd_ioctl_t;

typedef struct derror_sdt_arg {
size_t len;
uint8_t truncated;
uint64_t data[2];
char* entry[8];
size_t len;
uint8_t truncated;
uint64_t data[2];
char* entry[8];
} derror_sdt_arg_t;
33 changes: 21 additions & 12 deletions dtrace/opte-bad-packet.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#include "common.h"

#define HDR_FMT "%-12s %-3s %-18s %s\n"
#define LINE_FMT "%-12s %-3s 0x%-16p "
#define EL_FMT "->%s"
#define LINE_FMT "%-12s %-3s 0x%-16p %s[%d, %d]\n"

BEGIN {
printf(HDR_FMT, "PORT", "DIR", "MBLK", "MSG+DATA");
Expand All @@ -21,13 +20,13 @@ bad-packet {
this->msgs = (derror_sdt_arg_t*) arg3;
this->msg_len = this->msgs->len;
this->data_len = arg4;
this->res = stringof("");

if (num >= 10) {
printf(HDR_FMT, "PORT", "DIR", "MBLK", "MSG+DATA");
num = 0;
}

printf(LINE_FMT, this->port, this->dir, this->mblk);
num++;
}

Expand All @@ -36,51 +35,61 @@ bad-packet {
bad-packet
/this->msg_len > 0/
{
printf("%s", stringof(this->msgs->entry[0]));
this->res = strjoin(this->res, stringof(this->msgs->entry[0]));
}

bad-packet
/this->msg_len > 1/
{
printf(EL_FMT, stringof(this->msgs->entry[1]));
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[1]));
}

bad-packet
/this->msg_len > 2/
{
printf(EL_FMT, stringof(this->msgs->entry[2]));
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[2]));
}

bad-packet
/this->msg_len > 3/
{
printf(EL_FMT, stringof(this->msgs->entry[3]));
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[3]));
}

bad-packet
/this->msg_len > 4/
{
printf(EL_FMT, stringof(this->msgs->entry[4]));
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[4]));
}

bad-packet
/this->msg_len > 5/
{
printf(EL_FMT, stringof(this->msgs->entry[5]));
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[5]));
}

bad-packet
/this->msg_len > 6/
{
printf(EL_FMT, stringof(this->msgs->entry[6]));
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[6]));
}

bad-packet
/this->msg_len > 7/
{
printf(EL_FMT, stringof(this->msgs->entry[7]));
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[7]));
}

bad-packet {
printf(" [%d, %d]\n", this->msgs->data[0], this->msgs->data[1]);
printf(LINE_FMT,
this->port, this->dir, this->mblk,
this->res, this->msgs->data[0], this->msgs->data[1]
);
}
17 changes: 16 additions & 1 deletion dtrace/opte-layer-process.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ layer-process-return {
this->layer = stringof(arg2);
this->flow_before = (flow_id_sdt_arg_t *)arg3;
this->flow_after = (flow_id_sdt_arg_t *)arg4;
this->res = stringof(arg5);
this->msgs = (derror_sdt_arg_t*) arg5;
this->msg_len = this->msgs->len;
this->res = stringof("");

if (num >= 10) {
printf(HDR_FMT, "PORT", "LAYER", "DIR", "FLOW BEFORE",
Expand All @@ -38,6 +40,19 @@ layer-process-return {
}
}

layer-process-return
/this->msg_len > 0/
{
this->res = strjoin(this->res, stringof(this->msgs->entry[0]));
}

layer-process-return
/this->msg_len > 1/
{
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[1]));
}

layer-process-return /this->af == AF_INET/ {
FLOW_FMT(this->s_before, this->flow_before);
FLOW_FMT(this->s_after, this->flow_after);
Expand Down
18 changes: 16 additions & 2 deletions dtrace/opte-port-process.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ port-process-return {
this->mp = (mblk_t *)arg5;
/* If the result is a hairpin packet, then hp_mp is non-NULL. */
this->hp_mp = (mblk_t *)arg6;
this->res = stringof(arg7);
this->msgs = (derror_sdt_arg_t*) arg7;
this->msg_len = this->msgs->len;
this->res = stringof("");

if (num >= 10) {
printf(HDR_FMT, "NAME", "DIR", "EPOCH", "FLOW BEFORE",
Expand All @@ -39,6 +41,19 @@ port-process-return {
}
}

port-process-return
/this->msg_len > 0/
{
this->res = strjoin(this->res, stringof(this->msgs->entry[0]));
}

port-process-return
/this->msg_len > 1/
{
this->res = strjoin(this->res, EL_DELIMIT);
this->res = strjoin(this->res, stringof(this->msgs->entry[1]));
}

port-process-return /this->af == AF_INET/ {
FLOW_FMT(this->s_before, this->flow_before);
FLOW_FMT(this->s_after, this->flow_after);
Expand All @@ -55,4 +70,3 @@ port-process-return /this->af == AF_INET6/ {
num++;
}


Loading