Introduce FreeBSD macros for SAFE iteration
Subsystems (2)
cover Introduce FreeBSD macros for SAFE iteration
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header sys/queue.h
Chose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros to RTE_XXX variants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.
There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
Stephen Hemminger (7):
eal: add queue macro extensions from FreeBSD net/qede: fix use after free
bus/fslmc: fix use after free
net/bnxt: fix use after free
net/iavf: replace local version of TAILQ_FOREACH_SAFE
vhost: replace open coded TAILQ_FOREACH_SAFE raw/ifpga: use EAL version of TAILQ_FOREACH_SAFE
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 5 +- drivers/net/bnxt/bnxt_filter.c | 8 +- drivers/net/iavf/iavf_vchnl.c | 8 +- drivers/net/qede/qede_ethdev.h | 3 +- drivers/net/qede/qede_filter.c | 13 +- drivers/raw/ifpga/base/opae_osdep.h | 1 + lib/eal/include/meson.build | 3 +- lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++ lib/vhost/socket.c | 11 +- 9 files changed, 193 insertions(+), 33 deletions(-) create mode 100644 lib/eal/include/rte_queue.h
Signature · 1 line
2.45.2
RFC 1/7 eal: add queue macro extensions from FreeBSD
The Linux version of sys/queue.h is frozen at an older version and is missing the _SAFE macro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.
--- lib/eal/include/meson.build | 3 +- lib/eal/include/rte_queue.h | 174 ++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 lib/eal/include/rte_queue.h
lib/eal/include/meson.build +2 -1
@@ -19,8 +19,8 @@ headers += files( 'rte_eal.h', 'rte_eal_memconfig.h', 'rte_eal_trace.h', - 'rte_errno.h', 'rte_epoll.h', + 'rte_errno.h', 'rte_fbarray.h', 'rte_hexdump.h', 'rte_hypervisor.h',
@@ -38,6 +38,7 @@ headers += files( 'rte_pci_dev_features.h', 'rte_per_lcore.h', 'rte_pflock.h', + 'rte_queue.h', 'rte_random.h', 'rte_reciprocal.h', 'rte_seqcount.h',
lib/eal/include/rte_queue.h new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
2.45.2
RFC 2/7 net/qede: fix use after free
In reply to Stephen HemmingerThe loop cleaning up flowdir resources was using SLIST_FOREACH but the inner loop would call rte_free. Found by building with address sanitizer undefined check.
Also remove needless initialization, and null check.
--- drivers/net/qede/qede_ethdev.h | 3 +-- drivers/net/qede/qede_filter.c | 13 +++++-------- 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/net/qede/qede_ethdev.h +1 -2
@@ -8,8 +8,7 @@#ifndef _QEDE_ETHDEV_H_#define _QEDE_ETHDEV_H_ -#include <sys/queue.h> - +#include <rte_queue.h> #include <rte_ether.h> #include <ethdev_driver.h> #include <ethdev_pci.h>
drivers/net/qede/qede_filter.c +5 -8
@@ -154,15 +154,12 @@ int qede_check_fdir_support(struct rte_eth_dev *eth_dev)void qede_fdir_dealloc_resc (struct rte_eth_dev *eth_dev) {struct qede_dev *qdev =QEDE_INIT_QDEV (eth_dev); -struct qede_arfs_entry *tmp =NULL ; +struct qede_arfs_entry *tmp, *tmp2; - SLIST_FOREACH(tmp, &qdev->arfs_info.arfs_list_head, list) { -if (tmp) { -rte_memzone_free (tmp->mz); -SLIST_REMOVE (&qdev->arfs_info.arfs_list_head, tmp, - qede_arfs_entry, list); -rte_free (tmp); - } + SLIST_FOREACH_SAFE(tmp, &qdev->arfs_info.arfs_list_head, list, tmp2) { +rte_memzone_free (tmp->mz); +SLIST_REMOVE (&qdev->arfs_info.arfs_list_head, tmp, qede_arfs_entry, list); +rte_free (tmp); } }
Signature · 1 line
2.45.2
RFC 3/7 bus/fslmc: fix use after free
In reply to Stephen HemmingerThe cleanup loop would deference the dpio_dev after freeing. Use TAILQ_FOREACH_SAFE to fix that.
Found by building with sanitizer undefined flag.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3 -2
@@ -15,7 +15,6 @@#include <signal.h> #include <pthread.h> #include <sys/types.h> -#include <sys/queue.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/mman.h>
@@ -27,6 +26,7 @@#include <ethdev_driver.h> #include <rte_malloc.h> #include <rte_memcpy.h> +#include <rte_queue.h> #include <rte_string_fns.h> #include <rte_cycles.h> #include <rte_kvargs.h>
@@ -403,6 +403,7 @@ dpaa2_create_dpio_device(int vdev_fd, struct rte_dpaa2_device *obj) {struct dpaa2_dpio_dev *dpio_dev =NULL ; +struct dpaa2_dpio_dev *dpio_tmp;struct vfio_region_info reg_info = { .argsz =sizeof (reg_info)};struct qbman_swp_desc p_des;struct dpio_attr attr;
@@ -588,7 +589,7 @@ dpaa2_create_dpio_device(int vdev_fd,rte_free (dpio_dev);/* For each element in the list, cleanup */ - TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) { + TAILQ_FOREACH_SAFE(dpio_dev, &dpio_dev_list, next, dpio_tmp) {if (dpio_dev->dpio) {dpio_disable (dpio_dev->dpio,CMD_PRI_LOW , dpio_dev->token);
Signature · 1 line
2.45.2
RFC 4/7 net/bnxt: fix use after free
In reply to Stephen HemmingerThe filter cleanup loop was using STAILQ_FOREACH and rte_free and would dereference the filter after free.
Found by build with -Dbsanitize=address,undefined
--- drivers/net/bnxt/bnxt_filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_filter.c +4 -4
@@ -3,14 +3,12 @@* All rights reserved. */ -#include <sys/queue.h> -#include <rte_byteorder.h> #include <rte_log.h> #include <rte_malloc.h> #include <rte_flow.h> #include <rte_flow_driver.h> -#include <rte_tailq.h> +#include <rte_queue.h> #include "bnxt.h" #include "bnxt_filter.h"
@@ -151,7 +149,9 @@ void bnxt_free_filter_mem(struct bnxt *bp) bp->filter_info =NULL ;for (i =0 ; i < bp->pf->max_vfs; i++) { - STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) { +struct bnxt_filter_info *tmp; + + STAILQ_FOREACH_SAFE(filter, &bp->pf->vf_info[i].filter, next, tmp) {rte_free (filter);STAILQ_REMOVE (&bp->pf->vf_info[i].filter, filter, bnxt_filter_info, next);
Signature · 1 line
2.45.2
Re: [RFC 4/7] net/bnxt: fix use after free
Quoted 11 lines · Stephen Hemminger
The filter cleanup loop was using
STAILQ_FOREACHandrte_freeand would dereference the filter after free.Found by build with -Dbsanitize=address,undefined
Fixes e8fe0e067b68 ("net/bnxt: fix allocation of PF info struct")Signed-off-by Stephen Hemminger <[email protected]>
Quoted 38 lines
--- drivers/net/bnxt/bnxt_filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/bnxt/bnxt_filter.c +4
-5@@ -3,14 +3,12 @@* All rights reserved. */ -#include <sys/queue.h> -#include <rte_byteorder.h> #include <rte_log.h> #include <rte_malloc.h> #include <rte_flow.h> #include <rte_flow_driver.h> -#include <rte_tailq.h> +#include <rte_queue.h> #include "bnxt.h" #include "bnxt_filter.h" @@ -151,7 +149,9 @@ void bnxt_free_filter_mem(struct bnxt *bp) bp->filter_info =NULL ;for (i =0 ; i < bp->pf->max_vfs; i++) { - STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) { +struct bnxt_filter_info *tmp; + + STAILQ_FOREACH_SAFE(filter, &bp->pf->vf_info[i].filter, next, tmp) {rte_free (filter);STAILQ_REMOVE (&bp->pf->vf_info[i].filter, filter, bnxt_filter_info, next); --2.45.2
RFC 5/7 net/iavf: replace local version of TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerNow in EAL as rte_queue.h
--- drivers/net/iavf/iavf_vchnl.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/iavf/iavf_vchnl.c +1 -7
@@ -13,6 +13,7 @@#include <rte_byteorder.h> #include <rte_common.h> #include <rte_os_shim.h> +#include <rte_queue.h> #include <rte_debug.h> #include <rte_alarm.h>
@@ -52,13 +53,6 @@ static struct iavf_event_handler event_handler = { .fd = {-1, -1}, }; -#ifndef TAILQ_FOREACH_SAFE -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif -static uint32_t iavf_dev_event_handle(void *param __rte_unused) {
Signature · 1 line
2.45.2
RFC 6/7 vhost: replace open coded TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerProper macro is now in EAL rte_queue.h use it instead.
--- lib/vhost/socket.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
lib/vhost/socket.c +2 -9
@@ -10,10 +10,10 @@#include <string.h> #include <sys/socket.h> #include <sys/un.h> -#include <sys/queue.h> #include <errno.h> #include <fcntl.h> +#include <rte_queue.h> #include <rte_thread.h> #include <rte_log.h>
@@ -458,14 +458,7 @@ vhost_user_client_reconnect(void *arg __rte_unused)while (1 ) {pthread_mutex_lock (&reconn_list.mutex); -/* -* An equal implementation of TAILQ_FOREACH_SAFE, -* which does not exist on all platforms. -*/ -for (reconn =TAILQ_FIRST (&reconn_list.head); - reconn !=NULL ; reconn = next) { - next =TAILQ_NEXT (reconn, next); - + TAILQ_FOREACH_SAFE(reconn, &reconn_list.head, next, next) { ret =vhost_user_connect_nonblock (reconn->vsocket->path, reconn->fd, (struct sockaddr *)&reconn->un,sizeof (reconn->un));
Signature · 1 line
2.45.2
RFC 7/7 raw/ifpga: use EAL version of TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerPrefer the EAL version over local version of macro.
--- drivers/raw/ifpga/base/opae_osdep.h | 1 + 1 file changed, 1 insertion(+)
drivers/raw/ifpga/base/opae_osdep.h +1 -0
@@ -11,6 +11,7 @@#ifdef RTE_LIB_EAL #include "osdep_rte/osdep_generic.h" +#include <rte_queue.h> #else #include "osdep_raw/osdep_generic.h" #endif
Signature · 1 line
2.45.2
RE: [RFC 7/7] raw/ifpga: use EAL version of TAILQ_FOREACH_SAFE
Hi,
Quoted 29 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 28, 2025 2:04 AM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Xu, Rosen <[email protected]>
Subject: [RFC 7/7] raw/ifpga: use EAL version ofTAILQ_FOREACH_SAFEPrefer the EAL version over local version of macro.
Signed-off-by Stephen Hemminger <[email protected]>--- drivers/raw/ifpga/base/opae_osdep.h | 1 + 1 file changed, 1 insertion(+)drivers/raw/ifpga/base/opae_osdep.h +1
-1@@ -11,6 +11,7 @@#ifdef RTE_LIB_EAL #include "osdep_rte/osdep_generic.h" +#include <rte_queue.h> #else #include "osdep_raw/osdep_generic.h" #endif --
Quoted 1 line
2.45.2
Quoted 4 lines · Stephen Hemminger
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.h
Quoted 9 lines
Chose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.
Actually, I wouldn't be that quick to eliminate the last option. It may give us some additional options for simplification. For example, the strlcpy and strlcat functions are in libbsd too, and if we had that as mandatory dependency, perhaps we could remove some extra code there too?
/Bruce
Quoted 15 lines · On Mon, 27 Jan 2025 18:16:18 +0000 Bruce Richardson…
Quoted 4 lines · Stephen Hemminger
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hQuoted 9 lines
Chose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.
Quoted 7 lines
Actually, I wouldn't be that quick to eliminate the last option. It may give us some additional options for simplification. For example, the strlcpy and strlcat functions are in libbsd too, and if we had that as mandatory dependency, perhaps we could remove some extra code there too?
/Bruce
I would be ok with using libbsd but only if we didn't have to keep a parallel copy for all the other compiler and OS variants. And would it be global or a per-driver dependency?
Quoted 29 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 27 January 2025 19.44Quoted 15 lines · On Mon, 27 Jan 2025 18:16:18 +0000 Bruce Richardson…
Quoted 4 lines · Stephen Hemminger
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hQuoted 9 lines
Chose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.Quoted 1 line
Actually, I wouldn't be that quick to eliminate the last option. It
may
Quoted 2 lines
give us some additional options for simplification. For example, the strlcpy and strlcat functions are in libbsd too, and if we had that
as
Quoted 1 line
mandatory dependency, perhaps we could remove some extra code there
too?
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
/Bruce
I would be ok with using libbsd but only if we didn't have to keep a parallel
copy for all the other compiler and OS variants. And would it be global or
a per-driver dependency?
+1 to providing our own implementations of relevant libbsd features in the DPDK EAL, rather than depending on the entire libbsd (and libbsd-dev for development). Providing these features as part of a "utilities library" (which is currently integrated into the EAL) is better for non-Unix environments.
Furthermore, libbsd has plenty of stuff we don't need:
https://manpages.debian.org/testing/libbsd-dev/index.html
Quoted 38 lines · On Mon, 27 Jan 2025 20:29:55 +0100 Morten Brørup <[email protected]>…
Quoted 29 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 27 January 2025 19.44Quoted 15 lines · On Mon, 27 Jan 2025 18:16:18 +0000 Bruce Richardson…
Quoted 4 lines · Stephen Hemminger
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hQuoted 9 lines
Chose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.Quoted 1 line
Actually, I wouldn't be that quick to eliminate the last option. It
may
Quoted 2 lines
give us some additional options for simplification. For example, the strlcpy and strlcat functions are in libbsd too, and if we had that
as
Quoted 1 line
mandatory dependency, perhaps we could remove some extra code there
too?
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
/Bruce
I would be ok with using libbsd but only if we didn't have to keep a parallel
copy for all the other compiler and OS variants. And would it be global or
a per-driver dependency?
Quoted 4 lines
+1 to providing our own implementations of relevant libbsd features in the DPDK EAL, rather than depending on the entire libbsd (and libbsd-dev for development). Providing these features as part of a "utilities library" (which is currently integrated into the EAL) is better for non-Unix environments.
Furthermore, libbsd has plenty of stuff we don't need:
https://manpages.debian.org/testing/libbsd-dev/index.html
The red-black tries in libbsd are very useful. In one product we used it as a way to manage LPM rules, since the current DPDK model is O(N^2) and works terribly in a router with 3M routes.
v2 cover Introduce FOREACH_SAFE macros
In reply to Stephen HemmingerThis series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header sys/queue.h
Chose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros to RTE_XXX variants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.
There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
v2 - rebase after Intel PMD reorg
Stephen Hemminger (7):
eal: add queue macro extensions from FreeBSD net/qede: fix use after free
bus/fslmc: fix use after free
net/bnxt: fix use after free
net/iavf: replace local version of TAILQ_FOREACH_SAFE
vhost: replace open coded TAILQ_FOREACH_SAFE raw/ifpga: use EAL version of TAILQ_FOREACH_SAFE
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 5 +- drivers/net/bnxt/bnxt_filter.c | 8 +- drivers/net/intel/iavf/iavf_vchnl.c | 8 +- drivers/net/qede/qede_ethdev.h | 3 +- drivers/net/qede/qede_filter.c | 13 +- drivers/raw/ifpga/base/opae_osdep.h | 1 + lib/eal/include/meson.build | 3 +- lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++ lib/vhost/socket.c | 11 +- 9 files changed, 193 insertions(+), 33 deletions(-) create mode 100644 lib/eal/include/rte_queue.h
Signature · 1 line
2.47.2
PATCH v2 1/7 eal: add queue macro extensions from FreeBSD
The Linux version of sys/queue.h is frozen at an older version and is missing the _SAFE macro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.
--- lib/eal/include/meson.build | 3 +- lib/eal/include/rte_queue.h | 174 ++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 lib/eal/include/rte_queue.h
lib/eal/include/meson.build +2 -1
@@ -19,8 +19,8 @@ headers += files( 'rte_eal.h', 'rte_eal_memconfig.h', 'rte_eal_trace.h', - 'rte_errno.h', 'rte_epoll.h', + 'rte_errno.h', 'rte_fbarray.h', 'rte_hexdump.h', 'rte_hypervisor.h',
@@ -38,6 +38,7 @@ headers += files( 'rte_pci_dev_features.h', 'rte_per_lcore.h', 'rte_pflock.h', + 'rte_queue.h', 'rte_random.h', 'rte_reciprocal.h', 'rte_seqcount.h',
lib/eal/include/rte_queue.h new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
2.47.2
Re: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
14/02/2025 18:20, Stephen Hemminger:
Quoted 5 lines
The Linux version of
sys/queue.his frozen at an older version and is missing the_SAFEmacro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.Signed-off-by Stephen Hemminger <[email protected]>
We may want to unify with lib/eal/windows/include/sys/queue.h
Re: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
Quoted 8 lines · On Wed, 19 Feb 2025 15:55:17 +0100 Thomas Monjalon <[email protected]> wrote:
14/02/2025 18:20, Stephen Hemminger:
Quoted 5 lines
The Linux version of
sys/queue.his frozen at an older version and is missing the_SAFEmacro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.Signed-off-by Stephen Hemminger <[email protected]>We may want to unify with
lib/eal/windows/include/sys/queue.h
Do we want to just not use the local Linux version of queue.h entirely? Maybe just put in current FreeBSD one? It has lots more useful variations.
The point is to avoid broken versions (like one Intel driver) or having same macro in multiple places.
Re: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
22/02/2025 00:05, Stephen Hemminger:
Quoted 8 lines
Quoted 5 lines · On Wed, 19 Feb 2025 15:55:17 +0100 Thomas Monjalon <[email protected]> wrote:
14/02/2025 18:20, Stephen Hemminger:
Quoted 4 lines
The Linux version of
sys/queue.his frozen at an older version and is missing the_SAFEmacro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Stephen Hemminger <[email protected]>We may want to unify with
lib/eal/windows/include/sys/queue.hDo we want to just not use the local Linux version of
queue.hentirely? Maybe just put in current FreeBSD one? It has lots more useful variations.
Yes but it should be global in EAL, no need to duplicate it for EAL Windows and others.
Quoted 2 lines
The point is to avoid broken versions (like one Intel driver) or having same macro in multiple places.
Got it.
Re: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
In reply to Thomas MonjalonQuoted 10 lines · On Wed, 19 Feb 2025 15:55:17 +0100 Thomas Monjalon <[email protected]> wrote:
14/02/2025 18:20, Stephen Hemminger:
Quoted 5 lines
The Linux version of
sys/queue.his frozen at an older version and is missing the_SAFEmacro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.Signed-off-by Stephen Hemminger <[email protected]>We may want to unify with
lib/eal/windows/include/sys/queue.h
Not sure, we have several options here:
1. Keep using Linux sys/queue.h and add enhancements in rte_queue.h
2. Make rte_queue.h a copy of FreeBSD version of queue.h (that is what Windows did)
3. Use the bsd version of queue.h.
On Debian/Ubuntu this in libbsd-dev package and referred to as bsd/sys/queue.h
I chose #1 as simplest. But all of these could work. #3 means DPDK has least new code, but adds another dependency to the build.
No matter what, should add to checkpatch to block any new files that include sys/queue.h directly.
RE: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
Quoted 25 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 00.02Quoted 10 lines · On Wed, 19 Feb 2025 15:55:17 +0100 Thomas Monjalon <[email protected]> wrote:
14/02/2025 18:20, Stephen Hemminger:
Quoted 5 lines
The Linux version of
sys/queue.his frozen at an older version and is missing the_SAFEmacro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.Signed-off-by Stephen Hemminger <[email protected]>We may want to unify with
lib/eal/windows/include/sys/queue.hNot sure, we have several options here:
1. Keep using Linuxsys/queue.hand add enhancements inrte_queue.h
2. Makerte_queue.ha copy of FreeBSD version ofqueue.h(that is
what Windows did)
3. Use the bsd version ofqueue.h.
On Debian/Ubuntu this in libbsd-dev package and referred to asbsd/sys/queue.h
Quoted 3 lines
I chose #1 as simplest. But all of these could work. #3 means DPDK has least new
code, but adds another dependency to the build.
+1 to #2:
If Linux sys/queue.h is frozen, and is a subset of FreeBSD queue.h, #2 would consolidate all the queue macros in one file.
That seems easier to navigate (for a developer/reviewer looking at the macro definitions/implementations) than including sys/queue.h, queue.h or lib/eal/windows/include/sys/queue.h depending on O/S, and then defining the missing macros in rte_queue.h. A comment at the top of the rte_queue.h file could mention that it is a copy of the FreeBSD queue.h file.
-1 to #3; it adds an unnecessary dependency.
Quoted 4 lines
No matter what, should add to checkpatch to block any new files that include
sys/queue.h
directly.
+1 to this.
Re: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
Quoted 34 lines · Morten Brørup
Quoted 25 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 00.02Quoted 10 lines · On Wed, 19 Feb 2025 15:55:17 +0100 Thomas Monjalon <[email protected]> wrote:
14/02/2025 18:20, Stephen Hemminger:
Quoted 5 lines
The Linux version of
sys/queue.his frozen at an older version and is missing the_SAFEmacro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.Signed-off-by Stephen Hemminger <[email protected]>We may want to unify with
lib/eal/windows/include/sys/queue.hNot sure, we have several options here:
1. Keep using Linuxsys/queue.hand add enhancements inrte_queue.h
2. Makerte_queue.ha copy of FreeBSD version ofqueue.h(that is
what Windows did)
3. Use the bsd version ofqueue.h.
On Debian/Ubuntu this in libbsd-dev package and referred to asbsd/sys/queue.hQuoted 3 lines
I chose #1 as simplest. But all of these could work. #3 means DPDK has least new
code, but adds another dependency to the build.+1 to #2:
If Linuxsys/queue.his frozen, and is a subset of FreeBSDqueue.h, #2 would consolidate all the queue macros in one file.
That seems easier to navigate (for a developer/reviewer looking at the macro definitions/implementations) than includingsys/queue.h,queue.horlib/eal/windows/include/sys/queue.hdepending on O/S, and then defining the missing macros inrte_queue.h. A comment at the top of therte_queue.hfile could mention that it is a copy of the FreeBSDqueue.hfile.
Quoted 9 lines
-1 to #3; it adds an unnecessary dependency.
Quoted 4 lines
No matter what, should add to checkpatch to block any new files that include
sys/queue.h
directly.+1 to this.
I agree with Morten, #2 looks the best option to me too. /Bruce
Re: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
13/03/2025 09:56, Bruce Richardson:
Quoted 38 lines · Morten Brørup
Quoted 37 lines
Quoted 25 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 00.02Quoted 10 lines · On Wed, 19 Feb 2025 15:55:17 +0100 Thomas Monjalon <[email protected]> wrote:
14/02/2025 18:20, Stephen Hemminger:
Quoted 5 lines
The Linux version of
sys/queue.his frozen at an older version and is missing the_SAFEmacro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.Signed-off-by Stephen Hemminger <[email protected]>We may want to unify with
lib/eal/windows/include/sys/queue.hNot sure, we have several options here:
1. Keep using Linuxsys/queue.hand add enhancements inrte_queue.h
2. Makerte_queue.ha copy of FreeBSD version ofqueue.h(that is
what Windows did)
3. Use the bsd version ofqueue.h.
On Debian/Ubuntu this in libbsd-dev package and referred to asbsd/sys/queue.hQuoted 3 lines
I chose #1 as simplest. But all of these could work. #3 means DPDK has least new
code, but adds another dependency to the build.+1 to #2:
If Linuxsys/queue.his frozen, and is a subset of FreeBSDqueue.h, #2 would consolidate all the queue macros in one file.
That seems easier to navigate (for a developer/reviewer looking at the macro definitions/implementations) than includingsys/queue.h,queue.horlib/eal/windows/include/sys/queue.hdepending on O/S, and then defining the missing macros inrte_queue.h. A comment at the top of therte_queue.hfile could mention that it is a copy of the FreeBSDqueue.hfile.-1 to #3; it adds an unnecessary dependency.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
No matter what, should add to checkpatch to block any new files that include
sys/queue.h
directly.+1 to this.
I agree with Morten, #2 looks the best option to me too.
It means we want to remove lib/eal/windows/include/sys/queue.h, right?
RE: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
Quoted 58 lines
From: Thomas Monjalon [mailto:[email protected]]
13/03/2025 09:56, Bruce Richardson:
Quoted 9 lines · Morten Brørup
Quoted 8 lines
Quoted 8 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 00.02Quoted 2 lines · On Wed, 19 Feb 2025 15:55:17 +0100 Thomas Monjalon <[email protected]> wrote:
14/02/2025 18:20, Stephen Hemminger:
Quoted 1 line
The Linux version of
sys/queue.his frozen at an olderversion
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
and is missing the
_SAFEmacro variants. Several driversstarted
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
introducing the own workarounds for this. Should be handled
in EAL.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Signed-off-by Stephen Hemminger <[email protected]>We may want to unify with
lib/eal/windows/include/sys/queue.hNot sure, we have several options here:
1. Keep using Linuxsys/queue.hand add enhancements in
rte_queue.hQuoted 1 line
Quoted 1 line
Quoted 1 line
2. Make
rte_queue.ha copy of FreeBSD version ofqueue.h(thatis
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
what Windows did)
3. Use the bsd version ofqueue.h.
On Debian/Ubuntu this in libbsd-dev package and referred toas
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
bsd/sys/queue.hI chose #1 as simplest. But all of these could work. #3 means
DPDK has
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
least new
code, but adds another dependency to the build.+1 to #2:
If Linuxsys/queue.his frozen, and is a subset of FreeBSDqueue.h,#2 would consolidate all the queue macros in one file.
Quoted 1 line
Quoted 1 line
That seems easier to navigate (for a developer/reviewer looking at
the macro definitions/implementations) than including
sys/queue.h,queue.horlib/eal/windows/include/sys/queue.hdepending on O/S, and then defining the missing macros inrte_queue.h.Quoted 1 line
Quoted 1 line
A comment at the top of the
rte_queue.hfile could mention that itis a copy of the FreeBSD
queue.hfile.Quoted 5 lines
Quoted 5 lines
-1 to #3; it adds an unnecessary dependency.
Quoted 2 lines
No matter what, should add to checkpatch to block any new files
that
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
include
sys/queue.h
directly.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+1 to this.
I agree with Morten, #2 looks the best option to me too.
It means we want to remove
lib/eal/windows/include/sys/queue.h, right?
Correct.
All queue macros are consolidated into rte_queue.h.
Re: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
Quoted 61 lines · On Thu, 13 Mar 2025 15:41:33 +0100 Morten Brørup <[email protected]>…
Quoted 61 lines
From: Thomas Monjalon [mailto:[email protected]]
13/03/2025 09:56, Bruce Richardson:
Quoted 9 lines · Morten Brørup
Quoted 8 lines
Quoted 8 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 00.02Quoted 2 lines · On Wed, 19 Feb 2025 15:55:17 +0100 Thomas Monjalon <[email protected]> wrote:
14/02/2025 18:20, Stephen Hemminger:
Quoted 1 line
The Linux version of
sys/queue.his frozen at an olderversion
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
and is missing the
_SAFEmacro variants. Several driversstarted
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
introducing the own workarounds for this. Should be handled
in EAL.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Signed-off-by Stephen Hemminger <[email protected]>We may want to unify with
lib/eal/windows/include/sys/queue.hNot sure, we have several options here:
1. Keep using Linuxsys/queue.hand add enhancements in
rte_queue.hQuoted 1 line
Quoted 1 line
Quoted 1 line
2. Make
rte_queue.ha copy of FreeBSD version ofqueue.h(thatis
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
what Windows did)
3. Use the bsd version ofqueue.h.
On Debian/Ubuntu this in libbsd-dev package and referred toas
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
bsd/sys/queue.hI chose #1 as simplest. But all of these could work. #3 means
DPDK has
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
least new
code, but adds another dependency to the build.+1 to #2:
If Linuxsys/queue.his frozen, and is a subset of FreeBSDqueue.h,#2 would consolidate all the queue macros in one file.
Quoted 1 line
Quoted 1 line
That seems easier to navigate (for a developer/reviewer looking at
the macro definitions/implementations) than including
sys/queue.h,queue.horlib/eal/windows/include/sys/queue.hdepending on O/S, and then defining the missing macros inrte_queue.h.Quoted 1 line
Quoted 1 line
A comment at the top of the
rte_queue.hfile could mention that itis a copy of the FreeBSD
queue.hfile.Quoted 5 lines
Quoted 5 lines
-1 to #3; it adds an unnecessary dependency.
Quoted 2 lines
No matter what, should add to checkpatch to block any new files
that
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
include
sys/queue.h
directly.+1 to this.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
I agree with Morten, #2 looks the best option to me too.
It means we want to remove
lib/eal/windows/include/sys/queue.h, right?Correct.
All queue macros are consolidated intorte_queue.h.
I have been trying this, and it possible but there is some fallout. If application includes <sys/queue.h> and other DPDK headers include <rte_queue.h> there are declaration conflicts. Ends up being a compilation failure. Tedious, but not hard to fix all of DPDK to use rte_queue.h instead of sys/queue.h but what about user applications?
Since that would be API break, best to put it off to 25.11.
RE: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
Quoted 86 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 17.25Quoted 10 lines · On Thu, 13 Mar 2025 15:41:33 +0100 Morten Brørup <[email protected]>…
Quoted 10 lines
From: Thomas Monjalon [mailto:[email protected]]
13/03/2025 09:56, Bruce Richardson:
Quoted 7 lines · Morten Brørup
Quoted 6 lines
Quoted 6 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 00.02On Wed, 19 Feb 2025 15:55:17 +0100
Thomas Monjalon <[email protected]> wrote:Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
14/02/2025 18:20, Stephen Hemminger:
Quoted 1 line
The Linux version of
sys/queue.his frozen at an olderversion
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
and is missing the
_SAFEmacro variants. Several driversstarted
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
introducing the own workarounds for this. Should be
handled
Quoted 3 lines
Quoted 3 lines
in EAL.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Stephen HemmingerQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
We may want to unify with
lib/eal/windows/include/sys/queue.hQuoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Not sure, we have several options here:
1. Keep using Linuxsys/queue.hand add enhancements in
rte_queue.hQuoted 1 line
Quoted 1 line
Quoted 1 line
2. Make
rte_queue.ha copy of FreeBSD version ofqueue.h(that
Quoted 4 lines
Quoted 4 lines
is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
what Windows did)
3. Use the bsd version ofqueue.h.
On Debian/Ubuntu this in libbsd-dev package and referredto
Quoted 10 lines
Quoted 10 lines
as
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
bsd/sys/queue.hI chose #1 as simplest. But all of these could work. #3 means
DPDK has
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
least new
code, but adds another dependency to the build.+1 to #2:
If Linuxsys/queue.his frozen, and is a subset of FreeBSD
queue.h,Quoted 2 lines
Quoted 2 lines
#2 would consolidate all the queue macros in one file.
Quoted 1 line
Quoted 1 line
That seems easier to navigate (for a developer/reviewer looking
at
Quoted 2 lines
Quoted 2 lines
the macro definitions/implementations) than including
sys/queue.h,queue.horlib/eal/windows/include/sys/queue.hdepending on O/S,and
Quoted 2 lines
Quoted 2 lines
then defining the missing macros in
rte_queue.h.Quoted 1 line
Quoted 1 line
A comment at the top of the
rte_queue.hfile could mention thatit
Quoted 6 lines
Quoted 6 lines
is a copy of the FreeBSD
queue.hfile.Quoted 5 lines
Quoted 5 lines
-1 to #3; it adds an unnecessary dependency.
Quoted 2 lines
No matter what, should add to checkpatch to block any new
files
Quoted 10 lines
Quoted 10 lines
that
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
include
sys/queue.h
directly.+1 to this.
I agree with Morten, #2 looks the best option to me too.
It means we want to remove
lib/eal/windows/include/sys/queue.h,right?
Quoted 4 lines
Correct.
All queue macros are consolidated intorte_queue.h.
Quoted 7 lines
I have been trying this, and it possible but there is some fallout. If application includes <
sys/queue.h> and other DPDK headers include <rte_queue.h>
there are declaration conflicts. Ends up being a compilation failure. Tedious, but not hard to fix all of DPDK to userte_queue.hinstead ofsys/queue.h
but what about user applications?
Perhaps this could work:
If _SYS_QUEUE_H_ is defined in rte_queue.h, including <sys/queue.h> after <rte_queue.h> will be harmless.
If each macro in rte_queue.h is surrounded by #ifndef MACRONAME, including <rte_queue.h> after <sys/queue.h> will be harmless. Alternatively, surround a group of macros in rte_queue.h by #ifndef _SYS_QUEUE_H_.
Quoted 2 lines
Since that would be API break, best to put it off to 25.11.
It might be impossible prohibiting user libraries from including <sys/queue.h>, especially if some 3rd party library includes <sys/queue.h> in the library's header file. The application developer would not want to modify the header files of 3rd party libraries.
Re: [PATCH v2 1/7] eal: add queue macro extensions from FreeBSD
Quoted 94 lines · On Thu, 13 Mar 2025 17:40:26 +0100 Morten Brørup <[email protected]>…
Quoted 86 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 17.25Quoted 10 lines · On Thu, 13 Mar 2025 15:41:33 +0100 Morten Brørup <[email protected]>…
Quoted 10 lines
From: Thomas Monjalon [mailto:[email protected]]
13/03/2025 09:56, Bruce Richardson:
Quoted 7 lines · Morten Brørup
Quoted 6 lines
Quoted 6 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 March 2025 00.02On Wed, 19 Feb 2025 15:55:17 +0100
Thomas Monjalon <[email protected]> wrote:Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
14/02/2025 18:20, Stephen Hemminger:
Quoted 1 line
The Linux version of
sys/queue.his frozen at an olderversion
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
and is missing the
_SAFEmacro variants. Several driversstarted
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
introducing the own workarounds for this. Should be
handled
Quoted 3 lines
Quoted 3 lines
in EAL.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Stephen HemmingerQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
We may want to unify with
lib/eal/windows/include/sys/queue.hQuoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Not sure, we have several options here:
1. Keep using Linuxsys/queue.hand add enhancements in
rte_queue.hQuoted 1 line
Quoted 1 line
Quoted 1 line
2. Make
rte_queue.ha copy of FreeBSD version ofqueue.h(that
Quoted 4 lines
Quoted 4 lines
is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
what Windows did)
3. Use the bsd version ofqueue.h.
On Debian/Ubuntu this in libbsd-dev package and referredto
Quoted 10 lines
Quoted 10 lines
as
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
bsd/sys/queue.hI chose #1 as simplest. But all of these could work. #3 means
DPDK has
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
least new
code, but adds another dependency to the build.+1 to #2:
If Linuxsys/queue.his frozen, and is a subset of FreeBSD
queue.h,Quoted 2 lines
Quoted 2 lines
#2 would consolidate all the queue macros in one file.
Quoted 1 line
Quoted 1 line
That seems easier to navigate (for a developer/reviewer looking
at
Quoted 2 lines
Quoted 2 lines
the macro definitions/implementations) than including
sys/queue.h,queue.horlib/eal/windows/include/sys/queue.hdepending on O/S,and
Quoted 2 lines
Quoted 2 lines
then defining the missing macros in
rte_queue.h.Quoted 1 line
Quoted 1 line
A comment at the top of the
rte_queue.hfile could mention thatit
Quoted 6 lines
Quoted 6 lines
is a copy of the FreeBSD
queue.hfile.Quoted 5 lines
Quoted 5 lines
-1 to #3; it adds an unnecessary dependency.
Quoted 2 lines
No matter what, should add to checkpatch to block any new
files
Quoted 10 lines
Quoted 10 lines
that
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
include
sys/queue.h
directly.+1 to this.
I agree with Morten, #2 looks the best option to me too.
It means we want to remove
lib/eal/windows/include/sys/queue.h,right?
Quoted 4 lines
Correct.
All queue macros are consolidated intorte_queue.h.Quoted 7 lines
I have been trying this, and it possible but there is some fallout. If application includes <
sys/queue.h> and other DPDK headers include <rte_queue.h>
there are declaration conflicts. Ends up being a compilation failure. Tedious, but not hard to fix all of DPDK to userte_queue.hinstead ofsys/queue.h
but what about user applications?
Quoted 6 lines
Perhaps this could work:
If _SYS_QUEUE_H_ is defined in
rte_queue.h, including <sys/queue.h> after <rte_queue.h> will be harmless.If each macro in
rte_queue.his surrounded by #ifndef MACRONAME, including <rte_queue.h> after <sys/queue.h> will be harmless. Alternatively, surround a group of macros inrte_queue.hby #ifndef _SYS_QUEUE_H_.
Most applications include system headers (ie. sys/queue.h) then DPDK headers (rte_queue.h)
Quoted 5 lines
Quoted 2 lines
Since that would be API break, best to put it off to 25.11.
It might be impossible prohibiting user libraries from including <
sys/queue.h>, especially if some 3rd party library includes <sys/queue.h> in the library's header file. The application developer would not want to modify the header files of 3rd party libraries.
It is possible to bracket every macro with #ifdef to avoid collision but gets messy.
PATCH v2 2/7 net/qede: fix use after free
In reply to Stephen HemmingerThe loop cleaning up flowdir resources was using SLIST_FOREACH but the inner loop would call rte_free. Found by building with address sanitizer undefined check.
Also remove needless initialization, and null check.
--- drivers/net/qede/qede_ethdev.h | 3 +-- drivers/net/qede/qede_filter.c | 13 +++++-------- 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/net/qede/qede_ethdev.h +1 -2
@@ -8,8 +8,7 @@#ifndef _QEDE_ETHDEV_H_#define _QEDE_ETHDEV_H_ -#include <sys/queue.h> - +#include <rte_queue.h> #include <rte_ether.h> #include <ethdev_driver.h> #include <ethdev_pci.h>
drivers/net/qede/qede_filter.c +5 -8
@@ -154,15 +154,12 @@ int qede_check_fdir_support(struct rte_eth_dev *eth_dev)void qede_fdir_dealloc_resc (struct rte_eth_dev *eth_dev) {struct qede_dev *qdev =QEDE_INIT_QDEV (eth_dev); -struct qede_arfs_entry *tmp =NULL ; +struct qede_arfs_entry *tmp, *tmp2; - SLIST_FOREACH(tmp, &qdev->arfs_info.arfs_list_head, list) { -if (tmp) { -rte_memzone_free (tmp->mz); -SLIST_REMOVE (&qdev->arfs_info.arfs_list_head, tmp, - qede_arfs_entry, list); -rte_free (tmp); - } + SLIST_FOREACH_SAFE(tmp, &qdev->arfs_info.arfs_list_head, list, tmp2) { +rte_memzone_free (tmp->mz); +SLIST_REMOVE (&qdev->arfs_info.arfs_list_head, tmp, qede_arfs_entry, list); +rte_free (tmp); } }
Signature · 1 line
2.47.2
PATCH v2 3/7 bus/fslmc: fix use after free
In reply to Stephen HemmingerThe cleanup loop would deference the dpio_dev after freeing. Use TAILQ_FOREACH_SAFE to fix that.
Found by building with sanitizer undefined flag.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3 -2
@@ -15,7 +15,6 @@#include <signal.h> #include <pthread.h> #include <sys/types.h> -#include <sys/queue.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/mman.h>
@@ -27,6 +26,7 @@#include <ethdev_driver.h> #include <rte_malloc.h> #include <rte_memcpy.h> +#include <rte_queue.h> #include <rte_string_fns.h> #include <rte_cycles.h> #include <rte_kvargs.h>
@@ -403,6 +403,7 @@ dpaa2_create_dpio_device(int vdev_fd, struct rte_dpaa2_device *obj) {struct dpaa2_dpio_dev *dpio_dev =NULL ; +struct dpaa2_dpio_dev *dpio_tmp;struct vfio_region_info reg_info = { .argsz =sizeof (reg_info)};struct qbman_swp_desc p_des;struct dpio_attr attr;
@@ -588,7 +589,7 @@ dpaa2_create_dpio_device(int vdev_fd,rte_free (dpio_dev);/* For each element in the list, cleanup */ - TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) { + TAILQ_FOREACH_SAFE(dpio_dev, &dpio_dev_list, next, dpio_tmp) {if (dpio_dev->dpio) {dpio_disable (dpio_dev->dpio,CMD_PRI_LOW , dpio_dev->token);
Signature · 1 line
2.47.2
RE: [PATCH v2 3/7] bus/fslmc: fix use after free
PATCH v2 4/7 net/bnxt: fix use after free
In reply to Stephen HemmingerThe filter cleanup loop was using STAILQ_FOREACH and rte_free and would dereference the filter after free.
Found by build with -Dbsanitize=address,undefined
--- drivers/net/bnxt/bnxt_filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_filter.c +4 -4
@@ -3,14 +3,12 @@* All rights reserved. */ -#include <sys/queue.h> -#include <rte_byteorder.h> #include <rte_log.h> #include <rte_malloc.h> #include <rte_flow.h> #include <rte_flow_driver.h> -#include <rte_tailq.h> +#include <rte_queue.h> #include "bnxt.h" #include "bnxt_filter.h"
@@ -151,7 +149,9 @@ void bnxt_free_filter_mem(struct bnxt *bp) bp->filter_info =NULL ;for (i =0 ; i < bp->pf->max_vfs; i++) { - STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) { +struct bnxt_filter_info *tmp; + + STAILQ_FOREACH_SAFE(filter, &bp->pf->vf_info[i].filter, next, tmp) {rte_free (filter);STAILQ_REMOVE (&bp->pf->vf_info[i].filter, filter, bnxt_filter_info, next);
Signature · 1 line
2.47.2
PATCH v2 5/7 net/iavf: replace local version of TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerNow in EAL as rte_queue.h
--- drivers/net/intel/iavf/iavf_vchnl.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +1 -7
@@ -13,6 +13,7 @@#include <rte_byteorder.h> #include <rte_common.h> #include <rte_os_shim.h> +#include <rte_queue.h> #include <rte_debug.h> #include <rte_alarm.h>
@@ -52,13 +53,6 @@ static struct iavf_event_handler event_handler = { .fd = {-1, -1}, }; -#ifndef TAILQ_FOREACH_SAFE -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif -static uint32_t iavf_dev_event_handle(void *param __rte_unused) {
Signature · 1 line
2.47.2
PATCH v2 6/7 vhost: replace open coded TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerProper macro is now in EAL rte_queue.h use it instead.
--- lib/vhost/socket.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
lib/vhost/socket.c +2 -9
@@ -10,10 +10,10 @@#include <string.h> #include <sys/socket.h> #include <sys/un.h> -#include <sys/queue.h> #include <errno.h> #include <fcntl.h> +#include <rte_queue.h> #include <rte_thread.h> #include <rte_log.h>
@@ -456,14 +456,7 @@ vhost_user_client_reconnect(void *arg __rte_unused)while (1 ) {pthread_mutex_lock (&reconn_list.mutex); -/* -* An equal implementation of TAILQ_FOREACH_SAFE, -* which does not exist on all platforms. -*/ -for (reconn =TAILQ_FIRST (&reconn_list.head); - reconn !=NULL ; reconn = next) { - next =TAILQ_NEXT (reconn, next); - + TAILQ_FOREACH_SAFE(reconn, &reconn_list.head, next, next) { ret =vhost_user_connect_nonblock (reconn->vsocket->path, reconn->fd, (struct sockaddr *)&reconn->un,sizeof (reconn->un));
Signature · 1 line
2.47.2
PATCH v2 7/7 raw/ifpga: use EAL version of TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerPrefer the EAL version over local version of macro.
--- drivers/raw/ifpga/base/opae_osdep.h | 1 + 1 file changed, 1 insertion(+)
drivers/raw/ifpga/base/opae_osdep.h +1 -0
@@ -11,6 +11,7 @@#ifdef RTE_LIB_EAL #include "osdep_rte/osdep_generic.h" +#include <rte_queue.h> #else #include "osdep_raw/osdep_generic.h" #endif
Signature · 1 line
2.47.2
RE: [PATCH v2 0/7] Introduce FOREACH_SAFE macros
In reply to Stephen HemmingerQuoted 16 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Friday, 14 February 2025 18.20This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hChose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.
Quoted 2 lines
There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
100 % agree with all of the above.
Especially that adding RTE_ prefix to "industry standard" macros would be silly.
And all patches in this series LGTM.
v3 cover introduce common FOREACH_SAFE macros
In reply to Stephen HemmingerThis series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header sys/queue.h
Chose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros to RTE_XXX variants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.
There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
v3 - add a few more open coded loops that can use a macro
Stephen Hemminger (9):
eal: add queue macro extensions from FreeBSD net/qede: fix use after free
bus/fslmc: fix use after free
net/bnxt: fix use after free
net/iavf: replace local version of TAILQ_FOREACH_SAFE
vhost: replace open coded TAILQ_FOREACH_SAFE raw/ifpga: use EAL version of TAILQ_FOREACH_SAFE net/i40e: replace open coded version of LIST_FOREACH_SAFE net/ice: replace open coded version of LIST_FOREACH_SAFE
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 5 +- drivers/net/bnxt/bnxt_filter.c | 8 +- drivers/net/intel/i40e/i40e_ethdev.c | 9 +- drivers/net/intel/iavf/iavf_vchnl.c | 8 +- drivers/net/intel/ice/ice_ethdev.c | 9 +- drivers/net/qede/qede_ethdev.h | 3 +- drivers/net/qede/qede_filter.c | 13 +- drivers/raw/ifpga/base/ifpga_enumerate.c | 4 +- drivers/raw/ifpga/base/opae_osdep.h | 1 + lib/eal/include/meson.build | 3 +- lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++ lib/vhost/socket.c | 11 +- 12 files changed, 200 insertions(+), 48 deletions(-) create mode 100644 lib/eal/include/rte_queue.h
Signature · 1 line
2.47.2
PATCH v3 1/9 eal: add queue macro extensions from FreeBSD
The Linux version of sys/queue.h is frozen at an older version and is missing the _SAFE macro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL.
--- lib/eal/include/meson.build | 3 +- lib/eal/include/rte_queue.h | 174 ++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 lib/eal/include/rte_queue.h
lib/eal/include/meson.build +2 -1
@@ -19,8 +19,8 @@ headers += files( 'rte_eal.h', 'rte_eal_memconfig.h', 'rte_eal_trace.h', - 'rte_errno.h', 'rte_epoll.h', + 'rte_errno.h', 'rte_fbarray.h', 'rte_hexdump.h', 'rte_hypervisor.h',
@@ -38,6 +38,7 @@ headers += files( 'rte_pci_dev_features.h', 'rte_per_lcore.h', 'rte_pflock.h', + 'rte_queue.h', 'rte_random.h', 'rte_reciprocal.h', 'rte_seqcount.h',
lib/eal/include/rte_queue.h new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
2.47.2
PATCH v3 2/9 net/qede: fix use after free
In reply to Stephen HemmingerThe loop cleaning up flowdir resources was using SLIST_FOREACH but the inner loop would call rte_free. Found by building with address sanitizer undefined check.
Also remove needless initialization, and null check.
--- drivers/net/qede/qede_ethdev.h | 3 +-- drivers/net/qede/qede_filter.c | 13 +++++-------- 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/net/qede/qede_ethdev.h +1 -2
@@ -8,8 +8,7 @@#ifndef _QEDE_ETHDEV_H_#define _QEDE_ETHDEV_H_ -#include <sys/queue.h> - +#include <rte_queue.h> #include <rte_ether.h> #include <ethdev_driver.h> #include <ethdev_pci.h>
drivers/net/qede/qede_filter.c +5 -8
@@ -154,15 +154,12 @@ int qede_check_fdir_support(struct rte_eth_dev *eth_dev)void qede_fdir_dealloc_resc (struct rte_eth_dev *eth_dev) {struct qede_dev *qdev =QEDE_INIT_QDEV (eth_dev); -struct qede_arfs_entry *tmp =NULL ; +struct qede_arfs_entry *tmp, *tmp2; - SLIST_FOREACH(tmp, &qdev->arfs_info.arfs_list_head, list) { -if (tmp) { -rte_memzone_free (tmp->mz); -SLIST_REMOVE (&qdev->arfs_info.arfs_list_head, tmp, - qede_arfs_entry, list); -rte_free (tmp); - } + SLIST_FOREACH_SAFE(tmp, &qdev->arfs_info.arfs_list_head, list, tmp2) { +rte_memzone_free (tmp->mz); +SLIST_REMOVE (&qdev->arfs_info.arfs_list_head, tmp, qede_arfs_entry, list); +rte_free (tmp); } }
Signature · 1 line
2.47.2
PATCH v3 3/9 bus/fslmc: fix use after free
In reply to Stephen HemmingerThe cleanup loop would deference the dpio_dev after freeing. Use TAILQ_FOREACH_SAFE to fix that.
Found by building with sanitizer undefined flag.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3 -2
@@ -15,7 +15,6 @@#include <signal.h> #include <pthread.h> #include <sys/types.h> -#include <sys/queue.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/mman.h>
@@ -27,6 +26,7 @@#include <ethdev_driver.h> #include <rte_malloc.h> #include <rte_memcpy.h> +#include <rte_queue.h> #include <rte_string_fns.h> #include <rte_cycles.h> #include <rte_kvargs.h>
@@ -403,6 +403,7 @@ dpaa2_create_dpio_device(int vdev_fd, struct rte_dpaa2_device *obj) {struct dpaa2_dpio_dev *dpio_dev =NULL ; +struct dpaa2_dpio_dev *dpio_tmp;struct vfio_region_info reg_info = { .argsz =sizeof (reg_info)};struct qbman_swp_desc p_des;struct dpio_attr attr;
@@ -588,7 +589,7 @@ dpaa2_create_dpio_device(int vdev_fd,rte_free (dpio_dev);/* For each element in the list, cleanup */ - TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) { + TAILQ_FOREACH_SAFE(dpio_dev, &dpio_dev_list, next, dpio_tmp) {if (dpio_dev->dpio) {dpio_disable (dpio_dev->dpio,CMD_PRI_LOW , dpio_dev->token);
Signature · 1 line
2.47.2
PATCH v3 4/9 net/bnxt: fix use after free
In reply to Stephen HemmingerThe filter cleanup loop was using STAILQ_FOREACH and rte_free and would dereference the filter after free.
Found by build with -Dbsanitize=address,undefined
--- drivers/net/bnxt/bnxt_filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_filter.c +4 -4
@@ -3,14 +3,12 @@* All rights reserved. */ -#include <sys/queue.h> -#include <rte_byteorder.h> #include <rte_log.h> #include <rte_malloc.h> #include <rte_flow.h> #include <rte_flow_driver.h> -#include <rte_tailq.h> +#include <rte_queue.h> #include "bnxt.h" #include "bnxt_filter.h"
@@ -151,7 +149,9 @@ void bnxt_free_filter_mem(struct bnxt *bp) bp->filter_info =NULL ;for (i =0 ; i < bp->pf->max_vfs; i++) { - STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) { +struct bnxt_filter_info *tmp; + + STAILQ_FOREACH_SAFE(filter, &bp->pf->vf_info[i].filter, next, tmp) {rte_free (filter);STAILQ_REMOVE (&bp->pf->vf_info[i].filter, filter, bnxt_filter_info, next);
Signature · 1 line
2.47.2
PATCH v3 5/9 net/iavf: replace local version of TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerNow in EAL as rte_queue.h
--- drivers/net/intel/iavf/iavf_vchnl.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/intel/iavf/iavf_vchnl.c +1 -7
@@ -13,6 +13,7 @@#include <rte_byteorder.h> #include <rte_common.h> #include <rte_os_shim.h> +#include <rte_queue.h> #include <rte_debug.h> #include <rte_alarm.h>
@@ -52,13 +53,6 @@ static struct iavf_event_handler event_handler = { .fd = {-1, -1}, }; -#ifndef TAILQ_FOREACH_SAFE -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif -static uint32_t iavf_dev_event_handle(void *param __rte_unused) {
Signature · 1 line
2.47.2
PATCH v3 6/9 vhost: replace open coded TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerProper macro is now in EAL rte_queue.h use it instead.
--- lib/vhost/socket.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
lib/vhost/socket.c +2 -9
@@ -10,10 +10,10 @@#include <string.h> #include <sys/socket.h> #include <sys/un.h> -#include <sys/queue.h> #include <errno.h> #include <fcntl.h> +#include <rte_queue.h> #include <rte_thread.h> #include <rte_log.h>
@@ -456,14 +456,7 @@ vhost_user_client_reconnect(void *arg __rte_unused)while (1 ) {pthread_mutex_lock (&reconn_list.mutex); -/* -* An equal implementation of TAILQ_FOREACH_SAFE, -* which does not exist on all platforms. -*/ -for (reconn =TAILQ_FIRST (&reconn_list.head); - reconn !=NULL ; reconn = next) { - next =TAILQ_NEXT (reconn, next); - + TAILQ_FOREACH_SAFE(reconn, &reconn_list.head, next, next) { ret =vhost_user_connect_nonblock (reconn->vsocket->path, reconn->fd, (struct sockaddr *)&reconn->un,sizeof (reconn->un));
Signature · 1 line
2.47.2
PATCH v3 7/9 raw/ifpga: use EAL version of TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerPrefer the EAL version over local version of macro.
--- drivers/raw/ifpga/base/ifpga_enumerate.c | 4 +--- drivers/raw/ifpga/base/opae_osdep.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/raw/ifpga/base/ifpga_enumerate.c +1 -3
@@ -725,9 +725,7 @@ static void dfl_fpga_enum_info_free(struct dfl_fpga_enum_info *info)return ;/* remove all device feature lists in the list. */ -for (dfl =TAILQ_FIRST (&info->dfls); - dfl && (tmp =TAILQ_NEXT (dfl, node),1 ); - dfl = tmp) { + TAILQ_FOREACH_SAFE(dfl, &info->dfls, node, tmp) {TAILQ_REMOVE (&info->dfls, dfl, node);opae_free (dfl); }
drivers/raw/ifpga/base/opae_osdep.h +1 -0
@@ -11,6 +11,7 @@#ifdef RTE_LIB_EAL #include "osdep_rte/osdep_generic.h" +#include <rte_queue.h> #else #include "osdep_raw/osdep_generic.h" #endif
Signature · 1 line
2.47.2
PATCH v3 8/9 net/i40e: replace open coded version of LIST_FOREACH_SAFE
In reply to Stephen HemmingerUse macro instead.
--- drivers/net/intel/i40e/i40e_ethdev.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +3 -6
@@ -29,6 +29,7 @@#include <rte_hash_crc.h> #include <rte_bitmap.h> #include <rte_os_shim.h> +#include <rte_queue.h> #include "i40e_logs.h" #include "base/i40e_prototype.h"
@@ -5096,16 +5097,12 @@ i40e_res_pool_destroy(struct i40e_res_pool_info *pool)if (pool ==NULL )return ; -for (entry =LIST_FIRST (&pool->alloc_list); - entry && (next_entry =LIST_NEXT (entry, next),1 ); - entry = next_entry) { + LIST_FOREACH_SAFE(entry, &pool->alloc_list, next, next_entry) {LIST_REMOVE (entry, next);rte_free (entry); } -for (entry =LIST_FIRST (&pool->free_list); - entry && (next_entry =LIST_NEXT (entry, next),1 ); - entry = next_entry) { + LIST_FOREACH_SAFE(entry, &pool->free_list, next, next_entry) {LIST_REMOVE (entry, next);rte_free (entry); }
Signature · 1 line
2.47.2
Re: [PATCH v3 8/9] net/i40e: replace open coded version of LIST_FOREACH_SAFE
Quoted 4 lines · Stephen Hemminger
Use macro instead.
Signed-off-by Stephen Hemminger <[email protected]>---
Signature · 2 lines
Thanks, Anatoly
PATCH v3 9/9 net/ice: replace open coded version of LIST_FOREACH_SAFE
In reply to Stephen HemmingerUse macro instead.
--- drivers/net/intel/ice/ice_ethdev.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +3 -6
@@ -15,6 +15,7 @@#include <rte_tailq.h> #include <rte_os_shim.h> +#include <rte_queue.h> #include "eal_firmware.h"
@@ -884,16 +885,12 @@ ice_res_pool_destroy(struct ice_res_pool_info *pool)if (!pool)return ; -for (entry =LIST_FIRST (&pool->alloc_list); - entry && (next_entry =LIST_NEXT (entry, next),1 ); - entry = next_entry) { + LIST_FOREACH_SAFE(entry, &pool->alloc_list, next, next_entry) {LIST_REMOVE (entry, next);rte_free (entry); } -for (entry =LIST_FIRST (&pool->free_list); - entry && (next_entry =LIST_NEXT (entry, next),1 ); - entry = next_entry) { + LIST_FOREACH_SAFE(entry, &pool->free_list, next, next_entry) {LIST_REMOVE (entry, next);rte_free (entry); }
Signature · 1 line
2.47.2
Re: [PATCH v3 9/9] net/ice: replace open coded version of LIST_FOREACH_SAFE
Quoted 4 lines · Stephen Hemminger
Use macro instead.
Signed-off-by Stephen Hemminger <[email protected]>---
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v3 0/9] introduce common FOREACH_SAFE macros
In reply to Stephen HemmingerQuoted 29 lines · On Wed, 12 Mar 2025 16:15:29 -0700 Stephen Hemminger…
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hChose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
v3 - add a few more open coded loops that can use a macro
Stephen Hemminger (9):
eal: add queue macro extensions from FreeBSD net/qede: fix use after free
bus/fslmc: fix use after free
net/bnxt: fix use after free
net/iavf: replace local version ofTAILQ_FOREACH_SAFE
vhost: replace open codedTAILQ_FOREACH_SAFEraw/ifpga: use EAL version ofTAILQ_FOREACH_SAFEnet/i40e: replace open coded version ofLIST_FOREACH_SAFEnet/ice: replace open coded version ofLIST_FOREACH_SAFE
Quoted 11 lines
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 5 +- drivers/net/bnxt/bnxt_filter.c | 8 +- drivers/net/intel/i40e/i40e_ethdev.c | 9 +- drivers/net/intel/iavf/iavf_vchnl.c | 8 +- drivers/net/intel/ice/ice_ethdev.c | 9 +- drivers/net/qede/qede_ethdev.h | 3 +- drivers/net/qede/qede_filter.c | 13 +- drivers/raw/ifpga/base/ifpga_enumerate.c | 4 +- drivers/raw/ifpga/base/opae_osdep.h | 1 + lib/eal/include/meson.build | 3 +- lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++
Revisiting this and wondering about naming...
The file rte_queue.h is not really DPDK (ie not related to runtime environment). Thinking of calling it bsd_queue.h as a comprimise
RE: [PATCH v3 0/9] introduce common FOREACH_SAFE macros
Quoted 22 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 18 August 2025 18.34Quoted 16 lines · On Wed, 12 Mar 2025 16:15:29 -0700 Stephen Hemminger…
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hChose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
Quoted 6 lines
Quoted 1 line
lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++Revisiting this and wondering about naming...
The filerte_queue.his not really DPDK (ie not related to runtime environment).
Thinking of calling itbsd_queue.has a compromise
Since it replaces sys/queue.h, then maybe sys_queue.h (or rte_sys_queue.h).
But more importantly:
It is not really DPDK, and thus shouldn't really be part of the EAL.
So here's an idea:
As part of de-bloating the EAL, can we somehow add a new directory structure for independent "libraries" like this? And treat this rte_queue.h file as a "header file only" library, and put it there.
Then, build wise, the EAL could depend on this "library".
Re: [PATCH v3 0/9] introduce common FOREACH_SAFE macros
Quoted 29 lines · Morten Brørup
Quoted 22 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 18 August 2025 18.34Quoted 16 lines · On Wed, 12 Mar 2025 16:15:29 -0700 Stephen Hemminger…
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hChose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
Quoted 6 lines
Quoted 1 line
lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++Revisiting this and wondering about naming...
The filerte_queue.his not really DPDK (ie not related to runtime environment).
Thinking of calling itbsd_queue.has a compromise
Quoted 9 lines
Since it replaces
sys/queue.h, then maybesys_queue.h(orrte_sys_queue.h).But more importantly:
It is not really DPDK, and thus shouldn't really be part of the EAL.
So here's an idea:
As part of de-bloating the EAL, can we somehow add a new directory structure for independent "libraries" like this? And treat thisrte_queue.hfile as a "header file only" library, and put it there.
Then, build wise, the EAL could depend on this "library".
IMO it depends on what you mean by "EAL". EAL is environment abstraction layer, and this header abstracts OS, thereby meeting description of an "environment abstraction layer"?
Signature · 2 lines
Thanks, Anatoly
RE: [PATCH v3 0/9] introduce common FOREACH_SAFE macros
Quoted 40 lines
From: Burakov, Anatoly [mailto:[email protected]]
Sent: Wednesday, 27 August 2025 16.14Quoted 29 lines · Morten Brørup
Quoted 22 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 18 August 2025 18.34Quoted 16 lines · On Wed, 12 Mar 2025 16:15:29 -0700 Stephen Hemminger…
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hChose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
Quoted 6 lines
Quoted 1 line
lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++Revisiting this and wondering about naming...
The filerte_queue.his not really DPDK (ie not related to runtime environment).
Thinking of calling itbsd_queue.has a compromiseQuoted 6 lines
Since it replaces
sys/queue.h, then maybesys_queue.h(orrte_sys_queue.h).But more importantly:
It is not really DPDK, and thus shouldn't really be part of the EAL. So here's an idea:
As part of de-bloating the EAL, can we somehow add a new directory structurefor independent "libraries" like this?
Quoted 8 lines
Quoted 1 line
And treat this
rte_queue.hfile as a "header file only" library, and put itthere.
Quoted 2 lines
Then, build wise, the EAL could depend on this "library".
IMO it depends on what you mean by "EAL". EAL is environment abstraction layer, and this header abstracts OS, thereby meeting description of an "environment abstraction layer"?
This library (header file) is generic, and has zero interaction with the hardware and OS, so it's not an environment abstraction. The EAL has become a dump for "everything else" that isn't an individual library with its own subdirectory of the /lib directory. IMO, it would be nice if we could separate generic utility libraries from the EAL.
Re: [PATCH v3 0/9] introduce common FOREACH_SAFE macros
27/08/2025 17:08, Morten Brørup:
Quoted 42 lines
Quoted 42 lines
From: Burakov, Anatoly [mailto:[email protected]]
Sent: Wednesday, 27 August 2025 16.14Quoted 29 lines · Morten Brørup
Quoted 22 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 18 August 2025 18.34Quoted 16 lines · On Wed, 12 Mar 2025 16:15:29 -0700 Stephen Hemminger…
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hChose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
Quoted 6 lines
Quoted 1 line
lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++Revisiting this and wondering about naming...
The filerte_queue.his not really DPDK (ie not related to runtime environment).
Thinking of calling itbsd_queue.has a compromiseQuoted 6 lines
Since it replaces
sys/queue.h, then maybesys_queue.h(orrte_sys_queue.h).But more importantly:
It is not really DPDK, and thus shouldn't really be part of the EAL. So here's an idea:
As part of de-bloating the EAL, can we somehow add a new directory structurefor independent "libraries" like this?
Quoted 1 line
And treat this
rte_queue.hfile as a "header file only" library, and put itthere.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Then, build wise, the EAL could depend on this "library".
IMO it depends on what you mean by "EAL". EAL is environment abstraction layer, and this header abstracts OS, thereby meeting description of an "environment abstraction layer"?
This library (header file) is generic, and has zero interaction with the hardware and OS, so it's not an environment abstraction.
I disagree here, it is something due by the OS libc, but not reliably available everywhere.
Quoted 2 lines
The EAL has become a dump for "everything else" that isn't an individual library with its own subdirectory of the /lib directory. IMO, it would be nice if we could separate generic utility libraries from the EAL.
I agree with the goal of having a thinner EAL.
I'm not sure about this one.
RE: [PATCH v3 0/9] introduce common FOREACH_SAFE macros
Quoted 63 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 27 August 2025 17.1227/08/2025 17:08, Morten Brørup:
Quoted 23 lines
Quoted 23 lines
From: Burakov, Anatoly [mailto:[email protected]]
Sent: Wednesday, 27 August 2025 16.14Quoted 19 lines · Morten Brørup
Quoted 19 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 18 August 2025 18.34Quoted 13 lines · On Wed, 12 Mar 2025 16:15:29 -0700 Stephen Hemminger…
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hChose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
lib/eal/include/rte_queue.h | 174+++++++++++++++++++++++
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Revisiting this and wondering about naming...
The filerte_queue.his not really DPDK (ie not related to runtime environment).
Thinking of calling itbsd_queue.has a compromiseSince it replaces
sys/queue.h, then maybesys_queue.h(or
rte_sys_queue.h).Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
But more importantly:
It is not really DPDK, and thus shouldn't really be part of the EAL. So here's an idea:
As part of de-bloating the EAL, can we somehow add a new directorystructure
Quoted 2 lines
Quoted 2 lines
for independent "libraries" like this?
Quoted 1 line
And treat this
rte_queue.hfile as a "header file only" library, and putit
Quoted 9 lines
Quoted 7 lines
there.
Quoted 2 lines
Then, build wise, the EAL could depend on this "library".
IMO it depends on what you mean by "EAL". EAL is environment abstraction layer, and this header abstracts OS, thereby meeting description of an "environment abstraction layer"?
This library (header file) is generic, and has zero interaction with the
hardware and OS, so it's not an environment abstraction.
I disagree here, it is something due by the OS libc, but not reliably available everywhere.
Quoted 8 lines
Quoted 1 line
The EAL has become a dump for "everything else" that isn't an individual
library with its own subdirectory of the /lib directory.
Quoted 1 line
IMO, it would be nice if we could separate generic utility libraries from
the EAL.
I agree with the goal of having a thinner EAL.
I'm not sure about this one.
I thought this file might be a good place to start separating utilities from abstraction. However, a well designed roadmap to re-organize the EAL is probably better than starting with this specific library.
Sorry (not sorry) about the noise. I will keep reminding the community about the bloated EAL from time to time. :-)
Re: [PATCH v3 0/9] introduce common FOREACH_SAFE macros
In reply to Morten BrørupQuoted 45 lines · Morten Brørup
Quoted 45 lines
From: Burakov, Anatoly [mailto:[email protected]]
Sent: Wednesday, 27 August 2025 16.14Quoted 29 lines · Morten Brørup
Quoted 22 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 18 August 2025 18.34Quoted 16 lines · On Wed, 12 Mar 2025 16:15:29 -0700 Stephen Hemminger…
This series adds common macros for safe iteration over lists. It is a subset copy of the macros from FreeBSD that are missing from the Linux header
sys/queue.hChose this over several other options:
- let each driver define their own as needed.
One Intel driver got it wrong, others will as well.
- rename all the queue macros toRTE_XXXvariants. Seems like useless renaming and confusion.
- Several distros have libbsd package with the correct macros. But adding yet another dependency to DPDK would be annoying for something this basic.There are more macros in FreeBSD header that could be useful, but we can add those later as needed here.
Quoted 6 lines
Quoted 1 line
lib/eal/include/rte_queue.h | 174 +++++++++++++++++++++++Revisiting this and wondering about naming...
The filerte_queue.his not really DPDK (ie not related to runtime environment).
Thinking of calling itbsd_queue.has a compromiseQuoted 6 lines
Since it replaces
sys/queue.h, then maybesys_queue.h(orrte_sys_queue.h).But more importantly:
It is not really DPDK, and thus shouldn't really be part of the EAL. So here's an idea:
As part of de-bloating the EAL, can we somehow add a new directory structurefor independent "libraries" like this?
Quoted 1 line
And treat this
rte_queue.hfile as a "header file only" library, and put itthere.
Quoted 2 lines
Then, build wise, the EAL could depend on this "library".
Quoted 8 lines
Quoted 3 lines
IMO it depends on what you mean by "EAL". EAL is environment abstraction layer, and this header abstracts OS, thereby meeting description of an "environment abstraction layer"?
This library (header file) is generic, and has zero interaction with the hardware and OS, so it's not an environment abstraction. The EAL has become a dump for "everything else" that isn't an individual library with its own subdirectory of the /lib directory. IMO, it would be nice if we could separate generic utility libraries from the EAL.
We could start fairly easily by extracting out generic utility headers, no?
/Bruce
Re: [PATCH v3 0/9] introduce common FOREACH_SAFE macros
Quoted 5 lines · On Wed, 27 Aug 2025 16:55:12 +0100 Bruce Richardson…
Quoted 4 lines
This library (header file) is generic, and has zero interaction with the hardware and OS, so it's not an environment abstraction. The EAL has become a dump for "everything else" that isn't an individual library with its own subdirectory of the /lib directory. IMO, it would be nice if we could separate generic utility libraries from the EAL.
We could start fairly easily by extracting out generic utility headers, no?
Vendoring OS headers is a bad, bad idea.