MCPcopy Create free account
hub / github.com/F-Stack/f-stack / eval_ld_mbuf

Function eval_ld_mbuf

dpdk/lib/bpf/bpf_validate.c:599–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597}
598
599static const char *
600eval_ld_mbuf(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
601{
602 uint32_t i, mode;
603 struct bpf_reg_val *rv, ri, rs;
604
605 mode = BPF_MODE(ins->code);
606
607 /* R6 is an implicit input that must contain pointer to mbuf */
608 if (bvf->evst->rv[EBPF_REG_6].v.type != RTE_BPF_ARG_PTR_MBUF)
609 return "invalid type for implicit ctx register";
610
611 if (mode == BPF_IND) {
612 rs = bvf->evst->rv[ins->src_reg];
613 if (rs.v.type != RTE_BPF_ARG_RAW)
614 return "unexpected type for src register";
615
616 eval_fill_imm(&ri, UINT64_MAX, ins->imm);
617 eval_add(&rs, &ri, UINT64_MAX);
618
619 if (rs.s.max < 0 || rs.u.min > UINT32_MAX)
620 return "mbuf boundary violation";
621 }
622
623 /* R1-R5 scratch registers */
624 for (i = EBPF_REG_1; i != EBPF_REG_6; i++)
625 bvf->evst->rv[i].v.type = RTE_BPF_ARG_UNDEF;
626
627 /* R0 is an implicit output, contains data fetched from the packet */
628 rv = bvf->evst->rv + EBPF_REG_0;
629 rv->v.size = bpf_size(BPF_SIZE(ins->code));
630 eval_fill_max_bound(rv, RTE_LEN2MASK(rv->v.size * CHAR_BIT, uint64_t));
631
632 return NULL;
633}
634
635/*
636 * check that destination and source operand are in defined state.

Callers

nothing calls this directly

Calls 4

eval_fill_immFunction · 0.85
eval_addFunction · 0.85
bpf_sizeFunction · 0.85
eval_fill_max_boundFunction · 0.85

Tested by

no test coverage detected