bpf: Make SOCK_OPS_GET_TCP size independent
Make SOCK_OPS_GET_TCP helper macro size independent (before only worked with 4-byte fields. Signed-off-by: Lawrence Brakmo <brakmo@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
2585cd62f0
commit
a33de39734
@ -4470,9 +4470,10 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* Helper macro for adding read access to tcp_sock fields. */
|
/* Helper macro for adding read access to tcp_sock fields. */
|
||||||
#define SOCK_OPS_GET_TCP32(FIELD_NAME) \
|
#define SOCK_OPS_GET_TCP(FIELD_NAME) \
|
||||||
do { \
|
do { \
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct tcp_sock, FIELD_NAME) != 4); \
|
BUILD_BUG_ON(FIELD_SIZEOF(struct tcp_sock, FIELD_NAME) > \
|
||||||
|
FIELD_SIZEOF(struct bpf_sock_ops, FIELD_NAME)); \
|
||||||
*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF( \
|
*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF( \
|
||||||
struct bpf_sock_ops_kern, \
|
struct bpf_sock_ops_kern, \
|
||||||
is_fullsock), \
|
is_fullsock), \
|
||||||
@ -4484,16 +4485,18 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
|
|||||||
struct bpf_sock_ops_kern, sk),\
|
struct bpf_sock_ops_kern, sk),\
|
||||||
si->dst_reg, si->src_reg, \
|
si->dst_reg, si->src_reg, \
|
||||||
offsetof(struct bpf_sock_ops_kern, sk));\
|
offsetof(struct bpf_sock_ops_kern, sk));\
|
||||||
*insn++ = BPF_LDX_MEM(BPF_W, si->dst_reg, si->dst_reg, \
|
*insn++ = BPF_LDX_MEM(FIELD_SIZEOF(struct tcp_sock, \
|
||||||
|
FIELD_NAME), si->dst_reg, \
|
||||||
|
si->dst_reg, \
|
||||||
offsetof(struct tcp_sock, FIELD_NAME)); \
|
offsetof(struct tcp_sock, FIELD_NAME)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
case offsetof(struct bpf_sock_ops, snd_cwnd):
|
case offsetof(struct bpf_sock_ops, snd_cwnd):
|
||||||
SOCK_OPS_GET_TCP32(snd_cwnd);
|
SOCK_OPS_GET_TCP(snd_cwnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case offsetof(struct bpf_sock_ops, srtt_us):
|
case offsetof(struct bpf_sock_ops, srtt_us):
|
||||||
SOCK_OPS_GET_TCP32(srtt_us);
|
SOCK_OPS_GET_TCP(srtt_us);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return insn - insn_buf;
|
return insn - insn_buf;
|
||||||
|
Loading…
Reference in New Issue
Block a user