From mboxrd@z Thu Jan 1 00:00:00 1970 From: Igor Ryzhov Subject: [PATCH] lpm: fix overflow issue Date: Fri, 20 Feb 2015 16:16:46 +0300 Message-ID: <1424438206-29526-1-git-send-email-iryzhov@nfware.com> Cc: Igor Ryzhov To: dev-VfR2kkLFssw@public.gmane.org Return-path: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" LPM table overflow may occur if table is full and added rule has the biggest depth that already have some rules. Signed-off-by: Igor Ryzhov --- lib/librte_lpm/rte_lpm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 983e04b..cc51210 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -298,6 +298,9 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, return rule_index; } } + + if (rule_index == lpm->max_rules) + return -ENOSPC; } else { /* Calculate the position in which the rule will be stored. */ rule_index = 0; -- 1.9.3 (Apple Git-50)