1 #define BPF_SOCK_ADDR_STORE(field, off, res, err, flgs) \
3 "wide store to bpf_sock_addr." #field "[" #off "]", \
5 BPF_MOV64_IMM(BPF_REG_0, 1), \
6 BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, \
7 offsetof(struct bpf_sock_addr, field[off])), \
11 .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR, \
12 .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG, \
17 /* user_ip6[0] is u64 aligned */
18 BPF_SOCK_ADDR_STORE(user_ip6
, 0, ACCEPT
,
20 BPF_SOCK_ADDR_STORE(user_ip6
, 1, REJECT
,
21 "invalid bpf_context access off=12 size=8",
22 F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
),
23 BPF_SOCK_ADDR_STORE(user_ip6
, 2, ACCEPT
,
25 BPF_SOCK_ADDR_STORE(user_ip6
, 3, REJECT
,
26 "invalid bpf_context access off=20 size=8",
27 F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
),
29 /* msg_src_ip6[0] is _not_ u64 aligned */
30 BPF_SOCK_ADDR_STORE(msg_src_ip6
, 0, REJECT
,
31 "invalid bpf_context access off=44 size=8",
32 F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
),
33 BPF_SOCK_ADDR_STORE(msg_src_ip6
, 1, ACCEPT
,
35 BPF_SOCK_ADDR_STORE(msg_src_ip6
, 2, REJECT
,
36 "invalid bpf_context access off=52 size=8",
37 F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
),
38 BPF_SOCK_ADDR_STORE(msg_src_ip6
, 3, REJECT
,
39 "invalid bpf_context access off=56 size=8", 0),
41 #undef BPF_SOCK_ADDR_STORE
43 #define BPF_SOCK_ADDR_LOAD(field, off, res, err, flgs) \
45 "wide load from bpf_sock_addr." #field "[" #off "]", \
47 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, \
48 offsetof(struct bpf_sock_addr, field[off])), \
49 BPF_MOV64_IMM(BPF_REG_0, 1), \
53 .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR, \
54 .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG, \
59 /* user_ip6[0] is u64 aligned */
60 BPF_SOCK_ADDR_LOAD(user_ip6
, 0, ACCEPT
,
62 BPF_SOCK_ADDR_LOAD(user_ip6
, 1, REJECT
,
63 "invalid bpf_context access off=12 size=8",
64 F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
),
65 BPF_SOCK_ADDR_LOAD(user_ip6
, 2, ACCEPT
,
67 BPF_SOCK_ADDR_LOAD(user_ip6
, 3, REJECT
,
68 "invalid bpf_context access off=20 size=8",
69 F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
),
71 /* msg_src_ip6[0] is _not_ u64 aligned */
72 BPF_SOCK_ADDR_LOAD(msg_src_ip6
, 0, REJECT
,
73 "invalid bpf_context access off=44 size=8",
74 F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
),
75 BPF_SOCK_ADDR_LOAD(msg_src_ip6
, 1, ACCEPT
,
77 BPF_SOCK_ADDR_LOAD(msg_src_ip6
, 2, REJECT
,
78 "invalid bpf_context access off=52 size=8",
79 F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
),
80 BPF_SOCK_ADDR_LOAD(msg_src_ip6
, 3, REJECT
,
81 "invalid bpf_context access off=56 size=8", 0),
83 #undef BPF_SOCK_ADDR_LOAD