From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hunt Subject: [PATCH v2] lib/distributor: fix segfaults in flush Date: Fri, 14 Apr 2017 09:59:53 +0100 Message-ID: <1492160393-125112-1-git-send-email-david.hunt@intel.com> References: <1492072587-121343-1-git-send-email-david.hunt@intel.com> Cc: bruce.richardson@intel.com, David Hunt To: dev@dpdk.org Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E1C70378B for ; Fri, 14 Apr 2017 10:59:15 +0200 (CEST) In-Reply-To: <1492072587-121343-1-git-send-email-david.hunt@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Occasionally, the distributor single-packet-at-a-time mode will segfault because it inadvertently calls some burst mode code when flushing packets. This patch ensures that only the v20 (single mode) codepath is used, and returns without falling through to the burst mode code. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") v2: Extented commit message. Patch remains the same. Signed-off-by: David Hunt Tested-by: Yong Liu Acked-by: Bruce Richardson --- lib/librte_distributor/rte_distributor.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 4725904..e4dfa7f 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -555,7 +555,7 @@ total_outstanding(const struct rte_distributor *d) int rte_distributor_flush_v1705(struct rte_distributor *d) { - const unsigned int flushed = total_outstanding(d); + unsigned int flushed; unsigned int wkr; if (d->alg_type == RTE_DIST_ALG_SINGLE) { @@ -563,6 +563,8 @@ rte_distributor_flush_v1705(struct rte_distributor *d) return rte_distributor_flush_v20(d->d_v20); } + flushed = total_outstanding(d); + while (total_outstanding(d) > 0) rte_distributor_process(d, NULL, 0); @@ -590,6 +592,7 @@ rte_distributor_clear_returns_v1705(struct rte_distributor *d) if (d->alg_type == RTE_DIST_ALG_SINGLE) { /* Call the old API */ rte_distributor_clear_returns_v20(d->d_v20); + return; } /* throw away returns, so workers can exit */ -- 2.7.4