* compare two evaluation states. * returns zero if @lv is more conservative (safer) then @rv. * returns non-zero value otherwise. */
| 2281 | * returns non-zero value otherwise. |
| 2282 | */ |
| 2283 | static int |
| 2284 | cmp_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. |