From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by dpdk.org (Postfix) with ESMTP id 7C2E7B6EB for ; Fri, 20 Feb 2015 14:17:27 +0100 (CET) Received: by labgm9 with SMTP id gm9so6086289lab.2 for ; Fri, 20 Feb 2015 05:17:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c5ztNFFivBhPs64Obf8WOrS/YB71tdPkURr7jy2UQLo=; b=Tr0lqTVz8s0vmwffqxpg53BZ+wbVd6LXXYDZj2hK0zpgliJdBJUGGpXn7B9ExhnPAF vRdVTCjDsLIDG1kD+Y2b4AJdMm8KVhYvXbS2argyWSxYEM12K1+DFsw9zK5WQMF8e5/e td3lyT6D1Gn0ZGNm3+7HnYMQ0bjCYAB8mvN8HmHVVupNwc4Buy9vDU3RBAcTqK8voVzO UHx9QpJeY179J/eFXpKA6OgiEU9ZDjFcyjkLuIA5Egv/jevRcfhneFKh8OpDJ4FHtbBc JhaHyxMezU1wNuyUBGPxh7ELT1cjZgoUQliQGoc0/zV67edEwajbF0QtEP+QZFsXs602 nIVQ== X-Gm-Message-State: ALoCoQl8QQewsVa2q7UDG/P+BFl+dLgGAXUq7czhXKkZ7/bm5KqIMS1WD4hLXd6+IYoeXsjYwCLb X-Received: by 10.152.87.178 with SMTP id az18mr8643496lab.122.1424438247155; Fri, 20 Feb 2015 05:17:27 -0800 (PST) Received: from localhost.localdomain (vpn.arccn.ru. [95.182.74.2]) by mx.google.com with ESMTPSA id rk10sm4086873lac.12.2015.02.20.05.17.25 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Feb 2015 05:17:26 -0800 (PST) From: Igor Ryzhov To: dev@dpdk.org Date: Fri, 20 Feb 2015 16:16:46 +0300 Message-Id: <1424438206-29526-1-git-send-email-iryzhov@nfware.com> X-Mailer: git-send-email 1.9.3 (Apple Git-50) Cc: Igor Ryzhov Subject: [dpdk-dev] [PATCH] lpm: fix overflow issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 13:17:27 -0000 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)