mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-05 19:31:57 -04:00
BACKPORT: bpf: sock_ops: Change some members of sock_ops_kern from u32 to u8
A later patch needs to add a few pointers and a few u8 to sock_ops_kern. Hence, this patch saves some spaces by moving some of the existing members from u32 to u8 so that the later patch can still fit everything in a cacheline. Change-Id: I2832dd6ada962378f87b948d81eab58e7093bc2f Signed-off-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200820190058.2885640-1-kafai@fb.com
This commit is contained in:
parent
6f2dbfbdf8
commit
72f1f798cd
2 changed files with 12 additions and 7 deletions
|
|
@ -1315,13 +1315,13 @@ struct bpf_sock_addr_kern {
|
|||
|
||||
struct bpf_sock_ops_kern {
|
||||
struct sock *sk;
|
||||
u32 op;
|
||||
union {
|
||||
u32 args[4];
|
||||
u32 reply;
|
||||
u32 replylong[4];
|
||||
};
|
||||
u32 is_fullsock;
|
||||
u8 op;
|
||||
u8 is_fullsock;
|
||||
u64 temp; /* temp and everything after is not
|
||||
* initialized to 0 before calling
|
||||
* the BPF program. New fields that
|
||||
|
|
|
|||
|
|
@ -8561,17 +8561,22 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
|
|||
return insn - insn_buf;
|
||||
|
||||
switch (si->off) {
|
||||
case offsetof(struct bpf_sock_ops, op) ...
|
||||
case offsetof(struct bpf_sock_ops, op):
|
||||
*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct bpf_sock_ops_kern,
|
||||
op),
|
||||
si->dst_reg, si->src_reg,
|
||||
offsetof(struct bpf_sock_ops_kern, op));
|
||||
break;
|
||||
|
||||
case offsetof(struct bpf_sock_ops, replylong[0]) ...
|
||||
offsetof(struct bpf_sock_ops, replylong[3]):
|
||||
BUILD_BUG_ON(FIELD_SIZEOF(struct bpf_sock_ops, op) !=
|
||||
FIELD_SIZEOF(struct bpf_sock_ops_kern, op));
|
||||
BUILD_BUG_ON(FIELD_SIZEOF(struct bpf_sock_ops, reply) !=
|
||||
FIELD_SIZEOF(struct bpf_sock_ops_kern, reply));
|
||||
BUILD_BUG_ON(FIELD_SIZEOF(struct bpf_sock_ops, replylong) !=
|
||||
FIELD_SIZEOF(struct bpf_sock_ops_kern, replylong));
|
||||
off = si->off;
|
||||
off -= offsetof(struct bpf_sock_ops, op);
|
||||
off += offsetof(struct bpf_sock_ops_kern, op);
|
||||
off -= offsetof(struct bpf_sock_ops, replylong[0]);
|
||||
off += offsetof(struct bpf_sock_ops_kern, replylong[0]);
|
||||
if (type == BPF_WRITE)
|
||||
*insn++ = BPF_STX_MEM(BPF_W, si->dst_reg, si->src_reg,
|
||||
off);
|
||||
|
|
|
|||
Loading…
Reference in a new issue