fuel-plugin-ovs/ovs_build/dpdk_2.2.0/debian/patches/ubuntu-backport-28-lpm-fix-...

80 lines
2.6 KiB
Diff

Description: backport of dpdk 16.04-rc fix for LP: #1568838
Forwarded: n/a (already upstream)
Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Last-Update: 2016-04-11
From f82f705b635d31a63446a16bc4526dbebf293c5a Mon Sep 17 00:00:00 2001
From: Olivier Matz <olivier.matz@6wind.com>
Date: Wed, 6 Apr 2016 15:27:58 +0200
Subject: [PATCH] lpm: fix allocation of an existing object
Change rte_lpm*_create() functions to return NULL and set rte_errno to
EEXIST when the object name already exists. This is the behavior
described in the API documentation in the header file.
These functions were returning a pointer to the existing object in that
case, but it is a problem as the caller did not know if the object had
to be freed or not.
Doing this change also makes the lpm API more consistent with the other
APIs (mempool, rings, ...).
Fixes: 916e4f4f4e ("memory: fix for multi process support")
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
app/test/test_lpm6.c | 2 +-
lib/librte_lpm/rte_lpm.c | 10 ++++++++--
lib/librte_lpm/rte_lpm6.c | 5 ++++-
4 files changed, 22 insertions(+), 4 deletions(-)
Index: dpdk/app/test/test_lpm6.c
===================================================================
--- dpdk.orig/app/test/test_lpm6.c
+++ dpdk/app/test/test_lpm6.c
@@ -222,7 +222,7 @@ test1(void)
/* rte_lpm6_create: lpm name == LPM2 */
lpm3 = rte_lpm6_create("LPM1", SOCKET_ID_ANY, &config);
- TEST_LPM_ASSERT(lpm3 == lpm1);
+ TEST_LPM_ASSERT(lpm3 == NULL);
rte_lpm6_free(lpm1);
rte_lpm6_free(lpm2);
Index: dpdk/lib/librte_lpm/rte_lpm.c
===================================================================
--- dpdk.orig/lib/librte_lpm/rte_lpm.c
+++ dpdk/lib/librte_lpm/rte_lpm.c
@@ -181,8 +181,11 @@ rte_lpm_create(const char *name, int soc
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);
Index: dpdk/lib/librte_lpm/rte_lpm6.c
===================================================================
--- dpdk.orig/lib/librte_lpm/rte_lpm6.c
+++ dpdk/lib/librte_lpm/rte_lpm6.c
@@ -182,8 +182,11 @@ rte_lpm6_create(const char *name, int so
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);