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

Function cmp_reg_val_within

dpdk/lib/bpf/bpf_validate.c:2283–2300  ·  view source on GitHub ↗

* compare two evaluation states. * returns zero if @lv is more conservative (safer) then @rv. * returns non-zero value otherwise. */

Source from the content-addressed store, hash-verified

2281 * returns non-zero value otherwise.
2282 */
2283static int
2284cmp_reg_val_within(const struct bpf_reg_val *lv, const struct bpf_reg_val *rv)
2285{
2286 /* expect @v and @mask to be identical */
2287 if (memcmp(&lv->v, &rv->v, sizeof(lv->v)) != 0 || lv->mask != rv->mask)
2288 return -1;
2289
2290 /* exact match only for mbuf and stack pointers */
2291 if (lv->v.type == RTE_BPF_ARG_PTR_MBUF ||
2292 lv->v.type == BPF_ARG_PTR_STACK)
2293 return -1;
2294
2295 if (lv->u.min <= rv->u.min && lv->u.max >= rv->u.max &&
2296 lv->s.min <= rv->s.min && lv->s.max >= rv->s.max)
2297 return 0;
2298
2299 return -1;
2300}
2301
2302/*
2303 * compare two evaluation states.

Callers 1

cmp_eval_stateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected