* Check that user provided external symbol. */
| 48 | * Check that user provided external symbol. |
| 49 | */ |
| 50 | static int |
| 51 | bpf_check_xsym(const struct rte_bpf_xsym *xsym) |
| 52 | { |
| 53 | uint32_t i; |
| 54 | |
| 55 | if (xsym->name == NULL) |
| 56 | return -EINVAL; |
| 57 | |
| 58 | if (xsym->type == RTE_BPF_XTYPE_VAR) { |
| 59 | if (xsym->var.desc.type == RTE_BPF_ARG_UNDEF) |
| 60 | return -EINVAL; |
| 61 | } else if (xsym->type == RTE_BPF_XTYPE_FUNC) { |
| 62 | |
| 63 | if (xsym->func.nb_args > EBPF_FUNC_MAX_ARGS) |
| 64 | return -EINVAL; |
| 65 | |
| 66 | /* check function arguments */ |
| 67 | for (i = 0; i != xsym->func.nb_args; i++) { |
| 68 | if (xsym->func.args[i].type == RTE_BPF_ARG_UNDEF) |
| 69 | return -EINVAL; |
| 70 | } |
| 71 | |
| 72 | /* check return value info */ |
| 73 | if (xsym->func.ret.type != RTE_BPF_ARG_UNDEF && |
| 74 | xsym->func.ret.size == 0) |
| 75 | return -EINVAL; |
| 76 | } else |
| 77 | return -EINVAL; |
| 78 | |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | struct rte_bpf * |
| 83 | rte_bpf_load(const struct rte_bpf_prm *prm) |