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
eea55286
Commit
eea55286
authored
Nov 03, 2017
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use bpf_prog_load_flag in APIs
parent
797669f4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
24 deletions
+17
-24
src/cc/api/BPF.cc
src/cc/api/BPF.cc
+2
-3
src/cc/api/BPF.h
src/cc/api/BPF.h
+3
-1
src/lua/bcc/bpf.lua
src/lua/bcc/bpf.lua
+2
-1
src/lua/bcc/libbcc.lua
src/lua/bcc/libbcc.lua
+2
-1
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+7
-17
src/python/bcc/libbcc.py
src/python/bcc/libbcc.py
+1
-1
No files found.
src/cc/api/BPF.cc
View file @
eea55286
...
...
@@ -483,9 +483,8 @@ StatusTuple BPF::load_func(const std::string& func_name,
fd
=
bpf_prog_load
(
type
,
func_name
.
c_str
(),
reinterpret_cast
<
struct
bpf_insn
*>
(
func_start
),
func_size
,
bpf_module_
->
license
(),
bpf_module_
->
kern_version
(),
nullptr
,
0
// BPFModule will handle error printing
);
bpf_module_
->
kern_version
(),
flag_
&
DEBUG_BPF
?
1
:
0
,
nullptr
,
0
);
if
(
fd
<
0
)
return
StatusTuple
(
-
1
,
"Failed to load %s: %d"
,
func_name
.
c_str
(),
fd
);
...
...
src/cc/api/BPF.h
View file @
eea55286
...
...
@@ -46,7 +46,7 @@ public:
static
const
int
BPF_MAX_STACK_DEPTH
=
127
;
explicit
BPF
(
unsigned
int
flag
=
0
,
TableStorage
*
ts
=
nullptr
)
:
bpf_module_
(
new
BPFModule
(
flag
,
ts
))
{}
:
flag_
(
flag
),
bpf_module_
(
new
BPFModule
(
flag
,
ts
))
{}
StatusTuple
init
(
const
std
::
string
&
bpf_program
,
const
std
::
vector
<
std
::
string
>&
cflags
=
{},
const
std
::
vector
<
USDT
>&
usdt
=
{});
...
...
@@ -185,6 +185,8 @@ private:
std
::
string
&
module_res
,
uint64_t
&
offset_res
);
int
flag_
;
std
::
unique_ptr
<
BPFModule
>
bpf_module_
;
std
::
map
<
std
::
string
,
int
>
funcs_
;
...
...
src/lua/bcc/bpf.lua
View file @
eea55286
...
...
@@ -160,7 +160,8 @@ function Bpf:load_func(fn_name, prog_type)
libbcc
.
bpf_function_start
(
self
.
module
,
fn_name
),
libbcc
.
bpf_function_size
(
self
.
module
,
fn_name
),
libbcc
.
bpf_module_license
(
self
.
module
),
libbcc
.
bpf_module_kern_version
(
self
.
module
),
nil
,
0
)
libbcc
.
bpf_module_kern_version
(
self
.
module
),
0
,
nil
,
0
)
assert
(
fd
>=
0
,
"failed to load BPF program "
..
fn_name
)
log
.
info
(
"loaded %s (%d)"
,
fn_name
,
fd
)
...
...
src/lua/bcc/libbcc.lua
View file @
eea55286
...
...
@@ -32,7 +32,8 @@ int bpf_get_next_key(int fd, void *key, void *next_key);
int bpf_prog_load(enum bpf_prog_type prog_type, const char *name,
const struct bpf_insn *insns, int insn_len,
const char *license, unsigned kern_version, char *log_buf, unsigned log_buf_size);
const char *license, unsigned kern_version,
int log_level, char *log_buf, unsigned log_buf_size);
int bpf_attach_socket(int sockfd, int progfd);
/* create RAW socket and bind to interface 'name' */
...
...
src/python/bcc/__init__.py
View file @
eea55286
...
...
@@ -320,23 +320,13 @@ class BPF(object):
return
self
.
funcs
[
func_name
]
if
not
lib
.
bpf_function_start
(
self
.
module
,
func_name
.
encode
(
"ascii"
)):
raise
Exception
(
"Unknown program %s"
%
func_name
)
buffer_len
=
LOG_BUFFER_SIZE
while
True
:
log_buf
=
ct
.
create_string_buffer
(
buffer_len
)
if
self
.
debug
else
None
fd
=
lib
.
bpf_prog_load
(
prog_type
,
func_name
.
encode
(
"ascii"
),
lib
.
bpf_function_start
(
self
.
module
,
func_name
.
encode
(
"ascii"
)),
lib
.
bpf_function_size
(
self
.
module
,
func_name
.
encode
(
"ascii"
)),
lib
.
bpf_module_license
(
self
.
module
),
lib
.
bpf_module_kern_version
(
self
.
module
),
log_buf
,
ct
.
sizeof
(
log_buf
)
if
log_buf
else
0
)
if
fd
<
0
and
ct
.
get_errno
()
==
errno
.
ENOSPC
and
self
.
debug
:
buffer_len
<<=
1
else
:
break
if
self
.
debug
&
DEBUG_BPF
and
log_buf
.
value
:
print
(
log_buf
.
value
.
decode
(),
file
=
sys
.
stderr
)
fd
=
lib
.
bpf_prog_load
(
prog_type
,
func_name
.
encode
(
"ascii"
),
lib
.
bpf_function_start
(
self
.
module
,
func_name
.
encode
(
"ascii"
)),
lib
.
bpf_function_size
(
self
.
module
,
func_name
.
encode
(
"ascii"
)),
lib
.
bpf_module_license
(
self
.
module
),
lib
.
bpf_module_kern_version
(
self
.
module
),
1
if
(
self
.
debug
&
DEBUG_BPF
)
else
0
,
None
,
0
);
if
fd
<
0
:
atexit
.
register
(
self
.
donothing
)
...
...
src/python/bcc/libbcc.py
View file @
eea55286
...
...
@@ -84,7 +84,7 @@ lib.bpf_attach_socket.restype = ct.c_int
lib
.
bpf_attach_socket
.
argtypes
=
[
ct
.
c_int
,
ct
.
c_int
]
lib
.
bpf_prog_load
.
restype
=
ct
.
c_int
lib
.
bpf_prog_load
.
argtypes
=
[
ct
.
c_int
,
ct
.
c_char_p
,
ct
.
c_void_p
,
ct
.
c_size_t
,
ct
.
c_char_p
,
ct
.
c_uint
,
ct
.
c_char_p
,
ct
.
c_uint
]
ct
.
c_size_t
,
ct
.
c_char_p
,
ct
.
c_uint
,
ct
.
c_
int
,
ct
.
c_
char_p
,
ct
.
c_uint
]
lib
.
bpf_attach_kprobe
.
restype
=
ct
.
c_void_p
_CB_TYPE
=
ct
.
CFUNCTYPE
(
None
,
ct
.
py_object
,
ct
.
c_int
,
ct
.
c_ulonglong
,
ct
.
POINTER
(
ct
.
c_ulonglong
))
...
...
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