* [PATCH] test/fib: clarify FIB RCU negative tests
@ 2024-10-16 18:42 Vladimir Medvedkin
2024-10-16 20:33 ` Stephen Hemminger
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Vladimir Medvedkin @ 2024-10-16 18:42 UTC (permalink / raw)
To: dev; +Cc: david.marchand, stephen
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 <vladimir.medvedkin@intel.com>
---
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] test/fib: clarify FIB RCU negative tests
2024-10-16 18:42 [PATCH] test/fib: clarify FIB RCU negative tests Vladimir Medvedkin
@ 2024-10-16 20:33 ` Stephen Hemminger
2024-11-07 13:00 ` David Marchand
2024-11-07 17:04 ` [PATCH v2] " Vladimir Medvedkin
2 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2024-10-16 20:33 UTC (permalink / raw)
To: Vladimir Medvedkin; +Cc: dev, david.marchand
On Wed, 16 Oct 2024 18:42:09 +0000
Vladimir Medvedkin <vladimir.medvedkin@intel.com> wrote:
> 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 <vladimir.medvedkin@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] test/fib: clarify FIB RCU negative tests
2024-10-16 18:42 [PATCH] test/fib: clarify FIB RCU negative tests Vladimir Medvedkin
2024-10-16 20:33 ` Stephen Hemminger
@ 2024-11-07 13:00 ` David Marchand
2024-11-07 17:02 ` Medvedkin, Vladimir
2024-11-07 17:04 ` [PATCH v2] " Vladimir Medvedkin
2 siblings, 1 reply; 6+ messages in thread
From: David Marchand @ 2024-11-07 13:00 UTC (permalink / raw)
To: Vladimir Medvedkin; +Cc: dev, stephen
On Wed, Oct 16, 2024 at 8:42 PM Vladimir Medvedkin
<vladimir.medvedkin@intel.com> wrote:
> @@ -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");
My eyes stopped on this.
Should be == right?
>
> rte_fib_free(fib);
> rte_free(qsv);
--
David Marchand
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] test/fib: clarify FIB RCU negative tests
2024-11-07 13:00 ` David Marchand
@ 2024-11-07 17:02 ` Medvedkin, Vladimir
0 siblings, 0 replies; 6+ messages in thread
From: Medvedkin, Vladimir @ 2024-11-07 17:02 UTC (permalink / raw)
To: David Marchand; +Cc: dev, stephen
Hi David,
On 07/11/2024 13:00, David Marchand wrote:
> On Wed, Oct 16, 2024 at 8:42 PM Vladimir Medvedkin
> <vladimir.medvedkin@intel.com> wrote:
>> @@ -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");
> My eyes stopped on this.
> Should be == right?
You right, thanks!
Will send v2
>
>> rte_fib_free(fib);
>> rte_free(qsv);
>
--
Regards,
Vladimir
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] test/fib: clarify FIB RCU negative tests
2024-10-16 18:42 [PATCH] test/fib: clarify FIB RCU negative tests Vladimir Medvedkin
2024-10-16 20:33 ` Stephen Hemminger
2024-11-07 13:00 ` David Marchand
@ 2024-11-07 17:04 ` Vladimir Medvedkin
2024-11-08 14:16 ` David Marchand
2 siblings, 1 reply; 6+ messages in thread
From: Vladimir Medvedkin @ 2024-11-07 17:04 UTC (permalink / raw)
To: dev; +Cc: david.marchand, stephen
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 <vladimir.medvedkin@intel.com>
---
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..ecd3fb4297 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] test/fib: clarify FIB RCU negative tests
2024-11-07 17:04 ` [PATCH v2] " Vladimir Medvedkin
@ 2024-11-08 14:16 ` David Marchand
0 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2024-11-08 14:16 UTC (permalink / raw)
To: Vladimir Medvedkin; +Cc: dev, stephen
On Thu, Nov 7, 2024 at 6:04 PM Vladimir Medvedkin
<vladimir.medvedkin@intel.com> wrote:
>
> 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 <vladimir.medvedkin@intel.com>
I kept Stephen ack from v1.
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-08 14:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-16 18:42 [PATCH] test/fib: clarify FIB RCU negative tests Vladimir Medvedkin
2024-10-16 20:33 ` Stephen Hemminger
2024-11-07 13:00 ` David Marchand
2024-11-07 17:02 ` Medvedkin, Vladimir
2024-11-07 17:04 ` [PATCH v2] " Vladimir Medvedkin
2024-11-08 14:16 ` David Marchand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).