def bpf_validate_with
import bend-osdev-bpf@0.1.0.0/validate.bend as Validateimport Base
import bend-osdev-bpf@0.1.0.0/insn.bend as I
257# Done{Unit{}} if the program may run, or the first rule it breaks: the
258# length, then each instruction's own rules in order, then scratch memory
259def bpf_validate_with(opts: BpfValidateOptions, +prog: List<&2, I.BpfOp>) -> Result<&2, &2, I.BpfError, Unit>:
260 match opts:
261 case BpfValidateOptions{max, need}:
262 +n = bpf_count(prog)
263 bpf_validate.ops(bpf_check.len(n, max), n, need, prog)