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 760E943D5E; Wed, 27 Mar 2024 03:44:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37FE0402A3; Wed, 27 Mar 2024 03:44:28 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 42F134029F for ; Wed, 27 Mar 2024 03:44:26 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42R0kCJK016354; Tue, 26 Mar 2024 19:44:20 -0700 Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2040.outbound.protection.outlook.com [104.47.51.40]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3x3hy1wvjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Mar 2024 19:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D7z6aNALMddyZLvAUqnA5xXjYwosXkizIZA6LhqCu2kuVjfAXDabS4H7mLQ9ushkRniaIOMvuwFkjUAoE7FKpg5frIXFV28Jb+VpjY+n2JnzM1YML8v6cuQy1olfRGaX+kSk1qiDxfltw0IiuQRgiCerEJ/7ZJkoouEaCkID2+9vSUdAFFjR5u4tqCz6y4k/lFDwQi+nTN7iqoNRiJC1k1pyYXYx1QxP2svra30zvQlldLYE0lyXAQf31npnLvCuG+OY8BZK23fvOuz8qeDdn7ua6oXVv6kXVIzZWUHBjcnXuVrRWUQHVDkElkuMOvm+6znj7sMIlravU0ZxCV1OAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lj6eJZJ7ZtKK+6SzJ7YYNGkIZD48L5V1lbyzr8sDYgU=; b=Easj0EaKyWfq42GLphCQlEpRwBrDlmfAkdIfd+ADAGhO5CDIOPjhs7MXjOP1K/uj2kV389dkne+oIlR9LUHIaG6PlDcQKi/jG/HyoqN29vE6U+5Oj/q6g8JZRPt8r000aIKfSrNhBSd/OFWbuw55i56Pb75XURQToTlp6tgcvsYHDkkQHusGRQu7qQ2LKZX1Lg7QmN8mdPinDSVHsbchjyCReiM5qp6F1hoKVcLxOvY0yJ/eatCcRdjn1Uh8TGnEq1xGSDWsB1FwmgnL2Bp9W8NNlS9BCW3ea04CEubhe6K4Gu2icxLdwVc9bTLtZIOw7AejeLQxayg7kL70DkzXTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lj6eJZJ7ZtKK+6SzJ7YYNGkIZD48L5V1lbyzr8sDYgU=; b=Uts4zy+Ma4IU/1b8ahPHs8uuPWIdLkO6rry2QATcjGzExO/FYXqnyU1GaxInIRd06ItmYBRfNEyoQYaeHjwgsXptIfNoqx4e1gpu4gn2D3blD4FO6OhKfJBWDX6LRP3fTciwbOmS4Gom8ZqHVyhXS/F9cWG6hOiBEAxS6Vxmes8= Received: from PH0PR18MB5071.namprd18.prod.outlook.com (2603:10b6:510:16b::15) by BN9PR18MB4122.namprd18.prod.outlook.com (2603:10b6:408:133::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.33; Wed, 27 Mar 2024 02:44:17 +0000 Received: from PH0PR18MB5071.namprd18.prod.outlook.com ([fe80::b2bd:bab4:73f2:6c52]) by PH0PR18MB5071.namprd18.prod.outlook.com ([fe80::b2bd:bab4:73f2:6c52%7]) with mapi id 15.20.7409.023; Wed, 27 Mar 2024 02:44:17 +0000 From: Kiran Kumar Kokkilagadda To: Robin Jarry , "dev@dpdk.org" , Jerin Jacob , Nithin Kumar Dabilpuram , Zhirun Yan Subject: RE: [EXTERNAL] [PATCH v2] graph: avoid id collisions Thread-Topic: [EXTERNAL] [PATCH v2] graph: avoid id collisions Thread-Index: AQHaf5VEJrRd6w0zrE+W457a8fCbY7FK4fcw Date: Wed, 27 Mar 2024 02:44:17 +0000 Message-ID: References: <20240325155354.770676-2-rjarry@redhat.com> <20240326154936.1132201-1-rjarry@redhat.com> In-Reply-To: <20240326154936.1132201-1-rjarry@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR18MB5071:EE_|BN9PR18MB4122:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: umEZW2jw55M2dU/kbTOn0KVRDEjtVtDRhQh+V8zijuAsFa1EoeP4VnvTz7jeq2RPMqlGn+d2DbT7MiL2Toe/TUcsp3i6risKBlIheb9Ul8QnRiDQZTVT1ITgoUSUg1GShYNpCzTYYatWFFMDpTI4wizOMiuMn+e1v/k3gL421CjDKX5Sc05KaMho5z+OyxN/m+Tui1L6Z8TB7fQ5YLsRnHbB7t89dlPLRKm8PQ8DR1YKL6BNzXsMOTcEK8gqlrXtCTMDn1CZEBZ5VLE6FzXZqyEJmMkMWSYmkwff8iCOCC0Q53NSRVyWXmNH1qRcPeEry5wv7IoS/5JkIe59EoyN4BlFE+yQoEkovZcaI+kM9VXDT5+/c+lIxsm41Rx/pSCgQkZR+bbvDUyhpOzjdaVI37w4QUzvoYgx8rt4O+k2g8T2brRawBuDw886Ly4A2PmHdfLLh6lhIjPEyW8o//C/U2WPT6QK5ZBX2dy2aoVrn/9MaFGJrvyu2oAS0xx6BbkNGS+Aji9pzYPKV4vGujyVsyQYohFjFPzaa6oJFO1GUo2PwJsUUvrilUYe51CPUSJkFjCbHDZQ4DyFVFON+N2XYngSMEFoCvjD5Vq7D1Pupb/efh2i5dzU41+/do67l1wecFAdYKGVni9YHbEvrtFO3fDKZ2sSRLq4zy/FuDPsGdI= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR18MB5071.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(1800799015)(366007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?sM5eJb0NT/YeSQNEx7Dd7I8CRUmUPgFT+RETQdWUwLHPI8uvoz5e1s9Knu+Q?= =?us-ascii?Q?SwjiM4ZVNhMrfFn8fj8eE44bZDY7XbDU1d+eTBiiB/wG9A/cOwNCYOatUINH?= =?us-ascii?Q?rqUJag4EPrSO4pPIdwF6UMRLd+FfU3AbrXjc8sD8aLZI6iDTuJdBFkjqIW3n?= =?us-ascii?Q?ITKS8iie4qcfo0lRTxn2rhwKRK4ahJauanHOsBPzQs+ruZvQxaZvNX1cmroC?= =?us-ascii?Q?/LMwKmvYZMI2s6bpwpNn3Cz5K/NFOsnVMBHMtThD17YckWgAmXtSydnu+hna?= =?us-ascii?Q?vs1nRDjhsWlivjQZSFLoqoi1bJcFGuyTxxFdrMCZNH2EPd86YRUXOVEQHoyD?= =?us-ascii?Q?8VgljKZFMHnphTdhY1oHbAwUyvYS3szMj6zMJoKDx6S8VKZUfFgVWd5oWCyX?= =?us-ascii?Q?YpMnyyGHMgztMOn9sTyk+Oz7BEpAtRYwFsvEyLYrB35JTCoaL57aWOKOPR8n?= =?us-ascii?Q?pwoSMPYbTbJC/aUqz8rJYHk79evEK2i621gNcR+9XybqMF884ZKz7edcivXO?= =?us-ascii?Q?n8tJtkkjP9u7uGOPypWKexVh0sC38ehgQMLilnZ9V2CYU1EXV1IFxzGzUcLh?= =?us-ascii?Q?HwHCyr32/EyveuuMCpiuFXHnxuaKY2Bqupgk5iuYpH4K2rHbLGbKRJJw8xFS?= =?us-ascii?Q?wzRQUYVuwQDksZRyuq1jcVVuuI9T3Bq+E+WRXVnm2A5159/RFEZX0q6qYW78?= =?us-ascii?Q?bJ3oLo4Y/rJzYkrX7556WC2jXZWRyDt9700iJ0y8lRS7FH/15kIM9uxjttHw?= =?us-ascii?Q?9Jx1dsDZ2EvqKhDyCH7Gtjnb/acdW4O1DpdoZPqEzR9Y5JJx98sR7Su6pGc3?= =?us-ascii?Q?HTak07gzk1Ft9zSRFrp35mgo4mIsVXvKPCS756Lc2eEqIT5w5BOQOtegWqa8?= =?us-ascii?Q?6WlX4GdURLO5h8T+S4vv3/zs49SArvHJkfxJIpEwLeH4H024FIKOO3U2O4HV?= =?us-ascii?Q?KlswzA9GFK3sa3tubfWImhSdVGo8XSzWuup1r0NaY21IUDsFtE3HW87TnOY1?= =?us-ascii?Q?izk+xZjXiifp/16ZVJVBpl48cntWJENSv95mnrb94wCjr2YLsFo/aOt6lBU3?= =?us-ascii?Q?j1X5QxxJVJT/fRyq2ay7C3jG5kFug0kMdp70Mr+CgO54lKGkxcFu70Fm5QZK?= =?us-ascii?Q?w8t0e7uIjFgXnMtL3Xvk7z9rN4P1zWgjHXaYvqnqOcBalcjTw0+7ND6+FO2C?= =?us-ascii?Q?DHkhj0UFamJ2OKNO9FYOYEYOPyBpBFSmYh0sHoYgpE3iFQaYK091zOpI7hlK?= =?us-ascii?Q?Tone/YWeYNEROovu5mwKZYbj70MlqL798rnMOjbfWhlVJkLQjaBPA8pOp4Ob?= =?us-ascii?Q?UpPiOMasBX71fluBLyU4W2Wn6vz8Vf+ZwyHXxFGGs+gcmW/2vPeLftV/MdYg?= =?us-ascii?Q?DJNsarsmXKO56+cCmRMyMidIxCVVY0t2sVU+WXz1bKxIe5I7L8Af6qTh3kwr?= =?us-ascii?Q?fdTUYROQVDsMDNzYiR0C+2hA7gXWLO11HLpZ2mr/SCt5LLf3SemGWEZ7Evna?= =?us-ascii?Q?+xVVw5/OiilojjM2x+CmY3mLApKybYt4x+GLdzbA+VjE+kIXZZhQIH7pXwwY?= =?us-ascii?Q?xEkSizpOnlDibHrh92RhErN7oAAK0wLOZqeIuPYL?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR18MB5071.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5c224a7-c3a2-4ec4-6b66-08dc4e07cbf3 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Mar 2024 02:44:17.3004 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: wWZiGMPETuQ4clwQcl+BvHy27mfurc4I2zyrO9moL8L2qv8HTzB970yxI6Lf6M3QzdEd6UjDGHkt5qoLplWS5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR18MB4122 X-Proofpoint-GUID: FhoRU-rj2jC08VeNdR3xYE3O3PWbBri8 X-Proofpoint-ORIG-GUID: FhoRU-rj2jC08VeNdR3xYE3O3PWbBri8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-26_12,2024-03-21_02,2023-05-22_02 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 > -----Original Message----- > From: Robin Jarry > Sent: Tuesday, March 26, 2024 9:20 PM > To: dev@dpdk.org; Jerin Jacob ; Kiran Kumar > Kokkilagadda ; Nithin Kumar Dabilpuram > ; Zhirun Yan > Subject: [EXTERNAL] [PATCH v2] graph: avoid id collisions >=20 > Prioritize security for external emails: Confirm sender and content safet= y > before clicking links or opening attachments >=20 > ---------------------------------------------------------------------- > The graph id is determined based on a global variable that is incremented > every time a graph is created, and decremented every time a graph is > destroyed. This only works if graphs are destroyed in the reverse order i= n > which they have been created. >=20 > The following code produces duplicate graph IDs which can lead to use-aft= er- > free bugs and other undefined behaviours: >=20 > a =3D rte_graph_create(...); // id=3D0 graph_id=3D1 > b =3D rte_graph_create(...); // id=3D1 graph_id=3D2 > rte_graph_destroy(a); // graph_id=3D1 > c =3D rte_graph_create(...); // id=3D1 graph_id=3D2 (duplicate with b) > rte_graph_destroy(c); // frees memory still used by b >=20 > Remove the global counter. Make sure that the graph list is always ordere= d by > increasing graph ids. When creating a new graph, pick a free id which is = not > allocated. >=20 > Update unit tests to ensure it works as expected. >=20 > Signed-off-by: Robin Jarry > --- Acked-by: Kiran Kumar Kokkilagadda >=20 > Notes: > v2: Added unit test >=20 > app/test/test_graph.c | 63 +++++++++++++++++++++++++++++++ > lib/graph/graph.c | 86 ++++++++++++++++++++++++++++++++++--------- > 2 files changed, 132 insertions(+), 17 deletions(-) >=20 > diff --git a/app/test/test_graph.c b/app/test/test_graph.c index > b8409bc60497..c650ac4f57b7 100644 > --- a/app/test/test_graph.c > +++ b/app/test/test_graph.c > @@ -696,6 +696,68 @@ test_graph_clone(void) > return ret; > } >=20 > +static int > +test_graph_id_collisions(void) > +{ > + static const char *node_patterns[] =3D {"test_node_source1", > "test_node00"}; > + struct rte_graph_param gconf =3D { > + .socket_id =3D SOCKET_ID_ANY, > + .nb_node_patterns =3D 2, > + .node_patterns =3D node_patterns, > + }; > + rte_graph_t g1, g2, g3; > + > + g1 =3D rte_graph_create("worker1", &gconf); > + if (g1 =3D=3D RTE_GRAPH_ID_INVALID) { > + printf("Graph 1 creation failed with error =3D %d\n", rte_errno); > + return -1; > + } > + g2 =3D rte_graph_create("worker2", &gconf); > + if (g2 =3D=3D RTE_GRAPH_ID_INVALID) { > + printf("Graph 2 creation failed with error =3D %d\n", rte_errno); > + return -1; > + } > + if (g1 =3D=3D g2) { > + printf("Graph ids should be different\n"); > + return -1; > + } > + if (rte_graph_destroy(g1) < 0) { > + printf("Graph 1 suppression failed\n"); > + return -1; > + } > + g3 =3D rte_graph_create("worker3", &gconf); > + if (g3 =3D=3D RTE_GRAPH_ID_INVALID) { > + printf("Graph 3 creation failed with error =3D %d\n", rte_errno); > + return -1; > + } > + if (g3 =3D=3D g2) { > + printf("Graph ids should be different\n"); > + return -1; > + } > + g1 =3D rte_graph_clone(g2, "worker1", &gconf); > + if (g1 =3D=3D RTE_GRAPH_ID_INVALID) { > + printf("Graph 2 clone failed with error =3D %d\n", rte_errno); > + return -1; > + } > + if (g1 =3D=3D g2 || g2 =3D=3D g3 || g1 =3D=3D g3) { > + printf("Graph ids should be different\n"); > + return -1; > + } > + if (rte_graph_destroy(g1) < 0) { > + printf("Graph 1 suppression failed\n"); > + return -1; > + } > + if (rte_graph_destroy(g2) < 0) { > + printf("Graph 2 suppression failed\n"); > + return -1; > + } > + if (rte_graph_destroy(g3) < 0) { > + printf("Graph 3 suppression failed\n"); > + return -1; > + } > + return 0; > +} > + > static int > test_graph_model_mcore_dispatch_node_lcore_affinity_set(void) > { > @@ -977,6 +1039,7 @@ static struct unit_test_suite graph_testsuite =3D { > TEST_CASE(test_lookup_functions), > TEST_CASE(test_create_graph), > TEST_CASE(test_graph_clone), > + TEST_CASE(test_graph_id_collisions), >=20 > TEST_CASE(test_graph_model_mcore_dispatch_node_lcore_affinity_s > et), >=20 > TEST_CASE(test_graph_model_mcore_dispatch_core_bind_unbind), > TEST_CASE(test_graph_worker_model_set_get), > diff --git a/lib/graph/graph.c b/lib/graph/graph.c index > 147bc6c685c5..50616580d06b 100644 > --- a/lib/graph/graph.c > +++ b/lib/graph/graph.c > @@ -19,11 +19,54 @@ >=20 > static struct graph_head graph_list =3D STAILQ_HEAD_INITIALIZER(graph_li= st); > static rte_spinlock_t graph_lock =3D RTE_SPINLOCK_INITIALIZER; -static > rte_graph_t graph_id; > - > -#define GRAPH_ID_CHECK(id) ID_CHECK(id, graph_id) >=20 > /* Private functions */ > +static struct graph * > +graph_from_id(rte_graph_t id) > +{ > + struct graph *graph; > + STAILQ_FOREACH(graph, &graph_list, next) { > + if (graph->id =3D=3D id) > + return graph; > + } > + rte_errno =3D EINVAL; > + return NULL; > +} > + > +static rte_graph_t > +graph_next_free_id(void) > +{ > + struct graph *graph; > + rte_graph_t id =3D 0; > + > + STAILQ_FOREACH(graph, &graph_list, next) { > + if (id < graph->id) > + break; > + id =3D graph->id + 1; > + } > + > + return id; > +} > + > +static void > +graph_insert_ordered(struct graph *graph) { > + struct graph *after, *g; > + > + after =3D NULL; > + STAILQ_FOREACH(g, &graph_list, next) { > + if (g->id < graph->id) { > + after =3D g; > + break; > + } > + } > + if (after =3D=3D NULL) { > + STAILQ_INSERT_TAIL(&graph_list, graph, next); > + } else { > + STAILQ_INSERT_AFTER(&graph_list, after, graph, next); > + } > +} > + > struct graph_head * > graph_list_head_get(void) > { > @@ -279,7 +322,8 @@ > rte_graph_model_mcore_dispatch_core_bind(rte_graph_t id, int lcore) { > struct graph *graph; >=20 > - GRAPH_ID_CHECK(id); > + if (graph_from_id(id) =3D=3D NULL) > + goto fail; > if (!rte_lcore_is_enabled(lcore)) > SET_ERR_JMP(ENOLINK, fail, "lcore %d not enabled", lcore); >=20 > @@ -309,7 +353,8 @@ > rte_graph_model_mcore_dispatch_core_unbind(rte_graph_t id) { > struct graph *graph; >=20 > - GRAPH_ID_CHECK(id); > + if (graph_from_id(id) =3D=3D NULL) > + goto fail; > STAILQ_FOREACH(graph, &graph_list, next) > if (graph->id =3D=3D id) > break; > @@ -406,7 +451,7 @@ rte_graph_create(const char *name, struct > rte_graph_param *prm) > graph->socket =3D prm->socket_id; > graph->src_node_count =3D src_node_count; > graph->node_count =3D graph_nodes_count(graph); > - graph->id =3D graph_id; > + graph->id =3D graph_next_free_id(); > graph->parent_id =3D RTE_GRAPH_ID_INVALID; > graph->lcore_id =3D RTE_MAX_LCORE; > graph->num_pkt_to_capture =3D prm->num_pkt_to_capture; @@ - > 422,8 +467,7 @@ rte_graph_create(const char *name, struct > rte_graph_param *prm) > goto graph_mem_destroy; >=20 > /* All good, Lets add the graph to the list */ > - graph_id++; > - STAILQ_INSERT_TAIL(&graph_list, graph, next); > + graph_insert_ordered(graph); >=20 > graph_spinlock_unlock(); > return graph->id; > @@ -467,7 +511,6 @@ rte_graph_destroy(rte_graph_t id) > graph_cleanup(graph); > STAILQ_REMOVE(&graph_list, graph, graph, next); > free(graph); > - graph_id--; > goto done; > } > graph =3D tmp; > @@ -520,7 +563,7 @@ graph_clone(struct graph *parent_graph, const char > *name, struct rte_graph_param > graph->parent_id =3D parent_graph->id; > graph->lcore_id =3D parent_graph->lcore_id; > graph->socket =3D parent_graph->socket; > - graph->id =3D graph_id; > + graph->id =3D graph_next_free_id(); >=20 > /* Allocate the Graph fast path memory and populate the data */ > if (graph_fp_mem_create(graph)) > @@ -539,8 +582,7 @@ graph_clone(struct graph *parent_graph, const char > *name, struct rte_graph_param > goto graph_mem_destroy; >=20 > /* All good, Lets add the graph to the list */ > - graph_id++; > - STAILQ_INSERT_TAIL(&graph_list, graph, next); > + graph_insert_ordered(graph); >=20 > graph_spinlock_unlock(); > return graph->id; > @@ -561,7 +603,8 @@ rte_graph_clone(rte_graph_t id, const char *name, > struct rte_graph_param *prm) { > struct graph *graph; >=20 > - GRAPH_ID_CHECK(id); > + if (graph_from_id(id) =3D=3D NULL) > + goto fail; > STAILQ_FOREACH(graph, &graph_list, next) > if (graph->id =3D=3D id) > return graph_clone(graph, name, prm); @@ -587,7 > +630,8 @@ rte_graph_id_to_name(rte_graph_t id) { > struct graph *graph; >=20 > - GRAPH_ID_CHECK(id); > + if (graph_from_id(id) =3D=3D NULL) > + goto fail; > STAILQ_FOREACH(graph, &graph_list, next) > if (graph->id =3D=3D id) > return graph->name; > @@ -604,7 +648,8 @@ rte_graph_node_get(rte_graph_t gid, uint32_t nid) > rte_graph_off_t off; > rte_node_t count; >=20 > - GRAPH_ID_CHECK(gid); > + if (graph_from_id(gid) =3D=3D NULL) > + goto fail; > STAILQ_FOREACH(graph, &graph_list, next) > if (graph->id =3D=3D gid) { > rte_graph_foreach_node(count, off, graph->graph, > @@ -747,7 +792,8 @@ graph_scan_dump(FILE *f, rte_graph_t id, bool all) > struct graph *graph; >=20 > RTE_VERIFY(f); > - GRAPH_ID_CHECK(id); > + if (graph_from_id(id) =3D=3D NULL) > + goto fail; >=20 > STAILQ_FOREACH(graph, &graph_list, next) { > if (all =3D=3D true) { > @@ -776,7 +822,13 @@ rte_graph_list_dump(FILE *f) rte_graph_t > rte_graph_max_count(void) > { > - return graph_id; > + struct graph *graph; > + rte_graph_t count =3D 0; > + > + STAILQ_FOREACH(graph, &graph_list, next) > + count++; > + > + return count; > } >=20 > RTE_LOG_REGISTER_DEFAULT(rte_graph_logtype, INFO); > -- > 2.44.0