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
7a3e5bc3
Commit
7a3e5bc3
authored
Mar 29, 2017
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new helper Macro across files
parent
f829177b
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
72 additions
and
73 deletions
+72
-73
examples/lua/task_switch.lua
examples/lua/task_switch.lua
+1
-1
examples/networking/distributed_bridge/tunnel.c
examples/networking/distributed_bridge/tunnel.c
+3
-3
examples/networking/distributed_bridge/tunnel_mesh.c
examples/networking/distributed_bridge/tunnel_mesh.c
+3
-3
examples/networking/dns_matching/dns_matching.c
examples/networking/dns_matching/dns_matching.c
+1
-1
examples/networking/http_filter/http-parse-complete.c
examples/networking/http_filter/http-parse-complete.c
+1
-1
examples/networking/neighbor_sharing/tc_neighbor_sharing.c
examples/networking/neighbor_sharing/tc_neighbor_sharing.c
+1
-1
examples/networking/tunnel_monitor/monitor.c
examples/networking/tunnel_monitor/monitor.c
+1
-1
examples/networking/vlan_learning/vlan_learning.c
examples/networking/vlan_learning/vlan_learning.c
+2
-2
examples/tracing/task_switch.py
examples/tracing/task_switch.py
+1
-1
examples/tracing/trace_perf_output.py
examples/tracing/trace_perf_output.py
+1
-1
tests/lua/test_clang.lua
tests/lua/test_clang.lua
+7
-7
tests/lua/test_uprobes.lua
tests/lua/test_uprobes.lua
+2
-2
tests/python/test_array.py
tests/python/test_array.py
+2
-2
tests/python/test_bpf_log.py
tests/python/test_bpf_log.py
+1
-1
tests/python/test_brb.c
tests/python/test_brb.c
+12
-12
tests/python/test_brb2.c
tests/python/test_brb2.c
+2
-2
tests/python/test_call1.c
tests/python/test_call1.c
+1
-1
tests/python/test_clang.py
tests/python/test_clang.py
+9
-9
tests/python/test_clang_complex.c
tests/python/test_clang_complex.c
+3
-3
tests/python/test_perf_event.py
tests/python/test_perf_event.py
+1
-1
tests/python/test_stat1.c
tests/python/test_stat1.c
+1
-1
tests/python/test_trace2.c
tests/python/test_trace2.c
+1
-1
tests/python/test_trace2.py
tests/python/test_trace2.py
+1
-1
tests/python/test_trace3.c
tests/python/test_trace3.c
+2
-2
tests/python/test_trace4.py
tests/python/test_trace4.py
+1
-1
tests/python/test_uprobes.py
tests/python/test_uprobes.py
+2
-2
tests/python/test_xlate1.c
tests/python/test_xlate1.c
+1
-1
tools/dcstat.py
tools/dcstat.py
+1
-1
tools/deadlock_detector.c
tools/deadlock_detector.c
+3
-4
tools/funccount.py
tools/funccount.py
+1
-1
tools/pidpersec.py
tools/pidpersec.py
+1
-1
tools/vfscount.py
tools/vfscount.py
+1
-1
tools/vfsstat.py
tools/vfsstat.py
+1
-1
No files found.
examples/lua/task_switch.lua
View file @
7a3e5bc3
...
...
@@ -24,7 +24,7 @@ struct key_t {
u32 curr_pid;
};
// map_type, key_type, leaf_type, table_name, num_entry
BPF_
TABLE("hash", struct key_t, u64, stats
, 1024);
BPF_
HASH(stats, struct key_t, u64
, 1024);
int count_sched(struct pt_regs *ctx, struct task_struct *prev) {
struct key_t key = {};
u64 zero = 0, *val;
...
...
examples/networking/distributed_bridge/tunnel.c
View file @
7a3e5bc3
...
...
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0 (the "License")
#include <bcc/proto.h>
BPF_
TABLE
(
"hash"
,
u32
,
int
,
vni2if
,
1024
);
BPF_
HASH
(
vni2if
,
u32
,
int
,
1024
);
struct
vni_key
{
u64
mac
;
...
...
@@ -15,12 +15,12 @@ struct host {
u64
rx_pkts
;
u64
tx_pkts
;
};
BPF_
TABLE
(
"hash"
,
struct
vni_key
,
struct
host
,
mac2host
,
10240
);
BPF_
HASH
(
mac2host
,
struct
vni_key
,
struct
host
);
struct
config
{
int
tunnel_ifindex
;
};
BPF_
TABLE
(
"hash"
,
int
,
struct
config
,
conf
,
1
);
BPF_
HASH
(
conf
,
int
,
struct
config
,
1
);
// Handle packets from the encap device, demux into the dest tenant
int
handle_ingress
(
struct
__sk_buff
*
skb
)
{
...
...
examples/networking/distributed_bridge/tunnel_mesh.c
View file @
7a3e5bc3
...
...
@@ -5,15 +5,15 @@
struct
config
{
int
tunnel_ifindex
;
};
BPF_
TABLE
(
"hash"
,
int
,
struct
config
,
conf
,
1
);
BPF_
HASH
(
conf
,
int
,
struct
config
,
1
);
struct
tunnel_key
{
u32
tunnel_id
;
u32
remote_ipv4
;
};
BPF_
TABLE
(
"hash"
,
struct
tunnel_key
,
int
,
tunkey2if
,
1024
);
BPF_
HASH
(
tunkey2if
,
struct
tunnel_key
,
int
,
1024
);
BPF_
TABLE
(
"hash"
,
int
,
struct
tunnel_key
,
if2tun
key
,
1024
);
BPF_
HASH
(
if2tunkey
,
int
,
struct
tunnel_
key
,
1024
);
// Handle packets from the encap device, demux into the dest tenant
int
handle_ingress
(
struct
__sk_buff
*
skb
)
{
...
...
examples/networking/dns_matching/dns_matching.c
View file @
7a3e5bc3
...
...
@@ -51,7 +51,7 @@ struct Leaf {
unsigned
char
p
[
4
];
};
BPF_
TABLE
(
"hash"
,
struct
Key
,
struct
Leaf
,
cache
,
128
);
BPF_
HASH
(
cache
,
struct
Key
,
struct
Leaf
,
128
);
int
dns_matching
(
struct
__sk_buff
*
skb
)
{
...
...
examples/networking/http_filter/http-parse-complete.c
View file @
7a3e5bc3
...
...
@@ -19,7 +19,7 @@ struct Leaf {
//BPF_TABLE(map_type, key_type, leaf_type, table_name, num_entry)
//map <Key, Leaf>
//tracing sessions having same Key(dst_ip, src_ip, dst_port,src_port)
BPF_
TABLE
(
"hash"
,
struct
Key
,
struct
Leaf
,
sessions
,
1024
);
BPF_
HASH
(
sessions
,
struct
Key
,
struct
Leaf
,
1024
);
/*eBPF program.
Filter IP and TCP packets, having payload not empty
...
...
examples/networking/neighbor_sharing/tc_neighbor_sharing.c
View file @
7a3e5bc3
...
...
@@ -7,7 +7,7 @@ struct ipkey {
u32
client_ip
;
};
BPF_
TABLE
(
"hash"
,
struct
ipkey
,
int
,
learned_ips
,
1024
);
BPF_
HASH
(
learned_ips
,
struct
ipkey
,
int
,
1024
);
// trivial action
int
pass
(
struct
__sk_buff
*
skb
)
{
...
...
examples/networking/tunnel_monitor/monitor.c
View file @
7a3e5bc3
...
...
@@ -16,7 +16,7 @@ struct counters {
u64
rx_bytes
;
};
BPF_
TABLE
(
"hash"
,
struct
ipkey
,
struct
counters
,
stat
s
,
1024
);
BPF_
HASH
(
stats
,
struct
ipkey
,
struct
counter
s
,
1024
);
BPF_TABLE
(
"prog"
,
int
,
int
,
parser
,
10
);
enum
cb_index
{
...
...
examples/networking/vlan_learning/vlan_learning.c
View file @
7a3e5bc3
...
...
@@ -12,10 +12,10 @@ struct ifindex_leaf_t {
};
// redirect based on mac -> out_ifindex (auto-learning)
BPF_
TABLE
(
"hash"
,
int
,
struct
ifindex_leaf_t
,
egress
,
4096
);
BPF_
HASH
(
egress
,
int
,
struct
ifindex_leaf_t
,
4096
);
// redirect based on mac -> out_ifindex (config-driven)
BPF_
TABLE
(
"hash"
,
u64
,
struct
ifindex_leaf_t
,
ingress
,
4096
);
BPF_
HASH
(
ingress
,
struct
ifindex_leaf_t
,
4096
);
int
handle_phys2virt
(
struct
__sk_buff
*
skb
)
{
// only handle vlan packets
...
...
examples/tracing/task_switch.py
View file @
7a3e5bc3
...
...
@@ -14,7 +14,7 @@ struct key_t {
u32 curr_pid;
};
// map_type, key_type, leaf_type, table_name, num_entry
BPF_
TABLE("hash", struct key_t, u64, stats
, 1024);
BPF_
HASH(stats, struct key_t, u64
, 1024);
int count_sched(struct pt_regs *ctx, struct task_struct *prev) {
struct key_t key = {};
u64 zero = 0, *val;
...
...
examples/tracing/trace_perf_output.py
View file @
7a3e5bc3
...
...
@@ -24,7 +24,7 @@ def cb(cpu, data, size):
prog
=
"""
BPF_PERF_OUTPUT(events);
BPF_
TABLE("array", int, u64, counters
, 10);
BPF_
ARRAY(counters, u64
, 10);
int kprobe__sys_clone(void *ctx) {
struct {
u64 ts;
...
...
tests/lua/test_clang.lua
View file @
7a3e5bc3
...
...
@@ -51,7 +51,7 @@ end
function
TestClang
:
test_sscanf
()
local
text
=
[[
BPF_
TABLE("hash", int, struct { u64 a; u64 b; u32 c:18; u32 d:14; struct { u32 a; u32 b; } s; }, stats
, 10);
BPF_
HASH(stats, int, struct { u64 a; u64 b; u32 c:18; u32 d:14; struct { u32 a; u32 b; } s; }
, 10);
int foo(void *ctx) {
return 0;
...
...
@@ -76,7 +76,7 @@ int foo(void *ctx) {
end
function
TestClang
:
test_sscanf_array
()
local
text
=
[[ BPF_
TABLE("hash", int, struct { u32 a[3]; u32 b; }, stats
, 10); ]]
local
text
=
[[ BPF_
HASH(stats, int, struct { u32 a[3]; u32 b; }
, 10); ]]
local
b
=
BPF
:
new
{
text
=
text
,
debug
=
0
}
local
t
=
b
:
get_table
(
"stats"
)
...
...
@@ -103,7 +103,7 @@ struct key_t {
struct request *req;
};
BPF_
TABLE("hash", struct key_t, u64, start
, 1024);
BPF_
HASH(start, struct key_t, u64
, 1024);
int do_request(struct pt_regs *ctx, struct request *req) {
struct key_t key = {};
...
...
@@ -236,7 +236,7 @@ struct key_t {
u32 prev_pid;
u32 curr_pid;
};
BPF_
TABLE("hash", struct key_t, u64, stats
, 1024);
BPF_
HASH(stats, struct key_t, u64
, 1024);
int kprobe__finish_task_switch(struct pt_regs *ctx, struct task_struct *prev) {
struct key_t key = {};
u64 zero = 0, *val;
...
...
@@ -296,9 +296,9 @@ union emptyu {
struct empty em3;
struct empty em4;
};
BPF_
TABLE("array", int, struct list, t1
, 1);
BPF_
TABLE("array", int, struct list *, t2
, 1);
BPF_
TABLE("array", int, union emptyu, t3
, 1);
BPF_
ARRAY(t1, struct list
, 1);
BPF_
ARRAY(t2, struct list *
, 1);
BPF_
ARRAY(t3, union emptyu
, 1);
]]
local
b
=
BPF
:
new
{
text
=
text
}
local
ffi
=
require
(
"ffi"
)
...
...
tests/lua/test_uprobes.lua
View file @
7a3e5bc3
...
...
@@ -10,7 +10,7 @@ ffi.cdef[[
function
TestUprobes
:
test_simple_library
()
local
text
=
[[
#include <uapi/linux/ptrace.h>
BPF_
TABLE("array", int, u64, stats
, 1);
BPF_
ARRAY(stats, u64
, 1);
static void incr(int idx) {
u64 *ptr = stats.lookup(&idx);
if (ptr)
...
...
@@ -41,7 +41,7 @@ end
function
TestUprobes
:
test_simple_binary
()
local
text
=
[[
#include <uapi/linux/ptrace.h>
BPF_
TABLE("array", int, u64, stats
, 1);
BPF_
ARRAY(stats, u64
, 1);
static void incr(int idx) {
u64 *ptr = stats.lookup(&idx);
if (ptr)
...
...
tests/python/test_array.py
View file @
7a3e5bc3
...
...
@@ -12,7 +12,7 @@ from unittest import main, TestCase
class
TestArray
(
TestCase
):
def
test_simple
(
self
):
b
=
BPF
(
text
=
"""BPF_
TABLE("array", int, u64, table1
, 128);"""
)
b
=
BPF
(
text
=
"""BPF_
ARRAY(table1, u64
, 128);"""
)
t1
=
b
[
"table1"
]
t1
[
ct
.
c_int
(
0
)]
=
ct
.
c_ulonglong
(
100
)
t1
[
ct
.
c_int
(
127
)]
=
ct
.
c_ulonglong
(
1000
)
...
...
@@ -24,7 +24,7 @@ class TestArray(TestCase):
self
.
assertEqual
(
len
(
t1
),
128
)
def
test_native_type
(
self
):
b
=
BPF
(
text
=
"""BPF_
TABLE("array", int, u64, table1
, 128);"""
)
b
=
BPF
(
text
=
"""BPF_
ARRAY(table1, u64
, 128);"""
)
t1
=
b
[
"table1"
]
t1
[
0
]
=
ct
.
c_ulonglong
(
100
)
t1
[
-
2
]
=
ct
.
c_ulonglong
(
37
)
...
...
tests/python/test_bpf_log.py
View file @
7a3e5bc3
...
...
@@ -15,7 +15,7 @@ error_msg = "R0 invalid mem access 'map_value_or_null'\n"
text
=
"""
#include <uapi/linux/ptrace.h>
#include <bcc/proto.h>
BPF_
TABLE("hash", int, int, t1
, 10);
BPF_
HASH(t1, int, int
, 10);
int sim_port(struct __sk_buff *skb) {
int x = 0, *y;
"""
...
...
tests/python/test_brb.c
View file @
7a3e5bc3
...
...
@@ -26,33 +26,33 @@ BPF_TABLE("prog", u32, u32, jump, 16);
// physical endpoint manager (pem) tables which connects to boeht bridge 1 and bridge 2
// <port_id, bpf_dest>
BPF_
TABLE
(
"array"
,
u32
,
bpf_dest_t
,
pem_des
t
,
256
);
BPF_
ARRAY
(
pem_dest
,
bpf_dest_
t
,
256
);
// <port_id, ifindex>
BPF_
TABLE
(
"array"
,
u32
,
u32
,
pem_port
,
256
);
BPF_
ARRAY
(
pem_port
,
u32
,
256
);
// <ifindex, port_id>
BPF_
TABLE
(
"hash"
,
u32
,
u32
,
pem_ifindex
,
256
);
BPF_
HASH
(
pem_ifindex
,
u32
,
u32
,
256
);
// <0, tx2vm_pkts>
BPF_
TABLE
(
"array"
,
u32
,
u32
,
pem_stats
,
1
);
BPF_
ARRAY
(
pem_stats
,
u32
,
1
);
// bridge 1 (br1) tables
// <port_id, bpf_dest>
BPF_
TABLE
(
"array"
,
u32
,
bpf_dest_t
,
br1_des
t
,
256
);
BPF_
ARRAY
(
br1_dest
,
bpf_dest_
t
,
256
);
// <eth_addr, port_id>
BPF_
TABLE
(
"hash"
,
eth_addr_t
,
u32
,
br1_mac
,
256
);
BPF_
HASH
(
br1_mac
,
eth_addr_t
,
u32
,
256
);
// <0, rtr_ifindex>
BPF_
TABLE
(
"array"
,
u32
,
u32
,
br1_rtr
,
1
);
BPF_
ARRAY
(
br1_rtr
,
u32
,
1
);
// <mac, ifindex>
BPF_
TABLE
(
"hash"
,
eth_addr_t
,
u32
,
br1_mac_ifindex
,
1
);
BPF_
HASH
(
br1_mac_ifindex
,
eth_addr_t
,
u32
,
1
);
// bridge 2 (br2) tables
// <port_id, bpf_dest>
BPF_
TABLE
(
"array"
,
u32
,
bpf_dest_t
,
br2_des
t
,
256
);
BPF_
ARRAY
(
br2_dest
,
bpf_dest_
t
,
256
);
// <eth_addr, port_id>
BPF_
TABLE
(
"hash"
,
eth_addr_t
,
u32
,
br2_mac
,
256
);
BPF_
HASH
(
br2_mac
,
eth_addr_t
,
u32
,
256
);
// <0, rtr_ifindex>
BPF_
TABLE
(
"array"
,
u32
,
u32
,
br2_rtr
,
1
);
BPF_
ARRAY
(
br2_rtr
,
u32
,
1
);
// <mac, ifindex>
BPF_
TABLE
(
"hash"
,
eth_addr_t
,
u32
,
br2_mac_ifindex
,
1
);
BPF_
HASH
(
br2_mac_ifindex
,
eth_addr_t
,
u32
,
1
);
int
pem
(
struct
__sk_buff
*
skb
)
{
bpf_metadata_t
meta
=
{};
...
...
tests/python/test_brb2.c
View file @
7a3e5bc3
...
...
@@ -4,9 +4,9 @@
// physical endpoint manager (pem) tables which connects VMs and bridges
// <ifindex_in, ifindex_out>
BPF_
TABLE
(
"hash"
,
u32
,
u32
,
pem_dest
,
256
);
BPF_
HASH
(
pem_dest
,
u32
,
u32
,
256
);
// <0, tx_pkts>
BPF_
TABLE
(
"array"
,
u32
,
u32
,
pem_stats
,
1
);
BPF_
ARRAY
(
pem_stats
,
u32
,
1
);
int
pem
(
struct
__sk_buff
*
skb
)
{
u32
ifindex_in
,
*
ifindex_p
;
...
...
tests/python/test_call1.c
View file @
7a3e5bc3
...
...
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0 (the "License")
BPF_TABLE
(
"prog"
,
int
,
int
,
jump
,
64
);
BPF_
TABLE
(
"array"
,
int
,
u64
,
stats
,
64
);
BPF_
ARRAY
(
stats
,
u64
,
64
);
enum
states
{
S_EOP
=
1
,
...
...
tests/python/test_clang.py
View file @
7a3e5bc3
...
...
@@ -86,7 +86,7 @@ int do_completion(struct pt_regs *ctx, struct request *req) {
def
test_sscanf
(
self
):
text
=
"""
BPF_
TABLE("hash", int, struct { u64 a; u64 b; u64 c:36; u64 d:28; struct { u32 a; u32 b; } s; }, stats
, 10);
BPF_
HASH(stats, int, struct { u64 a; u64 b; u64 c:36; u64 d:28; struct { u32 a; u32 b; } s; }
, 10);
int foo(void *ctx) {
return 0;
}
...
...
@@ -107,7 +107,7 @@ int foo(void *ctx) {
def
test_sscanf_array
(
self
):
text
=
"""
BPF_
TABLE("hash", int, struct { u32 a[3]; u32 b; }, stats
, 10);
BPF_
HASH(stats, int, struct { u32 a[3]; u32 b; }
, 10);
"""
b
=
BPF
(
text
=
text
,
debug
=
0
)
t
=
b
.
get_table
(
"stats"
)
...
...
@@ -130,7 +130,7 @@ struct key_t {
struct request *req;
};
BPF_
TABLE("hash", struct key_t, u64, start
, 1024);
BPF_
HASH(start, struct key_t, u64
, 1024);
int do_request(struct pt_regs *ctx, struct request *req) {
struct key_t key = {};
...
...
@@ -268,7 +268,7 @@ struct key_t {
u32 prev_pid;
u32 curr_pid;
};
BPF_
TABLE("hash", struct key_t, u64, stats
, 1024);
BPF_
HASH(stats, struct key_t, u64
, 1024);
int kprobe__finish_task_switch(struct pt_regs *ctx, struct task_struct *prev) {
struct key_t key = {};
u64 zero = 0, *val;
...
...
@@ -325,9 +325,9 @@ union emptyu {
struct empty em3;
struct empty em4;
};
BPF_
TABLE("array", int, struct list, t1
, 1);
BPF_
TABLE("array", int, struct list *, t2
, 1);
BPF_
TABLE("array", int, union emptyu, t3
, 1);
BPF_
ARRAY(t1, struct list
, 1);
BPF_
ARRAY(t2, struct list *
, 1);
BPF_
ARRAY(t3, union emptyu
, 1);
"""
b
=
BPF
(
text
=
text
)
import
ctypes
...
...
@@ -351,7 +351,7 @@ BPF_TABLE("array", int, union emptyu, t3, 1);
def
test_nested_union
(
self
):
text
=
"""
BPF_
TABLE("hash", struct bpf_tunnel_key, int, t1
, 1);
BPF_
HASH(t1, struct bpf_tunnel_key, int
, 1);
"""
b
=
BPF
(
text
=
text
)
t1
=
b
[
"t1"
]
...
...
@@ -389,7 +389,7 @@ int process(struct xdp_md *ctx) {
def
test_update_macro_arg
(
self
):
text
=
"""
BPF_
TABLE("array", u32, u32, act
, 32);
BPF_
ARRAY(act, u32
, 32);
#define JMP_IDX_PIPE (1U << 1)
...
...
tests/python/test_clang_complex.c
View file @
7a3e5bc3
...
...
@@ -10,7 +10,7 @@ struct FwdKey {
struct
FwdLeaf
{
u32
fwd_idx
:
32
;
};
BPF_
TABLE
(
"hash"
,
struct
FwdKey
,
struct
FwdLeaf
,
fwd_map
,
1
);
BPF_
HASH
(
fwd_map
,
struct
FwdKey
,
struct
FwdLeaf
,
1
);
// array
struct
ConfigKey
{
...
...
@@ -29,7 +29,7 @@ struct MacaddrKey {
struct
MacaddrLeaf
{
u64
mac
;
};
BPF_
TABLE
(
"hash"
,
struct
MacaddrKey
,
struct
MacaddrLeaf
,
macaddr_map
,
11
);
BPF_
HASH
(
macaddr_map
,
struct
MacaddrKey
,
struct
MacaddrLeaf
,
11
);
// hash
struct
SlaveKey
{
...
...
@@ -38,7 +38,7 @@ struct SlaveKey {
struct
SlaveLeaf
{
u32
slave_ifindex
;
};
BPF_
TABLE
(
"hash"
,
struct
SlaveKey
,
struct
SlaveLeaf
,
slave_map
,
10
);
BPF_
HASH
(
slave_map
,
struct
SlaveKey
,
struct
SlaveLeaf
,
10
);
int
handle_packet
(
struct
__sk_buff
*
skb
)
{
int
ret
=
0
;
...
...
tests/python/test_perf_event.py
View file @
7a3e5bc3
...
...
@@ -13,7 +13,7 @@ class TestPerfCounter(unittest.TestCase):
def
test_cycles
(
self
):
text
=
"""
BPF_PERF_ARRAY(cnt1, NUM_CPUS);
BPF_
TABLE("array", u32, u64, prev
, NUM_CPUS);
BPF_
ARRAY(prev, u64
, NUM_CPUS);
BPF_HISTOGRAM(dist);
int kprobe__sys_getuid(void *ctx) {
u32 cpu = bpf_get_smp_processor_id();
...
...
tests/python/test_stat1.c
View file @
7a3e5bc3
...
...
@@ -12,7 +12,7 @@ struct IPLeaf {
u64
tx_pkts
;
};
BPF_
TABLE
(
"hash"
,
struct
IPKey
,
struct
IPLeaf
,
stats
,
256
);
BPF_
HASH
(
stats
,
struct
IPKey
,
struct
IPLeaf
,
256
);
int
on_packet
(
struct
__sk_buff
*
skb
)
{
u8
*
cursor
=
0
;
...
...
tests/python/test_trace2.c
View file @
7a3e5bc3
...
...
@@ -3,7 +3,7 @@
#include <linux/ptrace.h>
struct
Ptr
{
u64
ptr
;
};
struct
Counters
{
u64
stat1
;
};
BPF_
TABLE
(
"hash"
,
struct
Ptr
,
struct
Counters
,
stat
s
,
1024
);
BPF_
HASH
(
stats
,
struct
Ptr
,
struct
Counter
s
,
1024
);
int
count_sched
(
struct
pt_regs
*
ctx
)
{
struct
Ptr
key
=
{.
ptr
=
PT_REGS_PARM1
(
ctx
)};
...
...
tests/python/test_trace2.py
View file @
7a3e5bc3
...
...
@@ -12,7 +12,7 @@ text = """
#include <linux/ptrace.h>
struct Ptr { u64 ptr; };
struct Counters { u64 stat1; };
BPF_
TABLE("hash", struct Ptr, struct Counters, stat
s, 1024);
BPF_
HASH(stats, struct Ptr, struct Counter
s, 1024);
int count_sched(struct pt_regs *ctx) {
struct Ptr key = {.ptr=PT_REGS_PARM1(ctx)};
...
...
tests/python/test_trace3.c
View file @
7a3e5bc3
...
...
@@ -4,9 +4,9 @@
#include <linux/blkdev.h>
struct
Request
{
u64
rq
;
};
struct
Time
{
u64
start
;
};
BPF_
TABLE
(
"hash"
,
struct
Request
,
struct
Time
,
requests
,
1024
);
BPF_
HASH
(
requests
,
struct
Request
,
struct
Time
,
1024
);
#define SLOTS 100
BPF_
TABLE
(
"array"
,
u32
,
u64
,
latency
,
SLOTS
);
BPF_
ARRAY
(
latency
,
u64
,
SLOTS
);
static
u32
log2
(
u32
v
)
{
u32
r
,
shift
;
...
...
tests/python/test_trace4.py
View file @
7a3e5bc3
...
...
@@ -12,7 +12,7 @@ class TestKprobeRgx(TestCase):
self
.
b
=
BPF
(
text
=
"""
typedef struct { int idx; } Key;
typedef struct { u64 val; } Val;
BPF_
TABLE("hash", Key, Val, stats
, 3);
BPF_
HASH(stats, Key, Val
, 3);
int hello(void *ctx) {
stats.lookup_or_init(&(Key){1}, &(Val){0})->val++;
return 0;
...
...
tests/python/test_uprobes.py
View file @
7a3e5bc3
...
...
@@ -11,7 +11,7 @@ class TestUprobes(unittest.TestCase):
def
test_simple_library
(
self
):
text
=
"""
#include <uapi/linux/ptrace.h>
BPF_
TABLE("array", int, u64, stats
, 1);
BPF_
ARRAY(stats, u64
, 1);
static void incr(int idx) {
u64 *ptr = stats.lookup(&idx);
if (ptr)
...
...
@@ -40,7 +40,7 @@ int count(struct pt_regs *ctx) {
def
test_simple_binary
(
self
):
text
=
"""
#include <uapi/linux/ptrace.h>
BPF_
TABLE("array", int, u64, stats
, 1);
BPF_
ARRAY(stats, u64
, 1);
static void incr(int idx) {
u64 *ptr = stats.lookup(&idx);
if (ptr)
...
...
tests/python/test_xlate1.c
View file @
7a3e5bc3
...
...
@@ -11,7 +11,7 @@ struct IPLeaf {
u64
ip_xlated_pkts
;
u64
arp_xlated_pkts
;
};
BPF_
TABLE
(
"hash"
,
struct
IPKey
,
struct
IPLeaf
,
xlate
,
1024
);
BPF_
HASH
(
xlate
,
struct
IPKey
,
struct
IPLeaf
,
1024
);
int
on_packet
(
struct
__sk_buff
*
skb
)
{
u8
*
cursor
=
0
;
...
...
tools/dcstat.py
View file @
7a3e5bc3
...
...
@@ -49,7 +49,7 @@ enum stats {
S_MAXSTAT
};
BPF_
TABLE("array", int, u64, stats
, S_MAXSTAT + 1);
BPF_
ARRAY(stats, u64
, S_MAXSTAT + 1);
/*
* How this is instrumented, and how to interpret the statistics, is very much
...
...
tools/deadlock_detector.c
View file @
7a3e5bc3
...
...
@@ -30,8 +30,7 @@ struct thread_to_held_mutex_leaf_t {
};
// Map of thread ID -> array of (mutex addresses, stack id)
BPF_TABLE
(
"hash"
,
u32
,
struct
thread_to_held_mutex_leaf_t
,
thread_to_held_mutexes
,
2097152
);
BPF_HASH
(
thread_to_held_mutexes
,
u32
,
struct
thread_to_held_mutex_leaf_t
,
2097152
);
// Key type for edges. Represents an edge from mutex1 => mutex2.
struct
edges_key_t
{
...
...
@@ -48,7 +47,7 @@ struct edges_leaf_t {
};
// Represents all edges currently in the mutex wait graph.
BPF_
TABLE
(
"hash"
,
struct
edges_key_t
,
struct
edges_leaf_t
,
edges
,
2097152
);
BPF_
HASH
(
edges
,
struct
edges_key_t
,
struct
edges_leaf_t
,
2097152
);
// Info about parent thread when a child thread is created.
struct
thread_created_leaf_t
{
...
...
@@ -58,7 +57,7 @@ struct thread_created_leaf_t {
};
// Map of child thread pid -> info about parent thread.
BPF_
TABLE
(
"hash"
,
u32
,
struct
thread_created_leaf_t
,
thread_to_parent
,
10240
);
BPF_
HASH
(
thread_to_parent
,
u32
,
struct
thread_created_leaf_t
);
// Stack traces when threads are created and when mutexes are locked/unlocked.
BPF_STACK_TRACE
(
stack_traces
,
655360
);
...
...
tools/funccount.py
View file @
7a3e5bc3
...
...
@@ -178,7 +178,7 @@ int PROBE_FUNCTION(void *ctx) {
"""
bpf_text
=
"""#include <uapi/linux/ptrace.h>
BPF_
TABLE("array", int, u64, counts
, NUMLOCATIONS);
BPF_
ARRAY(counts, u64
, NUMLOCATIONS);
"""
# We really mean the tgid from the kernel's perspective, which is in
...
...
tools/pidpersec.py
View file @
7a3e5bc3
...
...
@@ -26,7 +26,7 @@ enum stat_types {
S_MAXSTAT
};
BPF_
TABLE("array", int, u64, stats
, S_MAXSTAT + 1);
BPF_
ARRAY(stats, u64
, S_MAXSTAT + 1);
void stats_increment(int key) {
u64 *leaf = stats.lookup(&key);
...
...
tools/vfscount.py
View file @
7a3e5bc3
...
...
@@ -23,7 +23,7 @@ struct key_t {
u64 ip;
};
BPF_
TABLE("hash", struct key_t, u64, counts
, 256);
BPF_
HASH(counts, struct key_t, u64
, 256);
int do_count(struct pt_regs *ctx) {
struct key_t key = {};
...
...
tools/vfsstat.py
View file @
7a3e5bc3
...
...
@@ -49,7 +49,7 @@ enum stat_types {
S_MAXSTAT
};
BPF_
TABLE("array", int, u64, stats
, S_MAXSTAT + 1);
BPF_
ARRAY(stats, u64
, S_MAXSTAT + 1);
void stats_increment(int key) {
u64 *leaf = stats.lookup(&key);
...
...
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