From patchwork Tue Sep 11 14: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: 146452 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3674905ljw; Tue, 11 Sep 2018 07:01:06 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda4tke7nBDbRweSDomggEyhFLD5N9IhSkbDaQcc1l+ynuHwjZBoGuh7Ms3lKLYz19+B/FfO X-Received: by 2002:ac8:1981:: with SMTP id u1-v6mr20212786qtj.296.1536674466302; Tue, 11 Sep 2018 07:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536674466; cv=none; d=google.com; s=arc-20160816; b=mXBJ5fpwxR7KJryPLuXu6BGh8yzg2pOW+Sj7XRjZDd281ORfFaC7XJvDKVps28FHZ0 N6lwX9i/m8zP7xWbfDMmsCnzl7GkOQmhhq1kGVOz6GNqvAPttQcVmeZK5pBIMBConlKJ uNNOk/oWQkU7tXlL+1Dn44st9LMKncSwdrlorUUsFmSbq3T1uJzZD6D6Js8qm6kaZJWE r7Fp4pZS4cnJkXrJEZXGes/yfA0CY2YRTwOmZ6hPE8hXNJsj5gJwuRMmG2sghSJbocJ5 3kFOt3rUYIOh81VPYPbz66GNdWddURgwyu4vagrpi432WUjjO/kzh/45ipdxPYB8e+gd 3UMA== 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=bLuOO2P+wbr0tdmWmq+XQG+QFgJ7QQXcPKrG+G7tEkE=; b=GZIHn4tqjCLFeGKv0hzB1eRAHdCOt+2utLEBWPGPnARmaHm4QC9Dcp55zXed5aNR9t oX8kPedCnkfUZqmupRqug8GUpO1+lW5lngjneofldaejJvRig8bAe2xeQHwWIXP5ETeO DIvTVksH6fPuvfuQgmIZZYL9CAmEflg1+wj5hmhibz/6O+cGn0DzVOnIfsiZcdMe5hKx 2ZryzvJzLv7U5JJxavE5zHKqVA3nZlHLuPPCsDHmqfQpoOvWFgg9y8WGQ4tEBElf+svp wr6Tzj3R10hJxkwHYhWKlhAPP2EikjzRdi7SE6Omma6j3sskDxiG6ovUolZ5HUqCXUUq GQXA== 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 o23-v6si247780qtr.338.2018.09.11.07.01.05; Tue, 11 Sep 2018 07:01:06 -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 CDD0361C2A; Tue, 11 Sep 2018 14:01:05 +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 E205A61C01; Tue, 11 Sep 2018 14:00:24 +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 E538261C13; Tue, 11 Sep 2018 14:00:21 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id D50EF61C01 for ; Tue, 11 Sep 2018 14:00:14 +0000 (UTC) Received: from mxback1j.mail.yandex.net (mxback1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10a]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 16EFB34C79AE for ; Tue, 11 Sep 2018 17:00:13 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id C8y6vcpsy3-0CEKusMI; Tue, 11 Sep 2018 17:00:13 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Hkfqa3Exzc-0AnGNGEd; Tue, 11 Sep 2018 17: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 14:00:08 +0000 Message-Id: <1536674408-8395-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536674408-8395-1-git-send-email-odpbot@yandex.ru> References: <1536674408-8395-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 700 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 700 (Linaro:devel/master_iploopup) ** https://github.com/Linaro/odp/pull/700 ** Patch: https://github.com/Linaro/odp/pull/700.patch ** Base sha: 33fbc04b6373960ec3f84de4e7e7b34c49d71508 ** Merge commit sha: ce64f0400605ea7b3298769a1ebce6fa7da611a9 **/ 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 */