Skip to content

Commit

Permalink
bpf: sk_msg program helper bpf_msg_push_data
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
jrfastab authored and borkmann committed Oct 20, 2018
1 parent 5032d07 commit 6fff607
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/linux/skmsg.h
20 changes: 19 additions & 1 deletion include/uapi/linux/bpf.h
134 changes: 134 additions & 0 deletions net/core/filter.c

0 comments on commit 6fff607

Please sign in to comment.