summaryrefslogtreecommitdiff
path: root/lib/librte_lpm
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2015-02-20 16:16:46 +0300
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-02-24 02:08:19 +0100
commite128e53879c71215c0293f8c7a7a8f0f173487c1 (patch)
tree71315d78295b816f2af71cd89fed168b739958bb /lib/librte_lpm
parentdc783e74cf70c95084e71442ba09b212dded3757 (diff)
downloaddpdk-e128e53879c71215c0293f8c7a7a8f0f173487c1.zip
dpdk-e128e53879c71215c0293f8c7a7a8f0f173487c1.tar.gz
dpdk-e128e53879c71215c0293f8c7a7a8f0f173487c1.tar.xz
lpm: fix overflow issue
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 <iryzhov@nfware.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'lib/librte_lpm')
-rw-r--r--lib/librte_lpm/rte_lpm.c3
1 files changed, 3 insertions, 0 deletions
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;