]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
bpf: sk_msg program helper bpf_msg_push_data
authorJohn Fastabend <john.fastabend@gmail.com>
Sat, 20 Oct 2018 02:56:49 +0000 (19:56 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 20 Oct 2018 19:37:11 +0000 (21:37 +0200)
commit6fff607e2f14bd7c63c06c464a6f93b8efbabe28
tree3ac21ecddcd5903aa5eaecb5ba54d2434ccf5184
parent5032d079909d1ac5c2535acc32d5f01cd245d8ea
bpf: sk_msg program helper bpf_msg_push_data

This allows user to push data into a msg using sk_msg program types.
The format is as follows,

bpf_msg_push_data(msg, offset, len, flags)

this will insert 'len' bytes at offset 'offset'. For example to
prepend 10 bytes at the front of the message the user can,

bpf_msg_push_data(msg, 0, 10, 0);

This will invalidate data bounds so BPF user will have to then recheck
data bounds after calling this. After this the msg size will have been
updated and the user is free to write into the added bytes. We allow
any offset/len as long as it is within the (data, data_end) range.
However, a copy will be required if the ring is full and its possible
for the helper to fail with ENOMEM or EINVAL errors which need to be
handled by the BPF program.

This can be used similar to XDP metadata to pass data between sk_msg
layer and lower layers.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/linux/skmsg.h
include/uapi/linux/bpf.h
net/core/filter.c