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
b13771a0
Commit
b13771a0
authored
Jul 30, 2015
by
4ast
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #96 from iovisor/bblanco_dev
Add option for custom log string to bpf_prog_load
parents
99e9f29f
759029fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
src/cc/libbpf.c
src/cc/libbpf.c
+8
-5
src/libbpf.h
src/libbpf.h
+3
-2
src/python/bpf/__init__.py
src/python/bpf/__init__.py
+3
-2
No files found.
src/cc/libbpf.c
View file @
b13771a0
...
...
@@ -119,23 +119,26 @@ char bpf_log_buf[LOG_BUF_SIZE];
int
bpf_prog_load
(
enum
bpf_prog_type
prog_type
,
const
struct
bpf_insn
*
insns
,
int
prog_len
,
const
char
*
license
,
unsigned
kern_version
)
const
char
*
license
,
unsigned
kern_version
,
char
*
log_buf
,
unsigned
log_buf_size
)
{
log_buf
=
log_buf
?
log_buf
:
bpf_log_buf
;
log_buf_size
=
log_buf_size
?
log_buf_size
:
LOG_BUF_SIZE
;
union
bpf_attr
attr
=
{
.
prog_type
=
prog_type
,
.
insns
=
ptr_to_u64
((
void
*
)
insns
),
.
insn_cnt
=
prog_len
/
sizeof
(
struct
bpf_insn
),
.
license
=
ptr_to_u64
((
void
*
)
license
),
.
log_buf
=
ptr_to_u64
(
bpf_
log_buf
),
.
log_size
=
LOG_BUF_SIZE
,
.
log_buf
=
ptr_to_u64
(
log_buf
),
.
log_size
=
log_buf_size
,
.
log_level
=
1
,
};
attr
.
kern_version
=
kern_version
;
bpf_
log_buf
[
0
]
=
0
;
log_buf
[
0
]
=
0
;
int
ret
=
syscall
(
__NR_bpf
,
BPF_PROG_LOAD
,
&
attr
,
sizeof
(
attr
));
if
(
ret
<
0
)
{
if
(
ret
<
0
&&
log_buf
==
bpf_log_buf
)
{
fprintf
(
stderr
,
"bpf: %s
\n
%s
\n
"
,
strerror
(
errno
),
bpf_log_buf
);
}
return
ret
;
...
...
src/libbpf.h
View file @
b13771a0
...
...
@@ -37,13 +37,14 @@ int bpf_get_next_key(int fd, void *key, void *next_key);
int
bpf_prog_load
(
enum
bpf_prog_type
prog_type
,
const
struct
bpf_insn
*
insns
,
int
insn_len
,
const
char
*
license
,
unsigned
kern_version
);
const
char
*
license
,
unsigned
kern_version
,
char
*
log_buf
,
unsigned
log_buf_size
);
int
bpf_attach_socket
(
int
sockfd
,
int
progfd
);
/* create RAW socket and bind to interface 'name' */
int
bpf_open_raw_sock
(
const
char
*
name
);
int
bpf_attach_kprobe
(
int
progfd
,
const
char
*
event
,
const
char
*
event_desc
,
pid_
t
pid
,
int
cpu
,
int
group_fd
);
int
bpf_attach_kprobe
(
int
progfd
,
const
char
*
event
,
const
char
*
event_desc
,
in
t
pid
,
int
cpu
,
int
group_fd
);
int
bpf_detach_kprobe
(
const
char
*
event_desc
);
#define LOG_BUF_SIZE 65536
...
...
src/python/bpf/__init__.py
View file @
b13771a0
...
...
@@ -60,7 +60,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_void_p
,
ct
.
c_size_t
,
ct
.
c_char_p
,
ct
.
c_uint
]
ct
.
c_char_p
,
ct
.
c_uint
,
ct
.
c_char_p
,
ct
.
c_uint
]
lib
.
bpf_attach_kprobe
.
restype
=
ct
.
c_int
lib
.
bpf_attach_kprobe
.
argtypes
=
[
ct
.
c_int
,
ct
.
c_char_p
,
ct
.
c_char_p
,
ct
.
c_int
,
ct
.
c_int
,
ct
.
c_int
]
lib
.
bpf_detach_kprobe
.
restype
=
ct
.
c_int
...
...
@@ -192,7 +192,8 @@ class BPF(object):
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
))
lib
.
bpf_module_kern_version
(
self
.
module
),
None
,
0
)
if
fd
<
0
:
print
((
ct
.
c_char
*
65536
).
in_dll
(
lib
,
"bpf_log_buf"
).
value
)
...
...
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