From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4382945B55; Wed, 16 Oct 2024 20:42:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 10A264021F; Wed, 16 Oct 2024 20:42:18 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by mails.dpdk.org (Postfix) with ESMTP id AB83340144 for ; Wed, 16 Oct 2024 20:42:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729104136; x=1760640136; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=cirf4gg8wMtuSpK3pspLwiaNGSeV66aZsQqZKddAnJ0=; b=d7ZPJTZ4RbvFosj4TR2w9HQyjOHRuou8iDFLMQRjxEkEj7Lg/wjJKe1l F+rDtkRjGq0pEno/OmYfxcdhl7k1XLFpJvPbJRRa0a9zkXorhHTAfOE7L t+A48Vykelox6SohMonaYP+gqJUHltrr8HTMVMkPzEgRMdzwjucCLVcE1 NryzmWjBaAbLfKXWBI0l0PiLduokQHG9SRbZi8eESQ61Id9nbEu3SoDI+ WxcPqAJGsRWIonL7QKFmg8QUIOz1vGwtkY4qhrRKUub0+rJzK9tUrifs9 c0dPnBQANj/opiJcpeIICXmyRV0sxbynXtHtjcJuOP8tVCa1GJwQ44fbx A==; X-CSE-ConnectionGUID: GC3BxoywQ7ieOOZb4c68KA== X-CSE-MsgGUID: S9exCGldTNGNi/z8WuItgA== X-IronPort-AV: E=McAfee;i="6700,10204,11226"; a="39148176" X-IronPort-AV: E=Sophos;i="6.11,208,1725346800"; d="scan'208";a="39148176" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2024 11:42:14 -0700 X-CSE-ConnectionGUID: ePSUEy8XQ7K731oqt5DNnA== X-CSE-MsgGUID: LcxAZWw/Q82nwIIdRYkhFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,208,1725346800"; d="scan'208";a="115756432" Received: from unknown (HELO silpixa00401176.ir.intel.com) ([10.243.22.76]) by orviesa001.jf.intel.com with ESMTP; 16 Oct 2024 11:42:13 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: david.marchand@redhat.com, stephen@networkplumber.org Subject: [PATCH] test/fib: clarify FIB RCU negative tests Date: Wed, 16 Oct 2024 18:42:09 +0000 Message-ID: <20241016184209.802449-1-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Add additional negative tests for rte_fib_rcu_qsbr_add(). Also explicitly check returned codes. Additionally add a check into the rte_fib_rcu_qsbr_add() for passed fib argument. Signed-off-by: Vladimir Medvedkin --- app/test/test_fib.c | 21 +++++++++++++++------ lib/fib/rte_fib.c | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/test/test_fib.c b/app/test/test_fib.c index 15035ee045..52908588e6 100644 --- a/app/test/test_fib.c +++ b/app/test/test_fib.c @@ -400,7 +400,6 @@ test_invalid_rcu(void) config.max_routes = MAX_ROUTES; config.rib_ext_sz = 0; config.default_nh = def_nh; - config.type = RTE_FIB_DUMMY; fib = rte_fib_create(__func__, SOCKET_ID_ANY, &config); RTE_TEST_ASSERT(fib != NULL, "Failed to create FIB\n"); @@ -417,23 +416,33 @@ test_invalid_rcu(void) rcu_cfg.v = qsv; /* adding rcu to RTE_FIB_DUMMY FIB type */ + config.type = RTE_FIB_DUMMY; rcu_cfg.mode = RTE_FIB_QSBR_MODE_SYNC; status = rte_fib_rcu_qsbr_add(fib, &rcu_cfg); - RTE_TEST_ASSERT(status == -ENOTSUP, "rte_fib_rcu_qsbr_add returned wrong error status\n"); + RTE_TEST_ASSERT(status == -ENOTSUP, + "rte_fib_rcu_qsbr_add returned wrong error status when called with DUMMY type FIB\n"); rte_fib_free(fib); - /* Invalid QSBR mode */ config.type = RTE_FIB_DIR24_8; config.dir24_8.nh_sz = RTE_FIB_DIR24_8_4B; config.dir24_8.num_tbl8 = MAX_TBL8; fib = rte_fib_create(__func__, SOCKET_ID_ANY, &config); RTE_TEST_ASSERT(fib != NULL, "Failed to create FIB\n"); + + /* Call rte_fib_rcu_qsbr_add without fib or config */ + status = rte_fib_rcu_qsbr_add(NULL, &rcu_cfg); + RTE_TEST_ASSERT(status == -EINVAL, "RCU added without fib\n"); + status = rte_fib_rcu_qsbr_add(fib, NULL); + RTE_TEST_ASSERT(status == -EINVAL, "RCU added without config\n"); + + /* Invalid QSBR mode */ rcu_cfg.mode = 2; status = rte_fib_rcu_qsbr_add(fib, &rcu_cfg); - RTE_TEST_ASSERT(status != 0, "Failed to add RCU\n"); + RTE_TEST_ASSERT(status == -EINVAL, "RCU added with incorrect mode\n"); rcu_cfg.mode = RTE_FIB_QSBR_MODE_DQ; - /* Attach RCU QSBR to FIB */ + + /* Attach RCU QSBR to FIB to check for double attach */ status = rte_fib_rcu_qsbr_add(fib, &rcu_cfg); RTE_TEST_ASSERT(status == 0, "Can not attach RCU to FIB\n"); @@ -445,7 +454,7 @@ test_invalid_rcu(void) rcu_cfg.v = qsv2; rcu_cfg.mode = RTE_FIB_QSBR_MODE_SYNC; status = rte_fib_rcu_qsbr_add(fib, &rcu_cfg); - RTE_TEST_ASSERT(status != 0, "Secondary RCU was mistakenly attached\n"); + RTE_TEST_ASSERT(status = -EEXIST, "Secondary RCU was mistakenly attached\n"); rte_fib_free(fib); rte_free(qsv); diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c index fa8779462a..db79fc428e 100644 --- a/lib/fib/rte_fib.c +++ b/lib/fib/rte_fib.c @@ -346,6 +346,9 @@ rte_fib_select_lookup(struct rte_fib *fib, int rte_fib_rcu_qsbr_add(struct rte_fib *fib, struct rte_fib_rcu_config *cfg) { + if (fib == NULL) + return -EINVAL; + switch (fib->type) { case RTE_FIB_DIR24_8: return dir24_8_rcu_qsbr_add(fib->dp, cfg, fib->name); -- 2.43.0