History

bpf, selftest: test {rd, wr}only flags and direct value access

Extend test_verifier with various test cases around the two kernel extensions, that is, {rd,wr}only map support as well as direct map value access. All passing, one skipped due to xskmap not present on test machine: # ./test_verifier [...] #948/p XDP pkt read, pkt_meta' <= pkt_data, bad access 1 OK #949/p XDP pkt read, pkt_meta' <= pkt_data, bad access 2 OK #950/p XDP pkt read, pkt_data <= pkt_meta', good access OK #951/p XDP pkt read, pkt_data <= pkt_meta', bad access 1 OK #952/p XDP pkt read, pkt_data <= pkt_meta', bad access 2 OK Summary: 1410 PASSED, 1 SKIPPED, 0 FAILED

Daniel Borkmann committed 7 years ago

Commit fb2abb71 parent 817998a4 files · +573 −5Browse files

Showing the changes to tools/include/linux (1 of 4 files). Show all

Unified · Split

tools/include/linux/filter.h+20−1
@@ -278,10 +278,29 @@ · 277 unmodified lines
278278 .off = 0, \
279279 .imm = ((__u64) (IMM)) >> 32 })
280280
281+#define BPF_LD_IMM64_RAW_FULL(DST, SRC, OFF1, OFF2, IMM1, IMM2) \
282+ ((struct bpf_insn) { \
283+ .code = BPF_LD | BPF_DW | BPF_IMM, \
284+ .dst_reg = DST, \
285+ .src_reg = SRC, \
286+ .off = OFF1, \
287+ .imm = IMM1 }), \
288+ ((struct bpf_insn) { \
289+ .code = 0, /* zero is reserved opcode */ \
290+ .dst_reg = 0, \
291+ .src_reg = 0, \
292+ .off = OFF2, \
293+ .imm = IMM2 })
294+
281295 /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */
282296
283297 #define BPF_LD_MAP_FD(DST, MAP_FD) \
284− BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD)
298+ BPF_LD_IMM64_RAW_FULL(DST, BPF_PSEUDO_MAP_FD, 0, 0, \
299+ MAP_FD, 0)
300+
301+#define BPF_LD_MAP_VALUE(DST, MAP_FD, VALUE_OFF) \
302+ BPF_LD_IMM64_RAW_FULL(DST, BPF_PSEUDO_MAP_VALUE, 0, 0, \
303+ MAP_FD, VALUE_OFF)
285304
286305 /* Relative call */
287306