Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
36ce1124
Commit
36ce1124
authored
Aug 17, 2018
by
Joe Yin
Committed by
yonghong-song
Aug 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch IPv4 saddr/daddr to u32's within tools/tcpstates.py (#1862)
make types appropriate for ipaddr/protocol etc.
parent
8cdcb0da
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
68 deletions
+77
-68
tools/tcpaccept.py
tools/tcpaccept.py
+8
-8
tools/tcpconnect.py
tools/tcpconnect.py
+12
-12
tools/tcpdrop.py
tools/tcpdrop.py
+9
-7
tools/tcplife.py
tools/tcplife.py
+20
-16
tools/tcpretrans.py
tools/tcpretrans.py
+20
-17
tools/tcpstates.py
tools/tcpstates.py
+8
-8
No files found.
tools/tcpaccept.py
View file @
36ce1124
...
@@ -51,22 +51,22 @@ bpf_text = """
...
@@ -51,22 +51,22 @@ bpf_text = """
struct ipv4_data_t {
struct ipv4_data_t {
// XXX: switch some to u32's when supported
// XXX: switch some to u32's when supported
u64 ts_us;
u64 ts_us;
u
64
pid;
u
32
pid;
u32 saddr;
u32 saddr;
u32 daddr;
u32 daddr;
u64 ip;
u64 ip;
u
64
lport;
u
16
lport;
char task[TASK_COMM_LEN];
char task[TASK_COMM_LEN];
};
};
BPF_PERF_OUTPUT(ipv4_events);
BPF_PERF_OUTPUT(ipv4_events);
struct ipv6_data_t {
struct ipv6_data_t {
u64 ts_us;
u64 ts_us;
u
64
pid;
u
32
pid;
unsigned __int128 saddr;
unsigned __int128 saddr;
unsigned __int128 daddr;
unsigned __int128 daddr;
u64 ip;
u64 ip;
u
64
lport;
u
16
lport;
char task[TASK_COMM_LEN];
char task[TASK_COMM_LEN];
};
};
BPF_PERF_OUTPUT(ipv6_events);
BPF_PERF_OUTPUT(ipv6_events);
...
@@ -212,22 +212,22 @@ TASK_COMM_LEN = 16 # linux/sched.h
...
@@ -212,22 +212,22 @@ TASK_COMM_LEN = 16 # linux/sched.h
class
Data_ipv4
(
ct
.
Structure
):
class
Data_ipv4
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"pid"
,
ct
.
c_u
longlong
),
(
"pid"
,
ct
.
c_u
int
),
(
"saddr"
,
ct
.
c_uint
),
(
"saddr"
,
ct
.
c_uint
),
(
"daddr"
,
ct
.
c_uint
),
(
"daddr"
,
ct
.
c_uint
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"lport"
,
ct
.
c_u
longlong
),
(
"lport"
,
ct
.
c_u
short
),
(
"task"
,
ct
.
c_char
*
TASK_COMM_LEN
)
(
"task"
,
ct
.
c_char
*
TASK_COMM_LEN
)
]
]
class
Data_ipv6
(
ct
.
Structure
):
class
Data_ipv6
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"pid"
,
ct
.
c_u
longlong
),
(
"pid"
,
ct
.
c_u
int
),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"ip"
,
ct
.
c_ulonglong
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"lport"
,
ct
.
c_u
longlong
),
(
"lport"
,
ct
.
c_u
short
),
(
"task"
,
ct
.
c_char
*
TASK_COMM_LEN
)
(
"task"
,
ct
.
c_char
*
TASK_COMM_LEN
)
]
]
...
...
tools/tcpconnect.py
View file @
36ce1124
...
@@ -59,22 +59,22 @@ BPF_HASH(currsock, u32, struct sock *);
...
@@ -59,22 +59,22 @@ BPF_HASH(currsock, u32, struct sock *);
struct ipv4_data_t {
struct ipv4_data_t {
// XXX: switch some to u32's when supported
// XXX: switch some to u32's when supported
u64 ts_us;
u64 ts_us;
u
64
pid;
u
32
pid;
u
64
saddr;
u
32
saddr;
u
64
daddr;
u
32
daddr;
u64 ip;
u64 ip;
u
64
dport;
u
16
dport;
char task[TASK_COMM_LEN];
char task[TASK_COMM_LEN];
};
};
BPF_PERF_OUTPUT(ipv4_events);
BPF_PERF_OUTPUT(ipv4_events);
struct ipv6_data_t {
struct ipv6_data_t {
u64 ts_us;
u64 ts_us;
u
64
pid;
u
32
pid;
unsigned __int128 saddr;
unsigned __int128 saddr;
unsigned __int128 daddr;
unsigned __int128 daddr;
u64 ip;
u64 ip;
u
64
dport;
u
16
dport;
char task[TASK_COMM_LEN];
char task[TASK_COMM_LEN];
};
};
BPF_PERF_OUTPUT(ipv6_events);
BPF_PERF_OUTPUT(ipv6_events);
...
@@ -175,22 +175,22 @@ TASK_COMM_LEN = 16 # linux/sched.h
...
@@ -175,22 +175,22 @@ TASK_COMM_LEN = 16 # linux/sched.h
class
Data_ipv4
(
ct
.
Structure
):
class
Data_ipv4
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"pid"
,
ct
.
c_u
longlong
),
(
"pid"
,
ct
.
c_u
int
),
(
"saddr"
,
ct
.
c_u
longlong
),
(
"saddr"
,
ct
.
c_u
int
),
(
"daddr"
,
ct
.
c_u
longlong
),
(
"daddr"
,
ct
.
c_u
int
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"dport"
,
ct
.
c_u
longlong
),
(
"dport"
,
ct
.
c_u
short
),
(
"task"
,
ct
.
c_char
*
TASK_COMM_LEN
)
(
"task"
,
ct
.
c_char
*
TASK_COMM_LEN
)
]
]
class
Data_ipv6
(
ct
.
Structure
):
class
Data_ipv6
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"pid"
,
ct
.
c_u
longlong
),
(
"pid"
,
ct
.
c_u
int
),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"ip"
,
ct
.
c_ulonglong
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"dport"
,
ct
.
c_u
longlong
),
(
"dport"
,
ct
.
c_u
short
),
(
"task"
,
ct
.
c_char
*
TASK_COMM_LEN
)
(
"task"
,
ct
.
c_char
*
TASK_COMM_LEN
)
]
]
...
...
tools/tcpdrop.py
View file @
36ce1124
...
@@ -54,8 +54,8 @@ BPF_STACK_TRACE(stack_traces, 1024);
...
@@ -54,8 +54,8 @@ BPF_STACK_TRACE(stack_traces, 1024);
struct ipv4_data_t {
struct ipv4_data_t {
u32 pid;
u32 pid;
u64 ip;
u64 ip;
u
64
saddr;
u
32
saddr;
u
64
daddr;
u
32
daddr;
u16 sport;
u16 sport;
u16 dport;
u16 dport;
u8 state;
u8 state;
...
@@ -113,7 +113,9 @@ int trace_tcp_drop(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb)
...
@@ -113,7 +113,9 @@ int trace_tcp_drop(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb)
dport = ntohs(dport);
dport = ntohs(dport);
if (family == AF_INET) {
if (family == AF_INET) {
struct ipv4_data_t data4 = {.pid = pid, .ip = 4};
struct ipv4_data_t data4 = {};
data4.pid = pid;
data4.ip = 4;
data4.saddr = ip->saddr;
data4.saddr = ip->saddr;
data4.daddr = ip->daddr;
data4.daddr = ip->daddr;
data4.dport = dport;
data4.dport = dport;
...
@@ -150,10 +152,10 @@ if debug or args.ebpf:
...
@@ -150,10 +152,10 @@ if debug or args.ebpf:
# event data
# event data
class
Data_ipv4
(
ct
.
Structure
):
class
Data_ipv4
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"pid"
,
ct
.
c_u
long
),
(
"pid"
,
ct
.
c_u
int
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"saddr"
,
ct
.
c_u
longlong
),
(
"saddr"
,
ct
.
c_u
int
),
(
"daddr"
,
ct
.
c_u
longlong
),
(
"daddr"
,
ct
.
c_u
int
),
(
"sport"
,
ct
.
c_ushort
),
(
"sport"
,
ct
.
c_ushort
),
(
"dport"
,
ct
.
c_ushort
),
(
"dport"
,
ct
.
c_ushort
),
(
"state"
,
ct
.
c_ubyte
),
(
"state"
,
ct
.
c_ubyte
),
...
@@ -163,7 +165,7 @@ class Data_ipv4(ct.Structure):
...
@@ -163,7 +165,7 @@ class Data_ipv4(ct.Structure):
class
Data_ipv6
(
ct
.
Structure
):
class
Data_ipv6
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"pid"
,
ct
.
c_u
long
),
(
"pid"
,
ct
.
c_u
int
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
...
...
tools/tcplife.py
View file @
36ce1124
...
@@ -78,9 +78,9 @@ BPF_HASH(birth, struct sock *, u64);
...
@@ -78,9 +78,9 @@ BPF_HASH(birth, struct sock *, u64);
struct ipv4_data_t {
struct ipv4_data_t {
// XXX: switch some to u32's when supported
// XXX: switch some to u32's when supported
u64 ts_us;
u64 ts_us;
u
64
pid;
u
32
pid;
u
64
saddr;
u
32
saddr;
u
64
daddr;
u
32
daddr;
u64 ports;
u64 ports;
u64 rx_b;
u64 rx_b;
u64 tx_b;
u64 tx_b;
...
@@ -91,7 +91,7 @@ BPF_PERF_OUTPUT(ipv4_events);
...
@@ -91,7 +91,7 @@ BPF_PERF_OUTPUT(ipv4_events);
struct ipv6_data_t {
struct ipv6_data_t {
u64 ts_us;
u64 ts_us;
u
64
pid;
u
32
pid;
unsigned __int128 saddr;
unsigned __int128 saddr;
unsigned __int128 daddr;
unsigned __int128 daddr;
u64 ports;
u64 ports;
...
@@ -195,8 +195,10 @@ int kprobe__tcp_set_state(struct pt_regs *ctx, struct sock *sk, int state)
...
@@ -195,8 +195,10 @@ int kprobe__tcp_set_state(struct pt_regs *ctx, struct sock *sk, int state)
u16 family = sk->__sk_common.skc_family;
u16 family = sk->__sk_common.skc_family;
if (family == AF_INET) {
if (family == AF_INET) {
struct ipv4_data_t data4 = {.span_us = delta_us,
struct ipv4_data_t data4 = {};
.rx_b = rx_b, .tx_b = tx_b};
data4.span_us = delta_us;
data4.rx_b = rx_b;
data4.tx_b = tx_b;
data4.ts_us = bpf_ktime_get_ns() / 1000;
data4.ts_us = bpf_ktime_get_ns() / 1000;
data4.saddr = sk->__sk_common.skc_rcv_saddr;
data4.saddr = sk->__sk_common.skc_rcv_saddr;
data4.daddr = sk->__sk_common.skc_daddr;
data4.daddr = sk->__sk_common.skc_daddr;
...
@@ -316,11 +318,13 @@ TRACEPOINT_PROBE(sock, inet_sock_set_state)
...
@@ -316,11 +318,13 @@ TRACEPOINT_PROBE(sock, inet_sock_set_state)
tx_b = tp->bytes_acked;
tx_b = tp->bytes_acked;
if (args->family == AF_INET) {
if (args->family == AF_INET) {
struct ipv4_data_t data4 = {.span_us = delta_us,
struct ipv4_data_t data4 = {};
.rx_b = rx_b, .tx_b = tx_b};
data4.span_us = delta_us;
data4.rx_b = rx_b;
data4.tx_b = tx_b;
data4.ts_us = bpf_ktime_get_ns() / 1000;
data4.ts_us = bpf_ktime_get_ns() / 1000;
bpf_probe_read(&data4.saddr, sizeof(u32), args->saddr
);
__builtin_memcpy(&data4.saddr, args->saddr, sizeof(data4.saddr)
);
bpf_probe_read(&data4.daddr, sizeof(u32), args->daddr
);
__builtin_memcpy(&data4.daddr, args->daddr, sizeof(data4.daddr)
);
// a workaround until data4 compiles with separate lport/dport
// a workaround until data4 compiles with separate lport/dport
data4.ports = dport + ((0ULL + lport) << 32);
data4.ports = dport + ((0ULL + lport) << 32);
data4.pid = pid;
data4.pid = pid;
...
@@ -336,8 +340,8 @@ TRACEPOINT_PROBE(sock, inet_sock_set_state)
...
@@ -336,8 +340,8 @@ TRACEPOINT_PROBE(sock, inet_sock_set_state)
struct ipv6_data_t data6 = {.span_us = delta_us,
struct ipv6_data_t data6 = {.span_us = delta_us,
.rx_b = rx_b, .tx_b = tx_b};
.rx_b = rx_b, .tx_b = tx_b};
data6.ts_us = bpf_ktime_get_ns() / 1000;
data6.ts_us = bpf_ktime_get_ns() / 1000;
bpf_probe_read(&data6.saddr, sizeof(data6.saddr), args->saddr_v6
);
__builtin_memcpy(&data6.saddr, args->saddr_v6, sizeof(data6.saddr)
);
bpf_probe_read(&data6.daddr, sizeof(data6.daddr), args->saddr_v6
);
__builtin_memcpy(&data6.daddr, args->daddr_v6, sizeof(data6.daddr)
);
// a workaround until data6 compiles with separate lport/dport
// a workaround until data6 compiles with separate lport/dport
data6.ports = dport + ((0ULL + lport) << 32);
data6.ports = dport + ((0ULL + lport) << 32);
data6.pid = pid;
data6.pid = pid;
...
@@ -390,9 +394,9 @@ TASK_COMM_LEN = 16 # linux/sched.h
...
@@ -390,9 +394,9 @@ TASK_COMM_LEN = 16 # linux/sched.h
class
Data_ipv4
(
ct
.
Structure
):
class
Data_ipv4
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"pid"
,
ct
.
c_u
longlong
),
(
"pid"
,
ct
.
c_u
int
),
(
"saddr"
,
ct
.
c_u
longlong
),
(
"saddr"
,
ct
.
c_u
int
),
(
"daddr"
,
ct
.
c_u
longlong
),
(
"daddr"
,
ct
.
c_u
int
),
(
"ports"
,
ct
.
c_ulonglong
),
(
"ports"
,
ct
.
c_ulonglong
),
(
"rx_b"
,
ct
.
c_ulonglong
),
(
"rx_b"
,
ct
.
c_ulonglong
),
(
"tx_b"
,
ct
.
c_ulonglong
),
(
"tx_b"
,
ct
.
c_ulonglong
),
...
@@ -403,7 +407,7 @@ class Data_ipv4(ct.Structure):
...
@@ -403,7 +407,7 @@ class Data_ipv4(ct.Structure):
class
Data_ipv6
(
ct
.
Structure
):
class
Data_ipv6
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"pid"
,
ct
.
c_u
longlong
),
(
"pid"
,
ct
.
c_u
int
),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"ports"
,
ct
.
c_ulonglong
),
(
"ports"
,
ct
.
c_ulonglong
),
...
...
tools/tcpretrans.py
View file @
36ce1124
...
@@ -54,24 +54,24 @@ bpf_text = """
...
@@ -54,24 +54,24 @@ bpf_text = """
// separate data structs for ipv4 and ipv6
// separate data structs for ipv4 and ipv6
struct ipv4_data_t {
struct ipv4_data_t {
// XXX: switch some to u32's when supported
// XXX: switch some to u32's when supported
u
64
pid;
u
32
pid;
u64 ip;
u64 ip;
u
64
saddr;
u
32
saddr;
u
64
daddr;
u
32
daddr;
u
64
lport;
u
16
lport;
u
64
dport;
u
16
dport;
u64 state;
u64 state;
u64 type;
u64 type;
};
};
BPF_PERF_OUTPUT(ipv4_events);
BPF_PERF_OUTPUT(ipv4_events);
struct ipv6_data_t {
struct ipv6_data_t {
u
64
pid;
u
32
pid;
u64 ip;
u64 ip;
unsigned __int128 saddr;
unsigned __int128 saddr;
unsigned __int128 daddr;
unsigned __int128 daddr;
u
64
lport;
u
16
lport;
u
64
dport;
u
16
dport;
u64 state;
u64 state;
u64 type;
u64 type;
};
};
...
@@ -142,7 +142,10 @@ struct_init = { 'ipv4':
...
@@ -142,7 +142,10 @@ struct_init = { 'ipv4':
flow_key.dport = ntohs(dport);"""
,
flow_key.dport = ntohs(dport);"""
,
'trace'
:
'trace'
:
"""
"""
struct ipv4_data_t data4 = {.pid = pid, .ip = 4, .type = type};
struct ipv4_data_t data4 = {};
data4.pid = pid;
data4.ip = 4;
data4.type = type;
data4.saddr = skp->__sk_common.skc_rcv_saddr;
data4.saddr = skp->__sk_common.skc_rcv_saddr;
data4.daddr = skp->__sk_common.skc_daddr;
data4.daddr = skp->__sk_common.skc_daddr;
// lport is host order
// lport is host order
...
@@ -197,24 +200,24 @@ if debug or args.ebpf:
...
@@ -197,24 +200,24 @@ if debug or args.ebpf:
# event data
# event data
class
Data_ipv4
(
ct
.
Structure
):
class
Data_ipv4
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"pid"
,
ct
.
c_u
longlong
),
(
"pid"
,
ct
.
c_u
int
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"saddr"
,
ct
.
c_u
longlong
),
(
"saddr"
,
ct
.
c_u
int
),
(
"daddr"
,
ct
.
c_u
longlong
),
(
"daddr"
,
ct
.
c_u
int
),
(
"lport"
,
ct
.
c_u
longlong
),
(
"lport"
,
ct
.
c_u
short
),
(
"dport"
,
ct
.
c_u
longlong
),
(
"dport"
,
ct
.
c_u
short
),
(
"state"
,
ct
.
c_ulonglong
),
(
"state"
,
ct
.
c_ulonglong
),
(
"type"
,
ct
.
c_ulonglong
)
(
"type"
,
ct
.
c_ulonglong
)
]
]
class
Data_ipv6
(
ct
.
Structure
):
class
Data_ipv6
(
ct
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"pid"
,
ct
.
c_u
longlong
),
(
"pid"
,
ct
.
c_u
int
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"ip"
,
ct
.
c_ulonglong
),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"saddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"daddr"
,
(
ct
.
c_ulonglong
*
2
)),
(
"lport"
,
ct
.
c_u
longlong
),
(
"lport"
,
ct
.
c_u
short
),
(
"dport"
,
ct
.
c_u
longlong
),
(
"dport"
,
ct
.
c_u
short
),
(
"state"
,
ct
.
c_ulonglong
),
(
"state"
,
ct
.
c_ulonglong
),
(
"type"
,
ct
.
c_ulonglong
)
(
"type"
,
ct
.
c_ulonglong
)
]
]
...
...
tools/tcpstates.py
View file @
36ce1124
...
@@ -68,8 +68,8 @@ BPF_HASH(last, struct sock *, u64);
...
@@ -68,8 +68,8 @@ BPF_HASH(last, struct sock *, u64);
struct ipv4_data_t {
struct ipv4_data_t {
u64 ts_us;
u64 ts_us;
u64 skaddr;
u64 skaddr;
u
64
saddr;
u
32
saddr;
u
64
daddr;
u
32
daddr;
u64 span_us;
u64 span_us;
u32 pid;
u32 pid;
u32 ports;
u32 ports;
...
@@ -129,8 +129,8 @@ TRACEPOINT_PROBE(sock, inet_sock_set_state)
...
@@ -129,8 +129,8 @@ TRACEPOINT_PROBE(sock, inet_sock_set_state)
.oldstate = args->oldstate, .newstate = args->newstate};
.oldstate = args->oldstate, .newstate = args->newstate};
data4.skaddr = (u64)args->skaddr;
data4.skaddr = (u64)args->skaddr;
data4.ts_us = bpf_ktime_get_ns() / 1000;
data4.ts_us = bpf_ktime_get_ns() / 1000;
bpf_probe_read(&data4.saddr, sizeof(u32), args->saddr
);
__builtin_memcpy(&data4.saddr, args->saddr, sizeof(data4.saddr)
);
bpf_probe_read(&data4.daddr, sizeof(u32), args->daddr
);
__builtin_memcpy(&data4.daddr, args->daddr, sizeof(data4.daddr)
);
// a workaround until data4 compiles with separate lport/dport
// a workaround until data4 compiles with separate lport/dport
data4.ports = dport + ((0ULL + lport) << 32);
data4.ports = dport + ((0ULL + lport) << 32);
data4.pid = pid;
data4.pid = pid;
...
@@ -144,8 +144,8 @@ TRACEPOINT_PROBE(sock, inet_sock_set_state)
...
@@ -144,8 +144,8 @@ TRACEPOINT_PROBE(sock, inet_sock_set_state)
.oldstate = args->oldstate, .newstate = args->newstate};
.oldstate = args->oldstate, .newstate = args->newstate};
data6.skaddr = (u64)args->skaddr;
data6.skaddr = (u64)args->skaddr;
data6.ts_us = bpf_ktime_get_ns() / 1000;
data6.ts_us = bpf_ktime_get_ns() / 1000;
bpf_probe_read(&data6.saddr, sizeof(data6.saddr), args->saddr_v6
);
__builtin_memcpy(&data6.saddr, args->saddr_v6, sizeof(data6.saddr)
);
bpf_probe_read(&data6.daddr, sizeof(data6.daddr), args->saddr_v6
);
__builtin_memcpy(&data6.daddr, args->daddr_v6, sizeof(data6.daddr)
);
// a workaround until data6 compiles with separate lport/dport
// a workaround until data6 compiles with separate lport/dport
data6.ports = dport + ((0ULL + lport) << 32);
data6.ports = dport + ((0ULL + lport) << 32);
data6.pid = pid;
data6.pid = pid;
...
@@ -191,8 +191,8 @@ class Data_ipv4(ct.Structure):
...
@@ -191,8 +191,8 @@ class Data_ipv4(ct.Structure):
_fields_
=
[
_fields_
=
[
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"ts_us"
,
ct
.
c_ulonglong
),
(
"skaddr"
,
ct
.
c_ulonglong
),
(
"skaddr"
,
ct
.
c_ulonglong
),
(
"saddr"
,
ct
.
c_u
longlong
),
(
"saddr"
,
ct
.
c_u
int
),
(
"daddr"
,
ct
.
c_u
longlong
),
(
"daddr"
,
ct
.
c_u
int
),
(
"span_us"
,
ct
.
c_ulonglong
),
(
"span_us"
,
ct
.
c_ulonglong
),
(
"pid"
,
ct
.
c_uint
),
(
"pid"
,
ct
.
c_uint
),
(
"ports"
,
ct
.
c_uint
),
(
"ports"
,
ct
.
c_uint
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment