/** * Perform search for a matching ACL rule for each input data buffer. * Each input data buffer can have up to *categories* matches. * That implies that results array should be big enough to hold * (categories * num) elements. * Also categories parameter should be either one or multiple of * RTE_ACL_RESULTS_MULTIPLIER and can't be bigger than RTE_ACL_MAX_CATEGORIES. * If more than one rule is applicable for given input buffer and * given category, then rule with highest priority will be returned as a match. * Note, that it is a caller's responsibility to ensure that input parameters * are valid and point to correct memory locations. * * @param ctx * ACL context to search with. * @param data * Array of pointers to input data buffers to perform search. * Note that all fields in input data buffers supposed to be in network * byte order (MSB). * @param results * Array of search results, *categories* results per each input data buffer. * @param num * Number of elements in the input data buffers array. * @param categories * Number of maximum possible matches for each input buffer, one possible * match per category. * @return * zero on successful completion. * -EINVAL for incorrect arguments. */ extern int rte_acl_classify(const struct rte_acl_ctx *ctx, const uint8_t **data, uint32_t *results, uint32_t num, uint32_t categories);
以下是rte_acl_classify接口的使用
int acl_match_ipv4(struct acl_context_t *ctx, const char *data) { int result = 0; int ret = rte_acl_classify(ctx->acl_ctx_v4, (const uint8_t **)&data, (uint32_t *)&result, 1, RTE_ACL_MAX_CATEGORIES); if (ret) rte_exit(EXIT_FAILURE, "ERROR rte_acl_classify in acl_match_ipv4\n"); return result; }
排查
我当时真的是非常的困惑. 主管过来一起排查代码找问题.
最后只有这一处代码存在可疑, 其他地方没有发生栈溢出的机会.
那这个API rte_acl_classify 的威力在哪里呢?
看rte_acl_classify中的 num, 只的是 数据输入的个数, 这边的场景是一次匹配一个报文, num 填1, 没错.