]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
bpf: Add write access to tcp_sock and sock fields
authorLawrence Brakmo <brakmo@fb.com>
Fri, 26 Jan 2018 00:14:08 +0000 (16:14 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 26 Jan 2018 00:41:14 +0000 (16:41 -0800)
commitb73042b8a28e2603ac178295ab96c876ba5a97a1
treec3db00b9c7a9b9816bb3392f9fa59f7d8b4a5e49
parent34d367c59233464dbd1f07445c4665099a7128ec
bpf: Add write access to tcp_sock and sock fields

This patch adds a macro, SOCK_OPS_SET_FIELD, for writing to
struct tcp_sock or struct sock fields. This required adding a new
field "temp" to struct bpf_sock_ops_kern for temporary storage that
is used by sock_ops_convert_ctx_access. It is used to store and recover
the contents of a register, so the register can be used to store the
address of the sk. Since we cannot overwrite the dst_reg because it
contains the pointer to ctx, nor the src_reg since it contains the value
we want to store, we need an extra register to contain the address
of the sk.

Also adds the macro SOCK_OPS_GET_OR_SET_FIELD that calls one of the
GET or SET macros depending on the value of the TYPE field.

Signed-off-by: Lawrence Brakmo <brakmo@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/filter.h
include/net/tcp.h
net/core/filter.c