* 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. */
| 2306 | * returns negative value otherwise. |
| 2307 | */ |
| 2308 | static int |
| 2309 | cmp_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. |
no test coverage detected