diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2018-10-20 21:37:12 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-10-20 21:37:13 +0200 |
commit | 2576b96757e481fb40f097517763ccf75f935037 (patch) | |
tree | e355a84970cff01d0b2b1182d6cb58e063dbff26 /include | |
parent | 5032d079909d1ac5c2535acc32d5f01cd245d8ea (diff) | |
parent | 84fbfe026acaa6d91e2f71f1635992bf472e2496 (diff) | |
download | linux-2576b96757e481fb40f097517763ccf75f935037.tar.bz2 |
Merge branch 'bpf-msg-push-data'
John Fastabend says:
====================
This series adds a new helper bpf_msg_push_data to be used by
sk_msg programs. The helper can be used to insert extra bytes into
the message that can then be used by the program as metadata tags
among other things.
The first patch adds the helper, second patch the libbpf support,
and last patch updates test_sockmap to run msg_push_data tests.
v2: rebase after queue map and in filter.c convert int -> u32
====================
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/skmsg.h | 5 | ||||
-rw-r--r-- | include/uapi/linux/bpf.h | 20 |
2 files changed, 24 insertions, 1 deletions
diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h index 84e18863f6a4..2a11e9d91dfa 100644 --- a/include/linux/skmsg.h +++ b/include/linux/skmsg.h @@ -207,6 +207,11 @@ static inline struct scatterlist *sk_msg_elem(struct sk_msg *msg, int which) return &msg->sg.data[which]; } +static inline struct scatterlist sk_msg_elem_cpy(struct sk_msg *msg, int which) +{ + return msg->sg.data[which]; +} + static inline struct page *sk_msg_page(struct sk_msg *msg, int which) { return sg_page(sk_msg_elem(msg, which)); diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index a2fb333290dc..852dc17ab47a 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -2240,6 +2240,23 @@ union bpf_attr { * pointer that was returned from bpf_sk_lookup_xxx\ (). * Return * 0 on success, or a negative error in case of failure. + * + * int bpf_msg_push_data(struct sk_buff *skb, u32 start, u32 len, u64 flags) + * Description + * For socket policies, insert *len* bytes into msg at offset + * *start*. + * + * If a program of type **BPF_PROG_TYPE_SK_MSG** is run on a + * *msg* it may want to insert metadata or options into the msg. + * This can later be read and used by any of the lower layer BPF + * hooks. + * + * This helper may fail if under memory pressure (a malloc + * fails) in these cases BPF programs will get an appropriate + * error and BPF programs will need to handle them. + * + * Return + * 0 on success, or a negative error in case of failure. */ #define __BPF_FUNC_MAPPER(FN) \ FN(unspec), \ @@ -2331,7 +2348,8 @@ union bpf_attr { FN(sk_release), \ FN(map_push_elem), \ FN(map_pop_elem), \ - FN(map_peek_elem), + FN(map_peek_elem), \ + FN(msg_push_data), /* integer value in 'imm' field of BPF_CALL instruction selects which helper * function eBPF program intends to call |