From patchwork Thu Apr 14 20:01:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 109730 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BB205A0509; Thu, 14 Apr 2022 22:01:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6D7684067E; Thu, 14 Apr 2022 22:01:11 +0200 (CEST) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 58E4B4067C for ; Thu, 14 Apr 2022 22:01:10 +0200 (CEST) Received: by mail-pl1-f172.google.com with SMTP id q3so5569447plg.3 for ; Thu, 14 Apr 2022 13:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ly0wbHtMW0hISi4C5WI6UFyhTICPCXHDIdt5Hh8vVsw=; b=i97edvDsZ6qpySVnGlSYo9hoYg/BUgG/48KjD8DDV1uA1IfY+lcWpws2B0uyWnyHPl qPAh/uq9RUZaO5eOtpSyXF2U1kK3OL/tCe3g9/VMhx8DZ4zfsCNuUSPgCt3LL/gkpq7p MuTtRZjQk9IqOVpFtuhXilQGikubGBu3lggX4hHhGJLJD7AepFBoRuvjvsCsb74WbDeJ XONd30VTp+bpApTgX7z9M4MX2Iu+xjFkekE8cE8ACFPlR4WBq/mpicg9JqUSwCU9Kexo c3nK4y0Jabj6KMwpjT1cqq+YFS+X5qEhYdCP3kmM8QVWgx+HysdIRAvel9k0phw+Y8+w K8FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ly0wbHtMW0hISi4C5WI6UFyhTICPCXHDIdt5Hh8vVsw=; b=Vlh8vkqkc+Zl4JnVbfuXSpP8Sr6HWpQO3EaZE+WsC165sCUr/rWUCbHsbVEPFK79Cy lxpqd42S1FC4PkJpraiy2bA0NTcmE93RxfYwBkF3DV5X7mDAHXdGX+uTW01qXN2vQCFR 4V1XKDWrK9b9reX5prULFjH5JiwRZKyQRiwki1ATPKd2oEm0R69NCZfco0z6uRnkhyHJ lc2k5YbFUSu+uKLFnILNnw1U8R5EJLGqR40k4S+iC4nqGtJWsUWfZP9wA3kjSzd0tX1N wCfHivojpqYL4KaDDek0qWrB/+gg/yeCcRhGUYWad3rZH9kpbDezOxnf3QpjT9RbsVaK p+kg== X-Gm-Message-State: AOAM5335bn1O+tqrW63CWK1vC2Rwgxf27w7nSipDnpW4USFjcLKtqenG mUbpmwjY78yXhPh9dzOn76nGTKKryATI0A== X-Google-Smtp-Source: ABdhPJz84ijuner7nevEzLMQ5qexC0F58xx3PmJYGnZOvFwlEPrRp7x7YBL35VsZk0hY91o4qfV2ug== X-Received: by 2002:a17:902:9b94:b0:156:2c08:14a5 with SMTP id y20-20020a1709029b9400b001562c0814a5mr48617190plp.60.1649966468240; Thu, 14 Apr 2022 13:01:08 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id d20-20020a056a00199400b005060849909esm760817pfl.176.2022.04.14.13.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 13:01:07 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH] rib: fix traversal with /32 route Date: Thu, 14 Apr 2022 13:01:04 -0700 Message-Id: <20220414200104.245071-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If a /32 route is entered in the RIB the code to traverse will not see that a a end of the tree. This is due to trying to do a negative shift which is an undefined in C. Fix by checking for max depth as is already done in rib6. Signed-off-by: Stephen Hemminger Acked-by: Vladimir Medvedkin --- lib/rib/rte_rib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c index cd9e823068d2..0603980cabd2 100644 --- a/lib/rib/rte_rib.c +++ b/lib/rib/rte_rib.c @@ -71,6 +71,8 @@ is_covered(uint32_t ip1, uint32_t ip2, uint8_t depth) static inline struct rte_rib_node * get_nxt_node(struct rte_rib_node *node, uint32_t ip) { + if (node->depth == RIB_MAXDEPTH) + return NULL; return (ip & (1 << (31 - node->depth))) ? node->right : node->left; }