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

Function cmp_eval_state

dpdk/lib/bpf/bpf_validate.c:2308–2329  ·  view source on GitHub ↗

* compare two evaluation states. * returns zero if they are identical. * returns positive value if @lv is more conservative (safer) then @rv. * returns negative value otherwise. */

Source from the content-addressed store, hash-verified

2306 * returns negative value otherwise.
2307 */
2308static int
2309cmp_eval_state(const struct bpf_eval_state *lv, const struct bpf_eval_state *rv)
2310{
2311 int32_t rc;
2312 uint32_t i, k;
2313
2314 /* for stack expect identical values */
2315 rc = memcmp(lv->sv, rv->sv, sizeof(lv->sv));
2316 if (rc != 0)
2317 return -(2 * EBPF_REG_NUM);
2318
2319 k = 0;
2320 /* check register values */
2321 for (i = 0; i != RTE_DIM(lv->rv); i++) {
2322 rc = memcmp(&lv->rv[i], &rv->rv[i], sizeof(lv->rv[i]));
2323 if (rc != 0 && cmp_reg_val_within(&lv->rv[i], &rv->rv[i]) != 0)
2324 return -(i + 1);
2325 k += (rc != 0);
2326 }
2327
2328 return k;
2329}
2330
2331/*
2332 * check did we already evaluated that path and can it be pruned that time.

Callers 1

prune_eval_stateFunction · 0.85

Calls 1

cmp_reg_val_withinFunction · 0.85

Tested by

no test coverage detected