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
19e33729
Commit
19e33729
authored
Mar 22, 2018
by
yonghong-song
Committed by
GitHub
Mar 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1645 from qmonnet/sockmap
sync bpf compat headers with latest net-next
parents
ad99e0ee
ef9d02b5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
207 additions
and
103 deletions
+207
-103
src/cc/compat/linux/bpf.h
src/cc/compat/linux/bpf.h
+97
-52
src/cc/compat/linux/virtual_bpf.h
src/cc/compat/linux/virtual_bpf.h
+97
-50
src/cc/export/helpers.h
src/cc/export/helpers.h
+9
-1
src/cc/libbpf.c
src/cc/libbpf.c
+4
-0
No files found.
src/cc/compat/linux/bpf.h
View file @
19e33729
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -132,6 +133,7 @@ enum bpf_prog_type {
...
@@ -132,6 +133,7 @@ enum bpf_prog_type {
BPF_PROG_TYPE_SOCK_OPS
,
BPF_PROG_TYPE_SOCK_OPS
,
BPF_PROG_TYPE_SK_SKB
,
BPF_PROG_TYPE_SK_SKB
,
BPF_PROG_TYPE_CGROUP_DEVICE
,
BPF_PROG_TYPE_CGROUP_DEVICE
,
BPF_PROG_TYPE_SK_MSG
,
};
};
enum
bpf_attach_type
{
enum
bpf_attach_type
{
...
@@ -142,6 +144,7 @@ enum bpf_attach_type {
...
@@ -142,6 +144,7 @@ enum bpf_attach_type {
BPF_SK_SKB_STREAM_PARSER
,
BPF_SK_SKB_STREAM_PARSER
,
BPF_SK_SKB_STREAM_VERDICT
,
BPF_SK_SKB_STREAM_VERDICT
,
BPF_CGROUP_DEVICE
,
BPF_CGROUP_DEVICE
,
BPF_SK_MSG_VERDICT
,
__MAX_BPF_ATTACH_TYPE
__MAX_BPF_ATTACH_TYPE
};
};
...
@@ -230,6 +233,28 @@ enum bpf_attach_type {
...
@@ -230,6 +233,28 @@ enum bpf_attach_type {
#define BPF_F_RDONLY (1U << 3)
#define BPF_F_RDONLY (1U << 3)
#define BPF_F_WRONLY (1U << 4)
#define BPF_F_WRONLY (1U << 4)
/* Flag for stack_map, store build_id+offset instead of pointer */
#define BPF_F_STACK_BUILD_ID (1U << 5)
enum
bpf_stack_build_id_status
{
/* user space need an empty entry to identify end of a trace */
BPF_STACK_BUILD_ID_EMPTY
=
0
,
/* with valid build_id and offset */
BPF_STACK_BUILD_ID_VALID
=
1
,
/* couldn't get build_id, fallback to ip */
BPF_STACK_BUILD_ID_IP
=
2
,
};
#define BPF_BUILD_ID_SIZE 20
struct
bpf_stack_build_id
{
__s32
status
;
unsigned
char
build_id
[
BPF_BUILD_ID_SIZE
];
union
{
__u64
offset
;
__u64
ip
;
};
};
union
bpf_attr
{
union
bpf_attr
{
struct
{
/* anonymous struct used by BPF_MAP_CREATE command */
struct
{
/* anonymous struct used by BPF_MAP_CREATE command */
__u32
map_type
;
/* one of enum bpf_map_type */
__u32
map_type
;
/* one of enum bpf_map_type */
...
@@ -332,7 +357,7 @@ union bpf_attr {
...
@@ -332,7 +357,7 @@ union bpf_attr {
* int bpf_map_delete_elem(&map, &key)
* int bpf_map_delete_elem(&map, &key)
* Return: 0 on success or negative error
* Return: 0 on success or negative error
*
*
* int bpf_probe_read(void *dst, int size,
const
void *src)
* int bpf_probe_read(void *dst, int size, void *src)
* Return: 0 on success or negative error
* Return: 0 on success or negative error
*
*
* u64 bpf_ktime_get_ns(void)
* u64 bpf_ktime_get_ns(void)
...
@@ -440,7 +465,6 @@ union bpf_attr {
...
@@ -440,7 +465,6 @@ union bpf_attr {
* all bits - reserved
* all bits - reserved
* Return: cls_bpf: TC_ACT_REDIRECT on success or TC_ACT_SHOT on error
* Return: cls_bpf: TC_ACT_REDIRECT on success or TC_ACT_SHOT on error
* xdp_bfp: XDP_REDIRECT on success or XDP_ABORT on error
* xdp_bfp: XDP_REDIRECT on success or XDP_ABORT on error
*
* int bpf_redirect_map(map, key, flags)
* int bpf_redirect_map(map, key, flags)
* redirect to endpoint in map
* redirect to endpoint in map
* @map: pointer to dev map
* @map: pointer to dev map
...
@@ -696,6 +720,15 @@ union bpf_attr {
...
@@ -696,6 +720,15 @@ union bpf_attr {
* int bpf_override_return(pt_regs, rc)
* int bpf_override_return(pt_regs, rc)
* @pt_regs: pointer to struct pt_regs
* @pt_regs: pointer to struct pt_regs
* @rc: the return value to set
* @rc: the return value to set
*
* int bpf_msg_redirect_map(map, key, flags)
* Redirect msg to a sock in map using key as a lookup key for the
* sock in map.
* @map: pointer to sockmap
* @key: key to lookup sock in map
* @flags: reserved for future use
* Return: SK_PASS
*
*/
*/
#define __BPF_FUNC_MAPPER(FN) \
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
FN(unspec), \
...
@@ -757,7 +790,11 @@ union bpf_attr {
...
@@ -757,7 +790,11 @@ union bpf_attr {
FN(perf_prog_read_value), \
FN(perf_prog_read_value), \
FN(getsockopt), \
FN(getsockopt), \
FN(override_return), \
FN(override_return), \
FN(sock_ops_cb_flags_set),
FN(sock_ops_cb_flags_set), \
FN(msg_redirect_map), \
FN(msg_apply_bytes), \
FN(msg_cork_bytes), \
FN(msg_pull_data),
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
* function eBPF program intends to call
* function eBPF program intends to call
...
@@ -800,8 +837,9 @@ enum bpf_func_id {
...
@@ -800,8 +837,9 @@ enum bpf_func_id {
/* BPF_FUNC_skb_set_tunnel_key flags. */
/* BPF_FUNC_skb_set_tunnel_key flags. */
#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
#define BPF_F_DONT_FRAGMENT (1ULL << 2)
#define BPF_F_DONT_FRAGMENT (1ULL << 2)
#define BPF_F_SEQ_NUMBER (1ULL << 3)
/* BPF_FUNC_perf_event_output
and
BPF_FUNC_perf_event_read and
/* BPF_FUNC_perf_event_output
,
BPF_FUNC_perf_event_read and
* BPF_FUNC_perf_event_read_value flags.
* BPF_FUNC_perf_event_read_value flags.
*/
*/
#define BPF_F_INDEX_MASK 0xffffffffULL
#define BPF_F_INDEX_MASK 0xffffffffULL
...
@@ -919,6 +957,14 @@ enum sk_action {
...
@@ -919,6 +957,14 @@ enum sk_action {
SK_PASS
,
SK_PASS
,
};
};
/* user accessible metadata for SK_MSG packet hook, new fields must
* be added to the end of this structure
*/
struct
sk_msg_md
{
void
*
data
;
void
*
data_end
;
};
#define BPF_TAG_SIZE 8
#define BPF_TAG_SIZE 8
struct
bpf_prog_info
{
struct
bpf_prog_info
{
...
@@ -1083,7 +1129,6 @@ enum {
...
@@ -1083,7 +1129,6 @@ enum {
BPF_TCP_MAX_STATES
/* Leave at the end! */
BPF_TCP_MAX_STATES
/* Leave at the end! */
};
};
#define TCP_BPF_IW 1001
/* Set TCP initial congestion window */
#define TCP_BPF_IW 1001
/* Set TCP initial congestion window */
#define TCP_BPF_SNDCWND_CLAMP 1002
/* Set sndcwnd_clamp */
#define TCP_BPF_SNDCWND_CLAMP 1002
/* Set sndcwnd_clamp */
...
...
src/cc/compat/linux/virtual_bpf.h
View file @
19e33729
R
"********(
R
"********(
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -133,6 +134,7 @@ enum bpf_prog_type {
...
@@ -133,6 +134,7 @@ enum bpf_prog_type {
BPF_PROG_TYPE_SOCK_OPS,
BPF_PROG_TYPE_SOCK_OPS,
BPF_PROG_TYPE_SK_SKB,
BPF_PROG_TYPE_SK_SKB,
BPF_PROG_TYPE_CGROUP_DEVICE,
BPF_PROG_TYPE_CGROUP_DEVICE,
BPF_PROG_TYPE_SK_MSG,
};
};
enum bpf_attach_type {
enum bpf_attach_type {
...
@@ -143,6 +145,7 @@ enum bpf_attach_type {
...
@@ -143,6 +145,7 @@ enum bpf_attach_type {
BPF_SK_SKB_STREAM_PARSER,
BPF_SK_SKB_STREAM_PARSER,
BPF_SK_SKB_STREAM_VERDICT,
BPF_SK_SKB_STREAM_VERDICT,
BPF_CGROUP_DEVICE,
BPF_CGROUP_DEVICE,
BPF_SK_MSG_VERDICT,
__MAX_BPF_ATTACH_TYPE
__MAX_BPF_ATTACH_TYPE
};
};
...
@@ -210,6 +213,7 @@ enum bpf_attach_type {
...
@@ -210,6 +213,7 @@ enum bpf_attach_type {
#define BPF_NOEXIST 1 /* create new element if it didn't exist */
#define BPF_NOEXIST 1 /* create new element if it didn't exist */
#define BPF_EXIST 2 /* update existing element */
#define BPF_EXIST 2 /* update existing element */
/* flags for BPF_MAP_CREATE command */
#define BPF_F_NO_PREALLOC (1U << 0)
#define BPF_F_NO_PREALLOC (1U << 0)
/* Instead of having one common LRU list in the
/* Instead of having one common LRU list in the
* BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list
* BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list
...
@@ -230,6 +234,28 @@ enum bpf_attach_type {
...
@@ -230,6 +234,28 @@ enum bpf_attach_type {
#define BPF_F_RDONLY (1U << 3)
#define BPF_F_RDONLY (1U << 3)
#define BPF_F_WRONLY (1U << 4)
#define BPF_F_WRONLY (1U << 4)
/* Flag for stack_map, store build_id+offset instead of pointer */
#define BPF_F_STACK_BUILD_ID (1U << 5)
enum bpf_stack_build_id_status {
/* user space need an empty entry to identify end of a trace */
BPF_STACK_BUILD_ID_EMPTY = 0,
/* with valid build_id and offset */
BPF_STACK_BUILD_ID_VALID = 1,
/* couldn't get build_id, fallback to ip */
BPF_STACK_BUILD_ID_IP = 2,
};
#define BPF_BUILD_ID_SIZE 20
struct bpf_stack_build_id {
__s32 status;
unsigned char build_id[BPF_BUILD_ID_SIZE];
union {
__u64 offset;
__u64 ip;
};
};
union bpf_attr {
union bpf_attr {
struct { /* anonymous struct used by BPF_MAP_CREATE command */
struct { /* anonymous struct used by BPF_MAP_CREATE command */
__u32 map_type; /* one of enum bpf_map_type */
__u32 map_type; /* one of enum bpf_map_type */
...
@@ -332,7 +358,7 @@ union bpf_attr {
...
@@ -332,7 +358,7 @@ union bpf_attr {
* int bpf_map_delete_elem(&map, &key)
* int bpf_map_delete_elem(&map, &key)
* Return: 0 on success or negative error
* Return: 0 on success or negative error
*
*
* int bpf_probe_read(void *dst, int size,
const
void *src)
* int bpf_probe_read(void *dst, int size, void *src)
* Return: 0 on success or negative error
* Return: 0 on success or negative error
*
*
* u64 bpf_ktime_get_ns(void)
* u64 bpf_ktime_get_ns(void)
...
@@ -628,7 +654,7 @@ union bpf_attr {
...
@@ -628,7 +654,7 @@ union bpf_attr {
* @level: SOL_SOCKET or IPPROTO_TCP
* @level: SOL_SOCKET or IPPROTO_TCP
* @optname: option name
* @optname: option name
* @optval: pointer to option value
* @optval: pointer to option value
* @optlen: length of optval in byes
* @optlen: length of optval in by
t
es
* Return: 0 or negative error
* Return: 0 or negative error
*
*
* int bpf_getsockopt(bpf_socket, level, optname, optval, optlen)
* int bpf_getsockopt(bpf_socket, level, optname, optval, optlen)
...
@@ -695,6 +721,15 @@ union bpf_attr {
...
@@ -695,6 +721,15 @@ union bpf_attr {
* int bpf_override_return(pt_regs, rc)
* int bpf_override_return(pt_regs, rc)
* @pt_regs: pointer to struct pt_regs
* @pt_regs: pointer to struct pt_regs
* @rc: the return value to set
* @rc: the return value to set
*
* int bpf_msg_redirect_map(map, key, flags)
* Redirect msg to a sock in map using key as a lookup key for the
* sock in map.
* @map: pointer to sockmap
* @key: key to lookup sock in map
* @flags: reserved for future use
* Return: SK_PASS
*
*/
*/
#define __BPF_FUNC_MAPPER(FN) \
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
FN(unspec), \
...
@@ -756,7 +791,11 @@ union bpf_attr {
...
@@ -756,7 +791,11 @@ union bpf_attr {
FN(perf_prog_read_value), \
FN(perf_prog_read_value), \
FN(getsockopt), \
FN(getsockopt), \
FN(override_return), \
FN(override_return), \
FN(sock_ops_cb_flags_set),
FN(sock_ops_cb_flags_set), \
FN(msg_redirect_map), \
FN(msg_apply_bytes), \
FN(msg_cork_bytes), \
FN(msg_pull_data),
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
* function eBPF program intends to call
* function eBPF program intends to call
...
@@ -799,8 +838,9 @@ enum bpf_func_id {
...
@@ -799,8 +838,9 @@ enum bpf_func_id {
/* BPF_FUNC_skb_set_tunnel_key flags. */
/* BPF_FUNC_skb_set_tunnel_key flags. */
#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
#define BPF_F_DONT_FRAGMENT (1ULL << 2)
#define BPF_F_DONT_FRAGMENT (1ULL << 2)
#define BPF_F_SEQ_NUMBER (1ULL << 3)
/* BPF_FUNC_perf_event_output
and
BPF_FUNC_perf_event_read and
/* BPF_FUNC_perf_event_output
,
BPF_FUNC_perf_event_read and
* BPF_FUNC_perf_event_read_value flags.
* BPF_FUNC_perf_event_read_value flags.
*/
*/
#define BPF_F_INDEX_MASK 0xffffffffULL
#define BPF_F_INDEX_MASK 0xffffffffULL
...
@@ -918,6 +958,14 @@ enum sk_action {
...
@@ -918,6 +958,14 @@ enum sk_action {
SK_PASS,
SK_PASS,
};
};
/* user accessible metadata for SK_MSG packet hook, new fields must
* be added to the end of this structure
*/
struct sk_msg_md {
void *data;
void *data_end;
};
#define BPF_TAG_SIZE 8
#define BPF_TAG_SIZE 8
struct bpf_prog_info {
struct bpf_prog_info {
...
@@ -1105,6 +1153,5 @@ struct bpf_cgroup_dev_ctx {
...
@@ -1105,6 +1153,5 @@ struct bpf_cgroup_dev_ctx {
__u32 minor;
__u32 minor;
};
};
#endif /* _UAPI__LINUX_BPF_H__ */
#endif /* _UAPI__LINUX_BPF_H__ */
)********"
)********"
src/cc/export/helpers.h
View file @
19e33729
...
@@ -329,7 +329,15 @@ static int (*bpf_xdp_adjust_head)(void *ctx, int offset) =
...
@@ -329,7 +329,15 @@ static int (*bpf_xdp_adjust_head)(void *ctx, int offset) =
static int (*bpf_override_return)(void *pt_regs, unsigned long rc) =
static int (*bpf_override_return)(void *pt_regs, unsigned long rc) =
(void *) BPF_FUNC_override_return;
(void *) BPF_FUNC_override_return;
static int (*bpf_sock_ops_cb_flags_set)(void *skops, int flags) =
static int (*bpf_sock_ops_cb_flags_set)(void *skops, int flags) =
(void *)BPF_FUNC_sock_ops_cb_flags_set;
(void *) BPF_FUNC_sock_ops_cb_flags_set;
static int (*bpf_msg_redirect_map)(void *msg, void *map, u32 key, u64 flags) =
(void *) BPF_FUNC_msg_redirect_map;
static int (*bpf_msg_apply_bytes)(void *msg, u32 bytes) =
(void *) BPF_FUNC_msg_apply_bytes;
static int (*bpf_msg_cork_bytes)(void *msg, u32 bytes) =
(void *) BPF_FUNC_msg_cork_bytes;
static int (*bpf_msg_pull_data)(void *msg, u32 start, u32 end, u64 flags) =
(void *) BPF_FUNC_msg_pull_data;
/* llvm builtin functions that eBPF C program may use to
/* llvm builtin functions that eBPF C program may use to
* emit BPF_LD_ABS and BPF_LD_IND instructions
* emit BPF_LD_ABS and BPF_LD_IND instructions
...
...
src/cc/libbpf.c
View file @
19e33729
...
@@ -149,6 +149,10 @@ static struct bpf_helper helpers[] = {
...
@@ -149,6 +149,10 @@ static struct bpf_helper helpers[] = {
{
"getsockopt"
,
"4.15"
},
{
"getsockopt"
,
"4.15"
},
{
"override_return"
,
"4.16"
},
{
"override_return"
,
"4.16"
},
{
"sock_ops_cb_flags_set"
,
"4.16"
},
{
"sock_ops_cb_flags_set"
,
"4.16"
},
{
"msg_redirect_map"
,
"4.16"
},
{
"msg_apply_bytes"
,
"4.16"
},
{
"msg_cork_bytes"
,
"4.16"
},
{
"msg_pull_data"
,
"4.16"
},
};
};
static
uint64_t
ptr_to_u64
(
void
*
ptr
)
static
uint64_t
ptr_to_u64
(
void
*
ptr
)
...
...
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