From patchwork Tue Sep 11 17:00:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 146468 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3859147ljw; Tue, 11 Sep 2018 10:00:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYmImLCTkgunc0vRjquuoJQ47YhRLFsLZZ72sKYnoCuxQJskElOWpGXK/9ctJBse6/o0Tb9 X-Received: by 2002:ac8:2f24:: with SMTP id j33-v6mr19861196qta.93.1536685248653; Tue, 11 Sep 2018 10:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536685248; cv=none; d=google.com; s=arc-20160816; b=GVnxHdm1bQgQatOXtoqJbxBc/y5q5pJa63IL0hg0s+AlNp3uC0SPiMFHr4hEKObDHo cgq6TzssxUnG5XXweF2gBR7oQHNBWsif3ySd/3pcRdCmNybKaqaMKskJmyaXSYlzKLNs O3TFsQWnVYn5zYVW2vQwANPwI2xijbM2OcwU+8EDAGkdgD6kIF6wQC0WqL6YYY2CSkc2 ERS+xatgke54xwxRiwhHVHAbjY1ar3oHXCMTi8VkuIEP9TURVo6jXu7plGhXVlV08adb 7nMXPH1yl7wscKKF8EJ44IAfP0nkFoxyKErDtzcWTL8E5NfK7I/iCOnCnKK8wLX1Az3+ NI5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to; bh=ToUXHv1rmRzAp2ywMghojNovZrbbDaXCiSUiBcBKyIY=; b=MeEGljOK3pyxD6JhaxtKxMqRVQ97s+cqlDZw4Zec4czatF7A3OQh89rLZI0UpF556l eNOzcJHeUBqmIZ/9xGuzkeGjetGOAd2Eyi0LrBO/uNJP1nRXsPTdIGUDmk9U7i82uwLV eUDXEdbBtuZtmDFfVjbI5SRldWHcSwYddd4KW5d4EFy3CIxf5eKdWbjlVRJB4/BbkCSC jUtbOou6oOUbRSdG6SO1aazZ4SR0uIIbJ2IzMQQLnoZEdeWjjRl1S6K6O4zC1Dcyb3q1 XFMlGlbvoZOLJLNm8O6f0Xe43lZN56Cczx9vf0wjLQRktlVKXAVKXB4s8ur22XRAyrib 8tlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id g1-v6si2520197qkd.118.2018.09.11.10.00.48; Tue, 11 Sep 2018 10:00:48 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 174DF61C3C; Tue, 11 Sep 2018 17:00:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 5012E61C1D; Tue, 11 Sep 2018 17:00:23 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C9F3761C36; Tue, 11 Sep 2018 17:00:18 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 6E51D61C33 for ; Tue, 11 Sep 2018 17:00:12 +0000 (UTC) Received: from mxback15j.mail.yandex.net (mxback15j.mail.yandex.net [IPv6:2a02:6b8:0:1619::91]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 0E0A54306136 for ; Tue, 11 Sep 2018 20:00:11 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback15j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 4RaSPbLdGP-0AWC77rx; Tue, 11 Sep 2018 20:00:11 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id zzRm4n9xhy-0AF4Gxgt; Tue, 11 Sep 2018 20:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Sep 2018 17:00:08 +0000 Message-Id: <1536685208-9060-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536685208-9060-1-git-send-email-odpbot@yandex.ru> References: <1536685208-9060-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 701 Subject: [lng-odp] [PATCH v1 1/1] helper: iplookuptable fix puting values to table X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov On putting values to table we have to validate input data and reject unaccepted data. Signed-off-by: Maxim Uvarov --- /** Email created from pull request 701 (muvarov:devel/master_iploopup) ** https://github.com/Linaro/odp/pull/701 ** Patch: https://github.com/Linaro/odp/pull/701.patch ** Base sha: 1adfa2e17b27032ff31bd8f361e05970ce186148 ** Merge commit sha: e0b5294f727aafbf91154ffe2a43a0736a1e6de3 **/ helper/iplookuptable.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c index 61f634022..b0141c311 100644 --- a/helper/iplookuptable.c +++ b/helper/iplookuptable.c @@ -585,24 +585,25 @@ prefix_insert_into_lx( odph_iplookup_table_impl *tbl, prefix_entry_t *entry, uint8_t cidr, odp_buffer_t nexthop, uint8_t level) { - uint8_t ret = 0; + int ret = 0; uint32_t i = 0, limit = (1 << (level - cidr)); prefix_entry_t *e = entry, *ne = NULL; for (i = 0; i < limit; i++, e++) { - if (e->child == 1) { - if (e->cidr > cidr) - continue; + if (e->cidr > cidr) + continue; + if (e->child == 1) { e->cidr = cidr; /* push to next level */ ne = (prefix_entry_t *)e->ptr; ret = prefix_insert_into_lx( tbl, ne, cidr, nexthop, cidr + 8); + if (ret == -1) + return -1; + if (ret == 0) + return ret; } else { - if (e->cidr > cidr) - continue; - e->child = 0; e->cidr = cidr; e->nexthop = nexthop; @@ -678,8 +679,9 @@ odph_iplookup_table_put_value(odph_table_t tbl, void *key, void *value) nexthop = *((odp_buffer_t *)value); - if (prefix->cidr == 0) + if (prefix->cidr == 0 || prefix->cidr == 255) return -1; + prefix->ip = prefix->ip & (0xffffffff << (IP_LENGTH - prefix->cidr)); /* insert into trie */