@@ -213,37 +213,40 @@ rte_acl_create(const struct rte_acl_param *param)
break;
}
+ ctx = NULL;
+ if (te != NULL) {
+ rte_errno = EEXIST;
+ goto exit;
+ }
+
/* if ACL with such name doesn't exist, then create a new one. */
- if (te == NULL) {
- ctx = NULL;
- te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0);
+ te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0);
- if (te == NULL) {
- RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n");
- goto exit;
- }
+ if (te == NULL) {
+ RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n");
+ goto exit;
+ }
- ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id);
+ ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id);
- if (ctx == NULL) {
- RTE_LOG(ERR, ACL,
- "allocation of %zu bytes on socket %d for %s failed\n",
- sz, param->socket_id, name);
- rte_free(te);
- goto exit;
- }
- /* init new allocated context. */
- ctx->rules = ctx + 1;
- ctx->max_rules = param->max_rule_num;
- ctx->rule_sz = param->rule_size;
- ctx->socket_id = param->socket_id;
- ctx->alg = rte_acl_default_classify;
- snprintf(ctx->name, sizeof(ctx->name), "%s", param->name);
+ if (ctx == NULL) {
+ RTE_LOG(ERR, ACL,
+ "allocation of %zu bytes on socket %d for %s failed\n",
+ sz, param->socket_id, name);
+ rte_free(te);
+ goto exit;
+ }
+ /* init new allocated context. */
+ ctx->rules = ctx + 1;
+ ctx->max_rules = param->max_rule_num;
+ ctx->rule_sz = param->rule_size;
+ ctx->socket_id = param->socket_id;
+ ctx->alg = rte_acl_default_classify;
+ snprintf(ctx->name, sizeof(ctx->name), "%s", param->name);
- te->data = (void *) ctx;
+ te->data = (void *) ctx;
- TAILQ_INSERT_TAIL(acl_list, te, next);
- }
+ TAILQ_INSERT_TAIL(acl_list, te, next);
exit:
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
@@ -206,8 +206,10 @@ rte_hash_create(const struct rte_hash_parameters *params)
/* Guarantee there's no existing */
h = rte_hash_find_existing(params->name);
- if (h != NULL)
- return h;
+ if (h != NULL) {
+ rte_errno = EEXIST;
+ return NULL;
+ }
te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0);
if (te == NULL) {
@@ -140,8 +140,11 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
if (strncmp(params->name, ht->name, RTE_FBK_HASH_NAMESIZE) == 0)
break;
}
- if (te != NULL)
+ ht = NULL;
+ if (te != NULL) {
+ rte_errno = EEXIST;
goto exit;
+ }
te = rte_zmalloc("FBK_HASH_TAILQ_ENTRY", sizeof(*te), 0);
if (te == NULL) {
@@ -181,8 +181,11 @@ rte_lpm_create(const char *name, int socket_id, int max_rules,
if (strncmp(name, lpm->name, RTE_LPM_NAMESIZE) == 0)
break;
}
- if (te != NULL)
+ lpm = NULL;
+ if (te != NULL) {
+ rte_errno = EEXIST;
goto exit;
+ }
/* allocate tailq entry */
te = rte_zmalloc("LPM_TAILQ_ENTRY", sizeof(*te), 0);
@@ -182,8 +182,11 @@ rte_lpm6_create(const char *name, int socket_id,
if (strncmp(name, lpm->name, RTE_LPM6_NAMESIZE) == 0)
break;
}
- if (te != NULL)
+ lpm = NULL;
+ if (te != NULL) {
+ rte_errno = EEXIST;
goto exit;
+ }
/* allocate tailq entry */
te = rte_zmalloc("LPM6_TAILQ_ENTRY", sizeof(*te), 0);