lib: fix mempool name prefixes
PATCH 1/1 lib: fix mempool name prefixes
The RIB library named the mempool holding its nodes "MP_<name>". That prefix is the one the mempool library itself prepends to the backing memzone, so the memzone ended up named "MP_MP_<name>" which is improper.
The FIB library passed its own name unchanged to the underlying RIB and did not add a prefix to the RIB name.
This patch makes name each object after its owner.
The node mempool of a RIB is now "RIB_<name>" or "RIB6_<name>", and the RIB owned by a FIB is now "FIB_<name>" or "FIB6_<name>".
A mempool name is limited to RTE_MEMPOOL_NAMESIZE, which is much shorter than RTE_RIB_NAMESIZE.
The name was passed down silently and an oversized one surfaced as an opaque rte_mempool_create() failure, so check the derived name up front and return ENAMETOOLONG instead. B
ecause the prefixes now stack, a name is limited to 21 characters for a RIB, 20 for a RIB6, 17 for a FIB and 15 for a FIB6. Hence, shortening the names used by the graph nodes, the l3fwd example and the unit tests accordingly.
Bugzilla ID: 1981 1982
--- app/test/test_fib.c | 34 ++++++++++----------- app/test/test_fib6.c | 42 +++++++++++++------------- doc/guides/rel_notes/release_26_11.rst | 5 +++ examples/l3fwd/l3fwd_fib.c | 4 +-- lib/fib/rte_fib.c | 11 +++++-- lib/fib/rte_fib6.c | 11 +++++-- lib/node/ip4_lookup_fib.c | 4 +-- lib/node/ip6_lookup_fib.c | 4 +-- lib/rib/rte_rib.c | 14 +++++++-- lib/rib/rte_rib6.c | 14 +++++++-- 10 files changed, 89 insertions(+), 54 deletions(-)
app/test/test_fib.c +17 -17
@@ -49,24 +49,24 @@ test_create_invalid(void) "Call succeeded with invalid parameters\n");/* rte_fib_create: config == NULL */ - fib =rte_fib_create (__func__,SOCKET_ID_ANY ,NULL ); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY ,NULL );RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" );/* socket_id < -1 is invalid */ - fib =rte_fib_create (__func__,-2 , &config); + fib =rte_fib_create ("test_create_inv" ,-2 , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" );/* rte_fib_create: max_routes = 0 */ config.max_routes =0 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" ); config.max_routes =MAX_ROUTES ; config.type =RTE_FIB_DIR24_8 +1 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" );
@@ -74,13 +74,13 @@ test_create_invalid(void) config.dir24_8.num_tbl8 =MAX_TBL8 ; config.dir24_8.nh_sz =RTE_FIB_DIR24_8_8B +1 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" ); config.dir24_8.nh_sz =RTE_FIB_DIR24_8_8B ; config.dir24_8.num_tbl8 =0 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" );
@@ -104,7 +104,7 @@ test_multiple_create(void)for (i =0 ; i <100 ; i++) { config.max_routes =MAX_ROUTES - i; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_mult_create" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );rte_fib_free (fib); }
@@ -129,7 +129,7 @@ test_free_null(void) config.default_nh =0 ; config.type =RTE_FIB_DUMMY ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_free_null" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );rte_fib_free (fib);
@@ -167,7 +167,7 @@ test_add_del_invalid(void) "Call succeeded with invalid parameters\n");/*Create valid fib to use in rest of test. */ - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_add_del_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );/* rte_fib_add: depth > RTE_FIB_MAXDEPTH */
@@ -331,7 +331,7 @@ test_lookup(void) config.default_nh = def_nh; config.type =RTE_FIB_DUMMY ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -342,7 +342,7 @@ test_lookup(void) config.dir24_8.nh_sz =RTE_FIB_DIR24_8_1B ; config.dir24_8.num_tbl8 =127 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -351,7 +351,7 @@ test_lookup(void) config.dir24_8.nh_sz =RTE_FIB_DIR24_8_2B ; config.dir24_8.num_tbl8 =MAX_TBL8 -1 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -360,7 +360,7 @@ test_lookup(void) 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); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -369,7 +369,7 @@ test_lookup(void) config.dir24_8.nh_sz =RTE_FIB_DIR24_8_8B ; config.dir24_8.num_tbl8 =MAX_TBL8 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -401,7 +401,7 @@ test_invalid_rcu(void) config.rib_ext_sz =0 ; config.default_nh = def_nh; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_invalid_rcu" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );/* Create RCU QSBR variable */
@@ -426,7 +426,7 @@ test_invalid_rcu(void) 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); + fib =rte_fib_create ("test_invalid_rcu" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );/* Call rte_fib_rcu_qsbr_add without fib or config */
@@ -532,7 +532,7 @@ test_fib_rcu_sync_rw(void) config.dir24_8.nh_sz =RTE_FIB_DIR24_8_4B ; config.dir24_8.num_tbl8 =1 ; - g_fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + g_fib =rte_fib_create ("test_rcu_sync_rw" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (g_fib !=NULL ,"Failed to create FIB\n" );/* Create RCU QSBR variable */
app/test/test_fib6.c +21 -21
163 lines not on this page · raw message
doc/guides/rel_notes/release_26_11.rst +5 -0
@@ -93,6 +93,11 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* rib: The node mempool created by ``rte_rib_create()`` and ``rte_rib6_create()`` + is now named ``RIB_<name>`` and ``RIB6_<name>`` instead of ``MP_<name>``. + +* fib: The RIB created by ``rte_fib_create()`` and ``rte_fib6_create()`` + is now named ``FIB_<name>`` and ``FIB6_<name>``. ABI Changes -----------
examples/l3fwd/l3fwd_fib.c +2 -2
@@ -654,7 +654,7 @@ setup_fib(const int socketid) config_ipv4.default_nh =FIB_DEFAULT_HOP ; config_ipv4.dir24_8.nh_sz =RTE_FIB_DIR24_8_4B ; config_ipv4.dir24_8.num_tbl8 = (1 <<15 ); -snprintf (s,sizeof (s),"IPV4_L3FWD_FIB_%d" , socketid); +snprintf (s,sizeof (s),"L3FWD_FIB_%d" , socketid); ipv4_l3fwd_fib_lookup_struct[socketid] =rte_fib_create (s, socketid, &config_ipv4);if (ipv4_l3fwd_fib_lookup_struct[socketid] ==NULL )
@@ -705,7 +705,7 @@ setup_fib(const int socketid)/* >8 End of setup fib. */ /* Create the fib IPv6 table. */ -snprintf (s,sizeof (s),"IPV6_L3FWD_FIB_%d" , socketid); +snprintf (s,sizeof (s),"L3FWD_FIB6_%d" , socketid); config.type =RTE_FIB6_TRIE ; config.max_routes = (1 <<16 ) -1 ;
lib/fib/rte_fib.c +8 -3
@@ -37,6 +37,9 @@ EAL_REGISTER_TAILQ(rte_fib_tailq)#define FIB_RETURN_IF_TRUE (cond, retval)#endif +/* Prefix used for the memory objects owned by a FIB. */ +#define FIB_MEM_PREFIX "FIB_" +struct rte_fib {char name[RTE_FIB_NAMESIZE ];enum rte_fib_type type;/**< Type of FIB struct */
@@ -173,14 +176,16 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) rib_conf.ext_sz = conf->rib_ext_sz; rib_conf.max_nodes = conf->max_routes *2 ; - rib =rte_rib_create (name, socket_id, &rib_conf); +/* Add FIB Prefix to its mempool name */ +snprintf (mem_name,sizeof (mem_name),FIB_MEM_PREFIX "%s" , name); + + rib =rte_rib_create (mem_name, socket_id, &rib_conf);if (rib ==NULL ) {FIB_LOG (ERR , -"Can not allocate RIB %s" , name); +"Can not allocate RIB %s" , mem_name);return NULL ; } -snprintf (mem_name,sizeof (mem_name),"FIB_%s" , name); fib_list =RTE_TAILQ_CAST (rte_fib_tailq.head, rte_fib_list);rte_mcfg_tailq_write_lock ();
lib/fib/rte_fib6.c +8 -3
@@ -37,6 +37,9 @@ EAL_REGISTER_TAILQ(rte_fib6_tailq)#define FIB6_RETURN_IF_TRUE (cond, retval)#endif +/* Prefix used for the memory objects owned by a FIB6. */ +#define FIB6_MEM_PREFIX "FIB6_" +struct rte_fib6 {char name[RTE_FIB6_NAMESIZE ];enum rte_fib6_type type;/**< Type of FIB struct */
@@ -172,14 +175,16 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) rib_conf.ext_sz = conf->rib_ext_sz; rib_conf.max_nodes = conf->max_routes *2 ; - rib =rte_rib6_create (name, socket_id, &rib_conf); +/* Add FIB6 Prefix to its mempool name */ +snprintf (mem_name,sizeof (mem_name),FIB6_MEM_PREFIX "%s" , name); + + rib =rte_rib6_create (mem_name, socket_id, &rib_conf);if (rib ==NULL ) {FIB_LOG (ERR , -"Can not allocate RIB %s" , name); +"Can not allocate RIB %s" , mem_name);return NULL ; } -snprintf (mem_name,sizeof (mem_name),"FIB6_%s" , name); fib_list =RTE_TAILQ_CAST (rte_fib6_tailq.head, rte_fib6_list);rte_mcfg_tailq_write_lock ();
lib/node/ip4_lookup_fib.c +2 -2
@@ -205,7 +205,7 @@ rte_node_ip4_fib_create(int socket, struct rte_fib_conf *conf)return 0 ; conf->default_nh =FIB_DEFAULT_NH ; -snprintf (s,sizeof (s),"IPV4_LOOKUP_FIB_%d" , socket); +snprintf (s,sizeof (s),"IP4_FIB_%d" , socket); nm->fib[socket] =rte_fib_create (s, socket, conf);if (nm->fib[socket] ==NULL )return -rte_errno;
@@ -266,7 +266,7 @@ setup_fib(int socket) conf.dir24_8.nh_sz =RTE_FIB_DIR24_8_4B ; conf.dir24_8.num_tbl8 =FIB_DEFAULT_NUM_TBL8 ; conf.flags =0 ; -snprintf (s,sizeof (s),"IPV4_LOOKUP_FIB_%d" , socket); +snprintf (s,sizeof (s),"IP4_FIB_%d" , socket); nm->fib[socket] =rte_fib_create (s, socket, &conf);if (nm->fib[socket] ==NULL )return -rte_errno;
lib/node/ip6_lookup_fib.c +2 -2
@@ -199,7 +199,7 @@ rte_node_ip6_fib_create(int socket, struct rte_fib6_conf *conf)return 0 ; conf->default_nh =FIB6_DEFAULT_NH ; -snprintf (s,sizeof (s),"IPV6_LOOKUP_FIB_%u" , socket); +snprintf (s,sizeof (s),"IP6_FIB_%u" , socket); nm->fib6[socket] =rte_fib6_create (s, socket, conf);if (nm->fib6[socket] ==NULL )return -rte_errno;
@@ -257,7 +257,7 @@ setup_fib6(int socket) conf.rib_ext_sz =0 ; conf.trie.nh_sz =RTE_FIB6_TRIE_4B ; conf.trie.num_tbl8 =FIB6_DEFAULT_NUM_TBL8 ; -snprintf (s,sizeof (s),"IPV6_LOOKUP_FIB_%u" , socket); +snprintf (s,sizeof (s),"IP6_FIB_%u" , socket); nm->fib6[socket] =rte_fib6_create (s, socket, &conf);if (nm->fib6[socket] ==NULL )return -rte_errno;
lib/rib/rte_rib.c +12 -2
@@ -32,6 +32,8 @@ EAL_REGISTER_TAILQ(rte_rib_tailq)#define RIB_MAXDEPTH 32/* Maximum length of a RIB name. */ #define RTE_RIB_NAMESIZE 64 +/* Prefix used for the memory objects owned by a RIB. */ +#define RIB_MEM_PREFIX "RIB_"struct rte_rib_node {struct rte_rib_node *left;
@@ -417,6 +419,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)struct rte_tailq_entry *te;struct rte_rib_list *rib_list;struct rte_mempool *node_pool; +int ret;/* Check user arguments. */ if (unlikely (name ==NULL || conf ==NULL || conf->max_nodes <=0 )) {
@@ -424,7 +427,15 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)return NULL ; } -snprintf (mem_name,sizeof (mem_name),"MP_%s" , name); +/* Add RIB Prefix to its node mempool name */ + ret =snprintf (mem_name,sizeof (mem_name),RIB_MEM_PREFIX "%s" , name); +if (unlikely (ret <0 || ret >= (int )RTE_MEMPOOL_NAMESIZE )) { +RIB_LOG (ERR ,"RIB name %s is too long, limit is %zu characters" , + name,RTE_MEMPOOL_NAMESIZE -sizeof (RIB_MEM_PREFIX )); + rte_errno =ENAMETOOLONG ; +return NULL ; + } + node_pool =rte_mempool_create (mem_name, conf->max_nodes,sizeof (struct rte_rib_node ) + conf->ext_sz,0 ,0 ,NULL ,NULL ,NULL ,NULL , socket_id,0 );
@@ -435,7 +446,6 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)return NULL ; } -snprintf (mem_name,sizeof (mem_name),"RIB_%s" , name); rib_list =RTE_TAILQ_CAST (rte_rib_tailq.head, rte_rib_list);rte_mcfg_tailq_write_lock ();
lib/rib/rte_rib6.c +12 -2
@@ -24,6 +24,8 @@#define RTE_RIB_VALID_NODE 1/* Maximum length of a RIB6 name. */ #define RTE_RIB6_NAMESIZE 64 +/* Prefix used for the memory objects owned by a RIB6. */ +#define RIB6_MEM_PREFIX "RIB6_"TAILQ_HEAD (rte_rib6_list, rte_tailq_entry);static struct rte_tailq_elem rte_rib6_tailq = {
@@ -480,6 +482,7 @@ rte_rib6_create(const char *name, int socket_id,struct rte_tailq_entry *te;struct rte_rib6_list *rib6_list;struct rte_mempool *node_pool; +int ret;/* Check user arguments. */ if (unlikely (name ==NULL || conf ==NULL || conf->max_nodes <=0 )) {
@@ -487,7 +490,15 @@ rte_rib6_create(const char *name, int socket_id,return NULL ; } -snprintf (mem_name,sizeof (mem_name),"MP_%s" , name); +/* Add RIB6 Prefix to its node mempool name */ + ret =snprintf (mem_name,sizeof (mem_name),RIB6_MEM_PREFIX "%s" , name); +if (unlikely (ret <0 || ret >= (int )RTE_MEMPOOL_NAMESIZE )) { +RIB_LOG (ERR ,"RIB6 name %s is too long, limit is %zu characters" , + name,RTE_MEMPOOL_NAMESIZE -sizeof (RIB6_MEM_PREFIX )); + rte_errno =ENAMETOOLONG ; +return NULL ; + } + node_pool =rte_mempool_create (mem_name, conf->max_nodes,sizeof (struct rte_rib6_node ) + conf->ext_sz,0 ,0 ,NULL ,NULL ,NULL ,NULL , socket_id,0 );
@@ -498,7 +509,6 @@ rte_rib6_create(const char *name, int socket_id,return NULL ; } -snprintf (mem_name,sizeof (mem_name),"RIB6_%s" , name); rib6_list =RTE_TAILQ_CAST (rte_rib6_tailq.head, rte_rib6_list);rte_mcfg_tailq_write_lock ();
Signature · 1 line
2.34.1
Quoted 25 lines
From: Anurag Mandal [mailto:[email protected]]
Sent: Wednesday, 12 August 2026 13.03The RIB library named the mempool holding its nodes "MP_<name>". That prefix is the one the mempool library itself prepends to the backing memzone, so the memzone ended up named "MP_MP_<name>" which is improper.
The FIB library passed its own name unchanged to the underlying RIB and did not add a prefix to the RIB name.
This patch makes name each object after its owner.
The node mempool of a RIB is now "RIB_<name>" or "RIB6_<name>", and the RIB owned by a FIB is now "FIB_<name>" or "FIB6_<name>".A mempool name is limited to
RTE_MEMPOOL_NAMESIZE, which is much shorter thanRTE_RIB_NAMESIZE.
The name was passed down silently and an oversized one surfaced as an opaquerte_mempool_create()failure, so check the derived name up front and return ENAMETOOLONG instead. B
ecause the prefixes now stack, a name is limited to 21 characters for a RIB, 20 for a RIB6, 17 for a FIB and 15 for a FIB6. Hence, shortening the names used by the graph nodes, the l3fwd example and the unit tests accordingly.
Quoted 5 lines
Bugzilla ID: 1981 1982
Fixes 5a5793a5ffa2 ("rib: add RIB library")Fixes f7e861e21c46 ("rib: support IPv6")Fixes 39e927248416 ("fib: add FIB library")Fixes 40d41a8a7b34 ("fib: support IPv6")
This patch reduces how long a FIB/RIB name can be, which is an API break. I don't think it should be backported.
Quoted 3 lines
Signed-off-by Anurag Mandal <[email protected]>---
Some comments inline below.
With those comments addressed,
[...]
Quoted 15 lines
doc/guides/rel_notes/release_26_11.rst +1
-0@@ -93,6 +93,11 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* rib: The node mempool created by ``rte_rib_create()`` and``rte_rib6_create()``
+ is now named ``RIB_<name>`` and ``RIB6_<name>`` instead of ``MP_<name>``.doc/guides/rel_notes/release_26_11.rst +2
-0+ +* fib: The RIB created by ``rte_fib_create()`` and
Quoted 2 lines
``rte_fib6_create()``
+ is now named ``FIB_<name>`` and ``FIB6_<name>``.
Please mention in the release notes how long the RIB, RIB6, FIB and FIB6 names are now allowed to be.
[...]
Quoted 15 lines
lib/fib/rte_fib.c +3
-0@@ -37,6 +37,9 @@ EAL_REGISTER_TAILQ(rte_fib_tailq)#define FIB_RETURN_IF_TRUE (cond, retval)#endif +/* Prefix used for the memory objects owned by a FIB. */ +#define FIB_MEM_PREFIX "FIB_" +struct rte_fib {char name[RTE_FIB_NAMESIZE ];enum rte_fib_type type;/**< Type of FIB struct */
lib/fib/rte_fib.c rte_fib_create(const char *name, int socket_id, · line 181
Quoted 7 lines
lib/fib/rte_fib.c +2
-1@@ -173,14 +176,16 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) rib_conf.ext_sz = conf->rib_ext_sz; rib_conf.max_nodes = conf->max_routes *2 ; - rib =rte_rib_create (name, socket_id, &rib_conf); +/* Add FIB Prefix to its mempool name */ +snprintf (mem_name,sizeof (mem_name),FIB_MEM_PREFIX "%s" , name);
Please add check for snprintf() return value, to ensure mem_name has 0-termination at the end. Something like (untested):
ret = snprintf(mem_name, sizeof(mem_name), FIB_MEM_PREFIX "%s", name);
if (unlikely(ret < 0 || ret >= sizeof(mem_name))) {
rte_errno = ENAMETOOLONG;
return NULL;
}This check was already missing, so adding it is an improvement.
Quoted 28 lines
lib/fib/rte_fib.c +3
-2+ + rib =rte_rib_create (mem_name, socket_id, &rib_conf);if (rib ==NULL ) {FIB_LOG (ERR , -"Can not allocate RIB %s" , name); +"Can not allocate RIB %s" , mem_name);return NULL ; } -snprintf (mem_name,sizeof (mem_name),"FIB_%s" , name); fib_list =RTE_TAILQ_CAST (rte_fib_tailq.head, rte_fib_list);lib/fib/rte_fib.c +0
-0rte_mcfg_tailq_write_lock ();lib/fib/rte_fib6.c +3
-0@@ -37,6 +37,9 @@ EAL_REGISTER_TAILQ(rte_fib6_tailq)#define FIB6_RETURN_IF_TRUE (cond, retval)#endif +/* Prefix used for the memory objects owned by a FIB6. */ +#define FIB6_MEM_PREFIX "FIB6_" +struct rte_fib6 {char name[RTE_FIB6_NAMESIZE ];enum rte_fib6_type type;/**< Type of FIB struct */
lib/fib/rte_fib6.c rte_fib6_create(const char *name, int socket_id, · line 180
Quoted 7 lines
lib/fib/rte_fib6.c +2
-1@@ -172,14 +175,16 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) rib_conf.ext_sz = conf->rib_ext_sz; rib_conf.max_nodes = conf->max_routes *2 ; - rib =rte_rib6_create (name, socket_id, &rib_conf); +/* Add FIB6 Prefix to its mempool name */ +snprintf (mem_name,sizeof (mem_name),FIB6_MEM_PREFIX "%s" , name);
Also here:
Please add check for snprintf() return value, to ensure mem_name has 0-termination at the end.
Quoted 1 line
Subject: [PATCH] lib: fix mempool name prefixes
The title could probably be improved...
Something like:
fib & rib: fix name prefixes
PATCH v2 1/1 fib, rib: fix name prefixes
In reply to Anurag MandalThe RIB library named the mempool holding its nodes "MP_<name>". That prefix is the one the mempool library itself prepends to the backing memzone, so the memzone ended up named "MP_MP_<name>" which is improper.
The FIB library passed its own name unchanged to the underlying RIB and did not add a prefix to the RIB name.
This patch makes name each object after its owner.
The node mempool of a RIB is now "RIB_<name>" or "RIB6_<name>", and the RIB owned by a FIB is now "FIB_<name>" or "FIB6_<name>".
A mempool name is limited to RTE_MEMPOOL_NAMESIZE, which is much shorter than RTE_RIB_NAMESIZE.
The name was passed down silently and an oversized one surfaced as an opaque rte_mempool_create() failure, so check the derived name up front and return ENAMETOOLONG instead.
As the prefixes above are added on top of the name, the new maximum length of a name is limited to the following:
RIB : 21 characters
RIB6: 20 characters
FIB : 17 characters
FIB6: 15 characters
Hence, shortening the names used by the graph nodes, the l3fwd example and the unit tests accordingly.
Bugzilla ID: 1981 1982
---
V2: Addressed Morten Brørup's review comments
app/test/test_fib.c | 34 ++++++++++----------- app/test/test_fib6.c | 42 +++++++++++++------------- doc/guides/rel_notes/release_26_11.rst | 14 +++++++++ examples/l3fwd/l3fwd_fib.c | 4 +-- lib/fib/rte_fib.c | 16 ++++++++-- lib/fib/rte_fib6.c | 16 ++++++++-- lib/node/ip4_lookup_fib.c | 4 +-- lib/node/ip6_lookup_fib.c | 4 +-- lib/rib/rte_rib.c | 14 +++++++-- lib/rib/rte_rib6.c | 14 +++++++-- 10 files changed, 108 insertions(+), 54 deletions(-)
app/test/test_fib.c +17 -17
@@ -49,24 +49,24 @@ test_create_invalid(void) "Call succeeded with invalid parameters\n");/* rte_fib_create: config == NULL */ - fib =rte_fib_create (__func__,SOCKET_ID_ANY ,NULL ); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY ,NULL );RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" );/* socket_id < -1 is invalid */ - fib =rte_fib_create (__func__,-2 , &config); + fib =rte_fib_create ("test_create_inv" ,-2 , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" );/* rte_fib_create: max_routes = 0 */ config.max_routes =0 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" ); config.max_routes =MAX_ROUTES ; config.type =RTE_FIB_DIR24_8 +1 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" );
@@ -74,13 +74,13 @@ test_create_invalid(void) config.dir24_8.num_tbl8 =MAX_TBL8 ; config.dir24_8.nh_sz =RTE_FIB_DIR24_8_8B +1 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" ); config.dir24_8.nh_sz =RTE_FIB_DIR24_8_8B ; config.dir24_8.num_tbl8 =0 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_create_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib ==NULL ,"Call succeeded with invalid parameters\n" );
@@ -104,7 +104,7 @@ test_multiple_create(void)for (i =0 ; i <100 ; i++) { config.max_routes =MAX_ROUTES - i; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_mult_create" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );rte_fib_free (fib); }
@@ -129,7 +129,7 @@ test_free_null(void) config.default_nh =0 ; config.type =RTE_FIB_DUMMY ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_free_null" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );rte_fib_free (fib);
@@ -167,7 +167,7 @@ test_add_del_invalid(void) "Call succeeded with invalid parameters\n");/*Create valid fib to use in rest of test. */ - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_add_del_inv" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );/* rte_fib_add: depth > RTE_FIB_MAXDEPTH */
@@ -331,7 +331,7 @@ test_lookup(void) config.default_nh = def_nh; config.type =RTE_FIB_DUMMY ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -342,7 +342,7 @@ test_lookup(void) config.dir24_8.nh_sz =RTE_FIB_DIR24_8_1B ; config.dir24_8.num_tbl8 =127 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -351,7 +351,7 @@ test_lookup(void) config.dir24_8.nh_sz =RTE_FIB_DIR24_8_2B ; config.dir24_8.num_tbl8 =MAX_TBL8 -1 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -360,7 +360,7 @@ test_lookup(void) 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); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -369,7 +369,7 @@ test_lookup(void) config.dir24_8.nh_sz =RTE_FIB_DIR24_8_8B ; config.dir24_8.num_tbl8 =MAX_TBL8 ; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_lookup" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" ); ret =check_fib (fib); RTE_TEST_ASSERT(ret == TEST_SUCCESS,
@@ -401,7 +401,7 @@ test_invalid_rcu(void) config.rib_ext_sz =0 ; config.default_nh = def_nh; - fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + fib =rte_fib_create ("test_invalid_rcu" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );/* Create RCU QSBR variable */
@@ -426,7 +426,7 @@ test_invalid_rcu(void) 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); + fib =rte_fib_create ("test_invalid_rcu" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (fib !=NULL ,"Failed to create FIB\n" );/* Call rte_fib_rcu_qsbr_add without fib or config */
@@ -532,7 +532,7 @@ test_fib_rcu_sync_rw(void) config.dir24_8.nh_sz =RTE_FIB_DIR24_8_4B ; config.dir24_8.num_tbl8 =1 ; - g_fib =rte_fib_create (__func__,SOCKET_ID_ANY , &config); + g_fib =rte_fib_create ("test_rcu_sync_rw" ,SOCKET_ID_ANY , &config);RTE_TEST_ASSERT (g_fib !=NULL ,"Failed to create FIB\n" );/* Create RCU QSBR variable */
app/test/test_fib6.c +21 -21
163 lines not on this page · raw message
doc/guides/rel_notes/release_26_11.rst +14 -0
@@ -93,6 +93,20 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* rib: The node mempool created by ``rte_rib_create()`` and ``rte_rib6_create()`` + is now named ``RIB_<name>`` and ``RIB6_<name>`` instead of ``MP_<name>``. + +* fib: The RIB created by ``rte_fib_create()`` and ``rte_fib6_create()`` + is now named ``FIB_<name>`` and ``FIB6_<name>``. + +* rib, fib: The name of a RIB, RIB6, FIB or FIB6 is used to derive the name of + its node mempool, which is bounded by ``RTE_MEMPOOL_NAMESIZE``. + As the prefixes above are added on top of the name,the new maximum length of + a name are the following: + RIB - 21 characters. + RIB6 - 20 characters. + FIB - 17 characters. + FIB6 - 15 characters. ABI Changes -----------
examples/l3fwd/l3fwd_fib.c +2 -2
@@ -654,7 +654,7 @@ setup_fib(const int socketid) config_ipv4.default_nh =FIB_DEFAULT_HOP ; config_ipv4.dir24_8.nh_sz =RTE_FIB_DIR24_8_4B ; config_ipv4.dir24_8.num_tbl8 = (1 <<15 ); -snprintf (s,sizeof (s),"IPV4_L3FWD_FIB_%d" , socketid); +snprintf (s,sizeof (s),"L3FWD_FIB_%d" , socketid); ipv4_l3fwd_fib_lookup_struct[socketid] =rte_fib_create (s, socketid, &config_ipv4);if (ipv4_l3fwd_fib_lookup_struct[socketid] ==NULL )
@@ -705,7 +705,7 @@ setup_fib(const int socketid)/* >8 End of setup fib. */ /* Create the fib IPv6 table. */ -snprintf (s,sizeof (s),"IPV6_L3FWD_FIB_%d" , socketid); +snprintf (s,sizeof (s),"L3FWD_FIB6_%d" , socketid); config.type =RTE_FIB6_TRIE ; config.max_routes = (1 <<16 ) -1 ;
lib/fib/rte_fib.c +13 -3
@@ -37,6 +37,9 @@ EAL_REGISTER_TAILQ(rte_fib_tailq)#define FIB_RETURN_IF_TRUE (cond, retval)#endif +/* Prefix used for the memory objects owned by a FIB. */ +#define FIB_MEM_PREFIX "FIB_" +struct rte_fib {char name[RTE_FIB_NAMESIZE ];enum rte_fib_type type;/**< Type of FIB struct */
@@ -173,14 +176,21 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) rib_conf.ext_sz = conf->rib_ext_sz; rib_conf.max_nodes = conf->max_routes *2 ; - rib =rte_rib_create (name, socket_id, &rib_conf); +/* Add FIB Prefix to its mempool name */ + ret =snprintf (mem_name,sizeof (mem_name),FIB_MEM_PREFIX "%s" , name); +if (ret <0 || ret >= (int )sizeof (mem_name)) { +FIB_LOG (ERR ,"FIB name %s is too long" , name); + rte_errno =ENAMETOOLONG ; +return NULL ; + } + + rib =rte_rib_create (mem_name, socket_id, &rib_conf);if (rib ==NULL ) {FIB_LOG (ERR , -"Can not allocate RIB %s" , name); +"Can not allocate RIB for FIB: %s" , mem_name);return NULL ; } -snprintf (mem_name,sizeof (mem_name),"FIB_%s" , name); fib_list =RTE_TAILQ_CAST (rte_fib_tailq.head, rte_fib_list);rte_mcfg_tailq_write_lock ();
lib/fib/rte_fib6.c +13 -3
@@ -37,6 +37,9 @@ EAL_REGISTER_TAILQ(rte_fib6_tailq)#define FIB6_RETURN_IF_TRUE (cond, retval)#endif +/* Prefix used for the memory objects owned by a FIB6. */ +#define FIB6_MEM_PREFIX "FIB6_" +struct rte_fib6 {char name[RTE_FIB6_NAMESIZE ];enum rte_fib6_type type;/**< Type of FIB struct */
@@ -172,14 +175,21 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) rib_conf.ext_sz = conf->rib_ext_sz; rib_conf.max_nodes = conf->max_routes *2 ; - rib =rte_rib6_create (name, socket_id, &rib_conf); +/* Add FIB6 Prefix to its mempool name */ + ret =snprintf (mem_name,sizeof (mem_name),FIB6_MEM_PREFIX "%s" , name); +if (ret <0 || ret >= (int )sizeof (mem_name)) { +FIB_LOG (ERR ,"FIB6 name %s is too long" , name); + rte_errno =ENAMETOOLONG ; +return NULL ; + } + + rib =rte_rib6_create (mem_name, socket_id, &rib_conf);if (rib ==NULL ) {FIB_LOG (ERR , -"Can not allocate RIB %s" , name); +"Can not allocate RIB6 for FIB6 %s" , mem_name);return NULL ; } -snprintf (mem_name,sizeof (mem_name),"FIB6_%s" , name); fib_list =RTE_TAILQ_CAST (rte_fib6_tailq.head, rte_fib6_list);rte_mcfg_tailq_write_lock ();
lib/node/ip4_lookup_fib.c +2 -2
@@ -205,7 +205,7 @@ rte_node_ip4_fib_create(int socket, struct rte_fib_conf *conf)return 0 ; conf->default_nh =FIB_DEFAULT_NH ; -snprintf (s,sizeof (s),"IPV4_LOOKUP_FIB_%d" , socket); +snprintf (s,sizeof (s),"IP4_FIB_%d" , socket); nm->fib[socket] =rte_fib_create (s, socket, conf);if (nm->fib[socket] ==NULL )return -rte_errno;
@@ -266,7 +266,7 @@ setup_fib(int socket) conf.dir24_8.nh_sz =RTE_FIB_DIR24_8_4B ; conf.dir24_8.num_tbl8 =FIB_DEFAULT_NUM_TBL8 ; conf.flags =0 ; -snprintf (s,sizeof (s),"IPV4_LOOKUP_FIB_%d" , socket); +snprintf (s,sizeof (s),"IP4_FIB_%d" , socket); nm->fib[socket] =rte_fib_create (s, socket, &conf);if (nm->fib[socket] ==NULL )return -rte_errno;
lib/node/ip6_lookup_fib.c +2 -2
@@ -199,7 +199,7 @@ rte_node_ip6_fib_create(int socket, struct rte_fib6_conf *conf)return 0 ; conf->default_nh =FIB6_DEFAULT_NH ; -snprintf (s,sizeof (s),"IPV6_LOOKUP_FIB_%u" , socket); +snprintf (s,sizeof (s),"IP6_FIB_%u" , socket); nm->fib6[socket] =rte_fib6_create (s, socket, conf);if (nm->fib6[socket] ==NULL )return -rte_errno;
@@ -257,7 +257,7 @@ setup_fib6(int socket) conf.rib_ext_sz =0 ; conf.trie.nh_sz =RTE_FIB6_TRIE_4B ; conf.trie.num_tbl8 =FIB6_DEFAULT_NUM_TBL8 ; -snprintf (s,sizeof (s),"IPV6_LOOKUP_FIB_%u" , socket); +snprintf (s,sizeof (s),"IP6_FIB_%u" , socket); nm->fib6[socket] =rte_fib6_create (s, socket, &conf);if (nm->fib6[socket] ==NULL )return -rte_errno;
lib/rib/rte_rib.c +12 -2
@@ -32,6 +32,8 @@ EAL_REGISTER_TAILQ(rte_rib_tailq)#define RIB_MAXDEPTH 32/* Maximum length of a RIB name. */ #define RTE_RIB_NAMESIZE 64 +/* Prefix used for the memory objects owned by a RIB. */ +#define RIB_MEM_PREFIX "RIB_"struct rte_rib_node {struct rte_rib_node *left;
@@ -417,6 +419,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)struct rte_tailq_entry *te;struct rte_rib_list *rib_list;struct rte_mempool *node_pool; +int ret;/* Check user arguments. */ if (unlikely (name ==NULL || conf ==NULL || conf->max_nodes <=0 )) {
@@ -424,7 +427,15 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)return NULL ; } -snprintf (mem_name,sizeof (mem_name),"MP_%s" , name); +/* Add RIB Prefix to its node mempool name */ + ret =snprintf (mem_name,sizeof (mem_name),RIB_MEM_PREFIX "%s" , name); +if (unlikely (ret <0 || ret >= (int )RTE_MEMPOOL_NAMESIZE )) { +RIB_LOG (ERR ,"RIB name %s is too long, limit is %zu characters" , + name,RTE_MEMPOOL_NAMESIZE -sizeof (RIB_MEM_PREFIX )); + rte_errno =ENAMETOOLONG ; +return NULL ; + } + node_pool =rte_mempool_create (mem_name, conf->max_nodes,sizeof (struct rte_rib_node ) + conf->ext_sz,0 ,0 ,NULL ,NULL ,NULL ,NULL , socket_id,0 );
@@ -435,7 +446,6 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)return NULL ; } -snprintf (mem_name,sizeof (mem_name),"RIB_%s" , name); rib_list =RTE_TAILQ_CAST (rte_rib_tailq.head, rte_rib_list);rte_mcfg_tailq_write_lock ();
lib/rib/rte_rib6.c +12 -2
@@ -24,6 +24,8 @@#define RTE_RIB_VALID_NODE 1/* Maximum length of a RIB6 name. */ #define RTE_RIB6_NAMESIZE 64 +/* Prefix used for the memory objects owned by a RIB6. */ +#define RIB6_MEM_PREFIX "RIB6_"TAILQ_HEAD (rte_rib6_list, rte_tailq_entry);static struct rte_tailq_elem rte_rib6_tailq = {
@@ -480,6 +482,7 @@ rte_rib6_create(const char *name, int socket_id,struct rte_tailq_entry *te;struct rte_rib6_list *rib6_list;struct rte_mempool *node_pool; +int ret;/* Check user arguments. */ if (unlikely (name ==NULL || conf ==NULL || conf->max_nodes <=0 )) {
@@ -487,7 +490,15 @@ rte_rib6_create(const char *name, int socket_id,return NULL ; } -snprintf (mem_name,sizeof (mem_name),"MP_%s" , name); +/* Add RIB6 Prefix to its node mempool name */ + ret =snprintf (mem_name,sizeof (mem_name),RIB6_MEM_PREFIX "%s" , name); +if (unlikely (ret <0 || ret >= (int )RTE_MEMPOOL_NAMESIZE )) { +RIB_LOG (ERR ,"RIB6 name %s is too long, limit is %zu characters" , + name,RTE_MEMPOOL_NAMESIZE -sizeof (RIB6_MEM_PREFIX )); + rte_errno =ENAMETOOLONG ; +return NULL ; + } + node_pool =rte_mempool_create (mem_name, conf->max_nodes,sizeof (struct rte_rib6_node ) + conf->ext_sz,0 ,0 ,NULL ,NULL ,NULL ,NULL , socket_id,0 );
@@ -498,7 +509,6 @@ rte_rib6_create(const char *name, int socket_id,return NULL ; } -snprintf (mem_name,sizeof (mem_name),"RIB6_%s" , name); rib6_list =RTE_TAILQ_CAST (rte_rib6_tailq.head, rte_rib6_list);rte_mcfg_tailq_write_lock ();
Signature · 1 line
2.34.1
Re: [PATCH v2] fib, rib: fix name prefixes
Quoted 27 lines · On Thu, 13 Aug 2026 07:46:26 +0000 Anurag Mandal <[email protected]>…
The RIB library named the mempool holding its nodes "MP_<name>". That prefix is the one the mempool library itself prepends to the backing memzone, so the memzone ended up named "MP_MP_<name>" which is improper.
The FIB library passed its own name unchanged to the underlying RIB and did not add a prefix to the RIB name.
This patch makes name each object after its owner.
The node mempool of a RIB is now "RIB_<name>" or "RIB6_<name>", and the RIB owned by a FIB is now "FIB_<name>" or "FIB6_<name>".A mempool name is limited to
RTE_MEMPOOL_NAMESIZE, which is much shorter thanRTE_RIB_NAMESIZE.
The name was passed down silently and an oversized one surfaced as an opaquerte_mempool_create()failure, so check the derived name up front and return ENAMETOOLONG instead.
As the prefixes above are added on top of the name, the new maximum length of a name is limited to the following:
RIB : 21 characters
RIB6: 20 characters
FIB : 17 characters
FIB6: 15 characters
Hence, shortening the names used by the graph nodes, the l3fwd example and the unit tests accordingly.Bugzilla ID: 1981 1982
Quoted 8 lines
Fixes 5a5793a5ffa2 ("rib: add RIB library")Fixes f7e861e21c46 ("rib: support IPv6")Fixes 39e927248416 ("fib: add FIB library")Fixes 40d41a8a7b34 ("fib: support IPv6")Signed-off-by Anurag Mandal <[email protected]>Acked-by Morten Brørup <[email protected]>---
This looks good, but would also like to bump up memzone size as well.
AI review:
Review: [PATCH v2] fib, rib: fix name prefixes
Applied to main (6bbb7b3) with the release notes hunk excluded; that hunk does not apply and needs a rebase. Builds with -Dwerror=true. rib, rib6, fib and fib6 autotests pass. Name length limits verified with a probe program against the built libraries.
Warning
1. Fixes tags on a change that shrinks the accepted name length.
RTE_MEMPOOL_NAMESIZE is 26, so a mempool name is at most 25 characters. Before this patch the RIB mempool was "MP_<name>" and FIB passed its name through unchanged, so RIB, RIB6, FIB and FIB6 all accepted names up to 22 characters. After this patch:
RIB 22 -> 21
RIB6 22 -> 20
FIB 22 -> 17
FIB6 22 -> 15An application using a 16..22 character FIB6 name works on 25.11 and fails with ENAMETOOLONG after this patch. With Fixes tags the stable maintainers will consider it for backport, which would be a regression in an LTS.
The "MP_MP_" memzone name is cosmetic. Split into two patches:
the up-front length check with the Fixes tags (backportable, no limit change), and the prefix rename without Fixes for 26.11 only.
2. FIB length check does not enforce the FIB limit.
rte_fib_create() and rte_fib6_create() check the prefixed name against sizeof(mem_name), which is RTE_FIB_NAMESIZE (64). The real limit is enforced one level down in rte_rib_create(), so an 18 character FIB name produces:
RIB: RIB name FIB_aaaaaaaaaaaaaaaaaa is too long, limit is 21
FIB: Can not allocate RIB for FIB: FIB_aaaaaaaaaaaaaaaaaa
The user never passed "FIB_..." and the stated limit is wrong for the FIB caller (21 vs 17; 20 vs 15 for FIB6). Check against the derived limit in FIB itself, and put the maximum name lengths in the public headers so applications can size names without reading release notes.
3. No test for the new ENAMETOOLONG path.
The tests were only shortened to fit. Add cases to test_rib, test_rib6, test_fib and test_fib6 that create a name at the limit (expect success) and at limit + 1 (expect NULL with rte_errno == ENAMETOOLONG).
Info
4. Release notes: "name,the" is missing a space; "maximum length of a name are" should be "is". The four limit lines are not a list in RST and render as one run-on paragraph; use a nested bullet list.
5. "Bugzilla ID: 1981 1982" should be one tag per line.
6. The comment "Add FIB Prefix to its mempool name" in rte_fib.c and rte_fib6.c is inaccurate; the prefixed string is the RIB name.