Skip to contentSkip to conversation

graph: remove the useless duplicate name check

PATCH Superseded Haiyue Wang 3 participants 4 messages Mar 7, 2022 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 graph: remove the useless duplicate name check

The node clone API parameter 'name' is the new node's postfix name, not the final node name, so it makes no sense to check it. And the new name will be checked duplicate when calling API '__rte_node_register'.

And update the test case to call clone API twice to check the real name duplicate.

---
v2: update the test case.

---
 app/test/test_graph.c | 10 +++++++++-
 lib/graph/node.c      |  4 ----
 2 files changed, 9 insertions(+), 5 deletions(-)
app/test/test_graph.c +9 -1
index 35e1a95b89..692360eccd 100644
@@ -545,13 +545,21 @@ test_node_clone(void)
 {
 	test_main_t *tm = &test_main;
 	uint32_t node_id, dummy_id;
+	uint32_t dummy_id_clone;
 	int i;
 
 	node_id = rte_node_from_name("test_node00");
 	tm->test_node[0].idx = node_id;
 
+#define TEST_NODE_CLONE_NAME "test_node00"
+	dummy_id_clone = rte_node_clone(node_id, TEST_NODE_CLONE_NAME);
+	if (rte_node_is_invalid(dummy_id_clone)) {
+		printf("Got invalid id when clone, Expecting fail\n");
+		return -1;
+	}
+
 	/* Clone with same name, should fail */
-	dummy_id = rte_node_clone(node_id, "test_node00");
+	dummy_id = rte_node_clone(node_id, TEST_NODE_CLONE_NAME);
 	if (!rte_node_is_invalid(dummy_id)) {
 		printf("Got valid id when clone with same name, Expecting fail\n");
 		return -1;
lib/graph/node.c +0 -4
index 79230035a2..ae6eadb260 100644
@@ -150,10 +150,6 @@ node_clone(struct node *node, const char *name)
 		goto fail;
 	}
 
-	/* Check for duplicate name */
-	if (node_has_duplicate_entry(name))
-		goto fail;
-
 	reg = calloc(1, sizeof(*reg) + (sizeof(char *) * node->nb_edges));
 	if (reg == NULL) {
 		rte_errno = ENOMEM;
Signature · 1 line
2.35.1
#2 lore raw

PATCH v3 1/1 graph: remove the useless duplicate name check

In reply to a message not in the archive

The node clone API parameter 'name' is the new node's postfix name, not the final node name, so it makes no sense to check it. And the new name will be checked duplicate when calling API '__rte_node_register'.

And update the test case to call clone API twice to check the real name duplicate.

---
v3: No need to define another node id var.
v2: update the test case.

---
 app/test/test_graph.c | 6 ++++++
 lib/graph/node.c      | 4 ----
 2 files changed, 6 insertions(+), 4 deletions(-)
app/test/test_graph.c +6 -0
index 35e1a95b89..1a2d1e6fab 100644
@@ -550,6 +550,12 @@ test_node_clone(void)
 	node_id = rte_node_from_name("test_node00");
 	tm->test_node[0].idx = node_id;
 
+	dummy_id = rte_node_clone(node_id, "test_node00");
+	if (rte_node_is_invalid(dummy_id)) {
+		printf("Got invalid id when clone, Expecting fail\n");
+		return -1;
+	}
+
 	/* Clone with same name, should fail */
 	dummy_id = rte_node_clone(node_id, "test_node00");
 	if (!rte_node_is_invalid(dummy_id)) {
lib/graph/node.c +0 -4
index 79230035a2..ae6eadb260 100644
@@ -150,10 +150,6 @@ node_clone(struct node *node, const char *name)
 		goto fail;
 	}
 
-	/* Check for duplicate name */
-	if (node_has_duplicate_entry(name))
-		goto fail;
-
 	reg = calloc(1, sizeof(*reg) + (sizeof(char *) * node->nb_edges));
 	if (reg == NULL) {
 		rte_errno = ENOMEM;
Signature · 1 line
2.35.1
Acked-by on v3 1/1
#3 lore raw
Quoted 9 lines · Haiyue Wang

The node clone API parameter 'name' is the new node's postfix name, not the final node name, so it makes no sense to check it. And the new name will be checked duplicate when calling API '__rte_node_register'.

And update the test case to call clone API twice to check the real name duplicate.

Quoted 43 lines

---
v3: No need to define another node id var.
v2: update the test case.

---
 app/test/test_graph.c | 6 ++++++
 lib/graph/node.c      | 4 ----
 2 files changed, 6 insertions(+), 4 deletions(-)
app/test/test_graph.c +6 -0
index 35e1a95b89..1a2d1e6fab 100644
@@ -550,6 +550,12 @@ test_node_clone(void)
        node_id = rte_node_from_name("test_node00");
        tm->test_node[0].idx = node_id;
 
+       dummy_id = rte_node_clone(node_id, "test_node00");
+       if (rte_node_is_invalid(dummy_id)) {
+               printf("Got invalid id when clone, Expecting fail\n");
+               return -1;
+       }
+
        /* Clone with same name, should fail */
        dummy_id = rte_node_clone(node_id, "test_node00");
        if (!rte_node_is_invalid(dummy_id)) {
lib/graph/node.c +0 -5
index 79230035a2..ae6eadb260 100644
@@ -150,10 +150,6 @@ node_clone(struct node *node, const char *name)
                goto fail;
        }
 
-       /* Check for duplicate name */
-       if (node_has_duplicate_entry(name))
-               goto fail;
-
        reg = calloc(1, sizeof(*reg) + (sizeof(char *) * node->nb_edges));
        if (reg == NULL) {
                rte_errno = ENOMEM;
--

2.35.1

#4 lore raw

07/03/2022 13:47, Jerin Jacob:

Quoted 6 lines · Haiyue Wang
Quoted 5 lines

The node clone API parameter 'name' is the new node's postfix name, not the final node name, so it makes no sense to check it. And the new name will be checked duplicate when calling API '__rte_node_register'.

Quoted 7 lines
Quoted 4 lines

And update the test case to call clone API twice to check the real name duplicate.

Applied, thanks.