Add support for driver directories
cover Add support for driver directories
This mini-series adds support for driver directory concept as described by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.html
Panu Matilainen (2):
eal: refactor plugin list append from eal_parse_args() to a helper
function
eal: add support for driver directory concept
config/common_linuxapp | 3 ++ lib/librte_eal/common/eal_common_options.c | 1 + lib/librte_eal/linuxapp/eal/eal.c | 76 ++++++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 9 deletions(-)
Signature · 1 line
2.4.3
PATCH 1/2 eal: refactor plugin list append from eal_parse_args() to a helper function
--- lib/librte_eal/linuxapp/eal/eal.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +19 -9
@@ -530,6 +530,24 @@ eal_log_level_parse(int argc, char **argv) optind =0 ;/* reset getopt lib */ } +static int +eal_add_solib (const char *path) +{ +struct shared_driver *solib; + + solib =malloc (sizeof (*solib)); +if (solib ==NULL ) { +RTE_LOG (ERR ,EAL ,"malloc(solib) failed\n" ); +return -1 ; + } +memset (solib,0 ,sizeof (*solib)); +strncpy (solib->name, path,PATH_MAX -1 ); + solib->name[PATH_MAX -1 ] =0 ; +TAILQ_INSERT_TAIL (&solib_list, solib, next); + +return 0 ; +} +/* Parse the argument given in the command line of the application */ static int eal_parse_args (int argc,char **argv)
@@ -538,7 +556,6 @@ eal_parse_args(int argc, char **argv)char **argvopt;int option_index;char *prgname = argv[0 ]; -struct shared_driver *solib; argvopt = argv;
@@ -570,15 +587,8 @@ eal_parse_args(int argc, char **argv)/* force loading of external driver */ case 'd' : - solib =malloc (sizeof (*solib)); -if (solib ==NULL ) { -RTE_LOG (ERR ,EAL ,"malloc(solib) failed\n" ); +if (eal_add_solib (optarg) ==-1 )return -1 ; - } -memset (solib,0 ,sizeof (*solib)); -strncpy (solib->name, optarg,PATH_MAX -1 ); - solib->name[PATH_MAX -1 ] =0 ; -TAILQ_INSERT_TAIL (&solib_list, solib, next);break ;/* long options */
Signature · 1 line
2.4.3
PATCH 2/2 eal: add support for driver directory concept
In reply to Panu MatilainenAdd a new EAL option -D for loading all drivers from a given directory. Additionally a default driver directory can be set in build-time configuration, in which case it will be always be used when EAL is initialized (but can be overridden or disabled with -D).
This simplifies usage in shared library configuration significantly over manually loading individual drivers with -d, and allows distros to establish a drop-in driver directory for seamless integration with 3rd party drivers etc.
--- config/common_linuxapp | 3 ++ lib/librte_eal/common/eal_common_options.c | 1 + lib/librte_eal/linuxapp/eal/eal.c | 48 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+)
config/common_linuxapp +3 -0
@@ -111,6 +111,9 @@ CONFIG_RTE_EAL_IGB_UIO=y CONFIG_RTE_EAL_VFIO=y CONFIG_RTE_MALLOC_DEBUG=n +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + # # Special configurations in PCI Config Space for high performance #
lib/librte_eal/common/eal_common_options.c +1 -0
@@ -58,6 +58,7 @@ eal_short_options[] ="b:" /* pci-blacklist */ "c:" /* coremask */ "d:" /* driver */ +"D:" /* driver directory */ "h" /* help */ "l:" /* corelist */ "m:" /* memory size */
lib/librte_eal/linuxapp/eal/eal.c +48 -0
84 lines not on this page · raw message
Signature · 1 line
2.4.3
Hello Panu,
Quoted 9 lines · Panu Matilainen
This mini-series adds support for driver directory concept as described by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.htmlPanu Matilainen (2):
eal: refactor plugin list append fromeal_parse_args()to a helper
function
eal: add support for driver directory concept
Quoted 6 lines
config/common_linuxapp | 3 ++ lib/librte_eal/common/eal_common_options.c | 1 + lib/librte_eal/linuxapp/eal/eal.c | 76 ++++++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 9 deletions(-)
This patchset looks good to me.
Is there any reason why we should only have this for linux ?
Signature · 1 line
David Marchand
Quoted 21 lines · David Marchand
Hello Panu,
On Fri, Sep 25, 2015 at 1:58 PM, Panu Matilainen <[email protected] <mailto:[email protected]>> wrote:
This mini-series adds support for driver directory concept as described by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.htmlPanu Matilainen (2):
eal: refactor plugin list append fromeal_parse_args()to a helper
function
eal: add support for driver directory conceptconfig/common_linuxapp | 3 ++
lib/librte_eal/common/eal_common_options.c| 1 +
lib/librte_eal/linuxapp/eal/eal.c| 76
++++++++++++++++++++++++++----
3 files changed, 71 insertions(+), 9 deletions(-)
Quoted 2 lines
This patchset looks good to me.
Is there any reason why we should only have this for linux ?
I merely followed suite with the related, pre-existing -d option which also only exists for Linux. And wondered about the same thing :)
- Panu -
Quoted 22 lines · Panu Matilainen
Quoted 21 lines · David Marchand
Hello Panu,
On Fri, Sep 25, 2015 at 1:58 PM, Panu Matilainen <[email protected] <mailto:[email protected]>> wrote:
This mini-series adds support for driver directory concept as described by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.htmlPanu Matilainen (2):
eal: refactor plugin list append fromeal_parse_args()to a helper
function
eal: add support for driver directory conceptconfig/common_linuxapp | 3 ++
lib/librte_eal/common/eal_common_options.c| 1 +
lib/librte_eal/linuxapp/eal/eal.c| 76
++++++++++++++++++++++++++----
3 files changed, 71 insertions(+), 9 deletions(-)
Quoted 5 lines
Quoted 2 lines
This patchset looks good to me.
Is there any reason why we should only have this for linux ?I merely followed suite with the related, pre-existing -d option which also only exists for Linux. And wondered about the same thing :)
So...
Is this blocking on being Linux-only? I can have a look at moving the initialization to common/ if needed, but I wont be able test on FreeBSD. I'd just like to get this functionality into DPDK 2.2 to remove one of those silly usability obstacles thats all :)
- Panu -
Quoted 11 lines · Panu Matilainen
Quoted 8 lines · Panu Matilainen
Quoted 2 lines · David Marchand
Is there any reason why we should only have this for linux ?
I merely followed suite with the related, pre-existing -d option which also only exists for Linux. And wondered about the same thing :)
Quoted 6 lines
So...
Is this blocking on being Linux-only? I can have a look at moving the initialization to common/ if needed, but I wont be able test on FreeBSD. I'd just like to get this functionality into DPDK 2.2 to remove one of those silly usability obstacles thats all :)
Yes this would make it simpler.
Not blocking, but if you can move this to common code, then all better. I am pretty sure someone can test this on FreeBSD, Bruce maybe ? :-)
Signature · 1 line
David Marchand
v2 cover Add support for driver directories
In reply to Panu MatilainenThis series adds support for driver directory concept based on idea by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.html
In the process FreeBSD also gains plugin support (but untested).
Panu Matilainen (5):
eal: refactor plugin list append from eal_parse_args() to a helper
function
eal: refactor plugin init from eal_parse_args() to a helper function
eal: move plugin loading to eal/common
eal: add an error code to plugin init for the next step
eal: add support for driver directory concept
config/common_bsdapp | 3 + config/common_linuxapp | 3 + lib/librte_eal/bsdapp/eal/eal.c | 3 + lib/librte_eal/common/eal_common_options.c | 103 +++++++++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 1 + lib/librte_eal/linuxapp/eal/eal.c | 39 +---------- 6 files changed, 115 insertions(+), 37 deletions(-)
Signature · 1 line
2.4.3
PATCH v2 1/5 eal: refactor plugin list append from eal_parse_args() to a helper function
--- lib/librte_eal/linuxapp/eal/eal.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +19 -9
@@ -530,6 +530,24 @@ eal_log_level_parse(int argc, char **argv) optind =0 ;/* reset getopt lib */ } +static int +eal_plugin_add (const char *path) +{ +struct shared_driver *solib; + + solib =malloc (sizeof (*solib)); +if (solib ==NULL ) { +RTE_LOG (ERR ,EAL ,"malloc(solib) failed\n" ); +return -1 ; + } +memset (solib,0 ,sizeof (*solib)); +strncpy (solib->name, path,PATH_MAX -1 ); + solib->name[PATH_MAX -1 ] =0 ; +TAILQ_INSERT_TAIL (&solib_list, solib, next); + +return 0 ; +} +/* Parse the argument given in the command line of the application */ static int eal_parse_args (int argc,char **argv)
@@ -538,7 +556,6 @@ eal_parse_args(int argc, char **argv)char **argvopt;int option_index;char *prgname = argv[0 ]; -struct shared_driver *solib; argvopt = argv;
@@ -570,15 +587,8 @@ eal_parse_args(int argc, char **argv)/* force loading of external driver */ case 'd' : - solib =malloc (sizeof (*solib)); -if (solib ==NULL ) { -RTE_LOG (ERR ,EAL ,"malloc(solib) failed\n" ); +if (eal_plugin_add (optarg) ==-1 )return -1 ; - } -memset (solib,0 ,sizeof (*solib)); -strncpy (solib->name, optarg,PATH_MAX -1 ); - solib->name[PATH_MAX -1 ] =0 ; -TAILQ_INSERT_TAIL (&solib_list, solib, next);break ;/* long options */
Signature · 1 line
2.4.3
PATCH v2 2/5 eal: refactor plugin init from eal_parse_args() to a helper function
In reply to Panu Matilainen--- lib/librte_eal/linuxapp/eal/eal.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +14 -7
@@ -548,6 +548,19 @@ eal_plugin_add(const char *path)return 0 ; } +static void +eal_plugins_init (void ) +{ +struct shared_driver *solib =NULL ; + + TAILQ_FOREACH(solib, &solib_list, next) { +RTE_LOG (DEBUG ,EAL ,"open shared lib %s\n" , solib->name); + solib->lib_handle =dlopen (solib->name,RTLD_NOW ); +if (solib->lib_handle ==NULL ) +RTE_LOG (WARNING ,EAL ,"%s\n" ,dlerror ()); + } +} +/* Parse the argument given in the command line of the application */ static int eal_parse_args (int argc,char **argv)
@@ -741,7 +754,6 @@ rte_eal_init(int argc, char **argv)int i, fctret, ret;pthread_t thread_id;static rte_atomic32_t run_once =RTE_ATOMIC32_INIT (0 ); -struct shared_driver *solib =NULL ;const char *logid;char cpuset[RTE_CPU_AFFINITY_STR_LEN ];
@@ -837,12 +849,7 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); - TAILQ_FOREACH(solib, &solib_list, next) { -RTE_LOG (DEBUG ,EAL ,"open shared lib %s\n" , solib->name); - solib->lib_handle =dlopen (solib->name,RTLD_NOW ); -if (solib->lib_handle ==NULL ) -RTE_LOG (WARNING ,EAL ,"%s\n" ,dlerror ()); - } +eal_plugins_init ();eal_thread_init_master (rte_config.master_lcore);
Signature · 1 line
2.4.3
PATCH v2 3/5 eal: move plugin loading to eal/common
In reply to Panu MatilainenThere's no good reason to limit plugins to Linux, make it available on FreeBSD too.
--- lib/librte_eal/bsdapp/eal/eal.c | 2 ++ lib/librte_eal/common/eal_common_options.c | 52 +++++++++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 1 + lib/librte_eal/linuxapp/eal/eal.c | 53 ------------------------------ 4 files changed, 55 insertions(+), 53 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +2 -0
@@ -543,6 +543,8 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); +eal_plugins_init (); +eal_thread_init_master (rte_config.master_lcore); ret =eal_thread_dump_affinity (cpuset,RTE_CPU_AFFINITY_STR_LEN );
lib/librte_eal/common/eal_common_options.c +52 -0
82 lines not on this page · raw message
lib/librte_eal/common/eal_options.h +1 -0
@@ -93,5 +93,6 @@ int eal_adjust_config(struct internal_config *internal_cfg);int eal_check_common_options (struct internal_config *internal_cfg);void eal_common_usage (void );enum rte_proc_type_t eal_proc_type_detect (void ); +void eal_plugins_init (void );#endif /* EAL_OPTIONS_H */
lib/librte_eal/linuxapp/eal/eal.c +0 -53
83 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH v2 4/5 eal: add an error code to plugin init for the next step
In reply to Panu Matilainen--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++- lib/librte_eal/common/eal_common_options.c | 3 ++- lib/librte_eal/common/eal_options.h | 2 +- lib/librte_eal/linuxapp/eal/eal.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +2 -1
@@ -543,7 +543,8 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); -eal_plugins_init (); +if (eal_plugins_init () <0 ) +rte_panic ("Cannot init plugins\n" );eal_thread_init_master (rte_config.master_lcore);
lib/librte_eal/common/eal_common_options.c +2 -1
@@ -167,7 +167,7 @@ eal_plugin_add(const char *path)return 0 ; } -void +int eal_plugins_init (void ) {struct shared_driver *solib =NULL ;
@@ -178,6 +178,7 @@ eal_plugins_init(void)if (solib->lib_handle ==NULL )RTE_LOG (WARNING ,EAL ,"%s\n" ,dlerror ()); } +return 0 ; }/*
lib/librte_eal/common/eal_options.h +1 -1
@@ -93,6 +93,6 @@ int eal_adjust_config(struct internal_config *internal_cfg);int eal_check_common_options (struct internal_config *internal_cfg);void eal_common_usage (void );enum rte_proc_type_t eal_proc_type_detect (void ); -void eal_plugins_init (void ); +int eal_plugins_init (void );#endif /* EAL_OPTIONS_H */
lib/librte_eal/linuxapp/eal/eal.c +2 -1
@@ -796,7 +796,8 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); -eal_plugins_init (); +if (eal_plugins_init () <0 ) +rte_panic ("Cannot init plugins\n" );eal_thread_init_master (rte_config.master_lcore);
Signature · 1 line
2.4.3
PATCH v2 5/5 eal: add support for driver directory concept
In reply to Panu MatilainenAdd a new EAL option -D for loading all drivers from a given directory. Additionally a default driver directory can be set in build-time configuration, in which case it will be always be used when EAL is initialized (but can be overridden or disabled with -D).
This simplifies usage in shared library configuration significantly over manually loading individual drivers with -d, and allows distros to establish a drop-in driver directory for seamless integration with 3rd party drivers etc.
--- config/common_bsdapp | 3 ++ config/common_linuxapp | 3 ++ lib/librte_eal/common/eal_common_options.c | 50 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)
config/common_bsdapp +3 -0
@@ -108,6 +108,9 @@ CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_MALLOC_DEBUG=n +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + # # FreeBSD contiguous memory driver settings #
config/common_linuxapp +3 -0
@@ -111,6 +111,9 @@ CONFIG_RTE_EAL_IGB_UIO=y CONFIG_RTE_EAL_VFIO=y CONFIG_RTE_MALLOC_DEBUG=n +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + # # Special configurations in PCI Config Space for high performance #
lib/librte_eal/common/eal_common_options.c +50 -0
91 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH 1/5] eal: refactor plugin list append from eal_parse_args() to a helper function
In reply to Panu MatilainenQuoted 16 lines · Panu Matilainen
Signed-off-by Panu Matilainen <[email protected]>--- lib/librte_eal/linuxapp/eal/eal.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)lib/librte_eal/linuxapp/eal/eal.c +3
-0@@ -530,6 +530,24 @@ eal_log_level_parse(int argc, char **argv) optind =0 ;/* reset getopt lib */ } +static int +eal_plugin_add (const char *path) +{
lib/librte_eal/linuxapp/eal/eal.c eal_log_level_parse(int argc, char **argv) · line 545
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal.c +10
-0+struct shared_driver *solib; + + solib =malloc (sizeof (*solib)); +if (solib ==NULL ) { +RTE_LOG (ERR ,EAL ,"malloc(solib) failed\n" ); +return -1 ; + } +memset (solib,0 ,sizeof (*solib)); +strncpy (solib->name, path,PATH_MAX -1 ); + solib->name[PATH_MAX -1 ] =0 ;
I always prefer a one-line snprintf to the above two-line code. :-)
/Bruce
Re: [PATCH 4/5] eal: add an error code to plugin init for the next step
In reply to Panu MatilainenQuoted 7 lines · Panu Matilainen
Signed-off-by Panu Matilainen <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++- lib/librte_eal/common/eal_common_options.c | 3 ++- lib/librte_eal/common/eal_options.h | 2 +- lib/librte_eal/linuxapp/eal/eal.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)
Again, another minor nit, but couldn't this be done when refactoring in previous patches, rather than needed a whole separate commit ?
/Bruce
Re: [PATCH 1/5] eal: refactor plugin list append from eal_parse_args() to a helper function
In reply to Bruce RichardsonQuoted 14 lines · Bruce Richardson
Quoted 13 lines · Panu Matilainen
Signed-off-by Panu Matilainen <[email protected]>--- lib/librte_eal/linuxapp/eal/eal.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)lib/librte_eal/linuxapp/eal/eal.c +0
-0@@ -530,6 +530,24 @@ eal_log_level_parse(int argc, char **argv) optind =0 ;/* reset getopt lib */ }
Quoted 15 lines
lib/librte_eal/linuxapp/eal/eal.c eal_log_level_parse(int argc, char **argv) · line 545
Quoted 13 lines
lib/librte_eal/linuxapp/eal/eal.c +13
-0+static int +eal_plugin_add (const char *path) +{ +struct shared_driver *solib; + + solib =malloc (sizeof (*solib)); +if (solib ==NULL ) { +RTE_LOG (ERR ,EAL ,"malloc(solib) failed\n" ); +return -1 ; + } +memset (solib,0 ,sizeof (*solib)); +strncpy (solib->name, path,PATH_MAX -1 ); + solib->name[PATH_MAX -1 ] =0 ;I always prefer a one-line snprintf to the above two-line code. :-)
Me too (or asprintf, depending on situation), but the point of this patch is to move around existing code without changing it. Certainly I can change it to sprintf if that's preferred.
- Panu -
Re: [PATCH 4/5] eal: add an error code to plugin init for the next step
In reply to Bruce RichardsonQuoted 11 lines · Bruce Richardson
Quoted 7 lines · Panu Matilainen
Signed-off-by Panu Matilainen <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++- lib/librte_eal/common/eal_common_options.c | 3 ++- lib/librte_eal/common/eal_options.h | 2 +- lib/librte_eal/linuxapp/eal/eal.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)Again, another minor nit, but couldn't this be done when refactoring in previous patches, rather than needed a whole separate commit ?
Of course it'd be possible to do this earlier, I pondered about it too but then went with this because
a) otherwise I would've had to rework the earlier patches again
b) not knowing which way people prefer it, I might've had to rework it back to the original
c) didn't know we were saving commits
d) doing it like this maintains a certain symmetry to how stuff is introduced
... yes, its all rather academic :)
- Panu -
Re: [PATCH 4/5] eal: add an error code to plugin init for the next step
Quoted 14 lines · Panu Matilainen
Quoted 9 lines · Bruce Richardson
Quoted 7 lines · Panu Matilainen
Signed-off-by Panu Matilainen <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++- lib/librte_eal/common/eal_common_options.c | 3 ++- lib/librte_eal/common/eal_options.h | 2 +- lib/librte_eal/linuxapp/eal/eal.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)Quoted 3 lines
Again, another minor nit, but couldn't this be done when refactoring in previous
patches, rather than needed a whole separate commit ?
Quoted 8 lines
Of course it'd be possible to do this earlier, I pondered about it too but then went with this because
a) otherwise I would've had to rework the earlier patches again
b) not knowing which way people prefer it, I might've had to rework it back to the original
c) didn't know we were saving commits
d) doing it like this maintains a certain symmetry to how stuff is introduced
In other words: I spent many years working with a codebase where the policy was to never change code while moving it around otherwise. So yeah, matter of policy, taste and all, I'm clearly still learning where the fine line is in case of dpdk :)
The series can easily be shrunken into two logical steps if that's preferred:
1) move the plugin handling code to common
2) add the plugin directory support
- Panu -
Re: [PATCH 4/5] eal: add an error code to plugin init for the next step
2015-10-16 16:38, Panu Matilainen:
Quoted 29 lines · Panu Matilainen
Quoted 14 lines · Bruce Richardson
Quoted 9 lines · Panu Matilainen
Quoted 7 lines
Signed-off-by Panu Matilainen <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++- lib/librte_eal/common/eal_common_options.c | 3 ++- lib/librte_eal/common/eal_options.h | 2 +- lib/librte_eal/linuxapp/eal/eal.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)Quoted 3 lines
Again, another minor nit, but couldn't this be done when refactoring in previous
patches, rather than needed a whole separate commit ?Quoted 8 lines
Of course it'd be possible to do this earlier, I pondered about it too but then went with this because
a) otherwise I would've had to rework the earlier patches again
b) not knowing which way people prefer it, I might've had to rework it back to the original
c) didn't know we were saving commits
d) doing it like this maintains a certain symmetry to how stuff is introducedIn other words: I spent many years working with a codebase where the policy was to never change code while moving it around otherwise. So yeah, matter of policy, taste and all, I'm clearly still learning where the fine line is in case of dpdk :)
Quoted 4 lines
The series can easily be shrunken into two logical steps if that's preferred:
1) move the plugin handling code to common
2) add the plugin directory support
Yes, looks good. Thanks
v3 cover Add support for driver directories
In reply to Panu MatilainenThis mini-series adds support for driver directory concept based on idea by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.html
In the process FreeBSD also gains plugin support (but untested).
v3: merge the first commits
v2: move code to eal/common, add bsd support
Panu Matilainen (2):
eal: move plugin loading to eal/common
eal: add support for driver directory concept
config/common_bsdapp | 3 + config/common_linuxapp | 3 + lib/librte_eal/bsdapp/eal/eal.c | 3 + lib/librte_eal/common/eal_common_options.c | 103 +++++++++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 1 + lib/librte_eal/linuxapp/eal/eal.c | 39 +---------- 6 files changed, 115 insertions(+), 37 deletions(-)
Signature · 1 line
2.4.3
PATCH 1/2 eal: move plugin loading to eal/common
There's no good reason to limit plugins to Linux, make it available on FreeBSD too. Refactor the plugin code from Linux EAL to common helper functions, also check for potential errors during initialization.
--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++ lib/librte_eal/common/eal_common_options.c | 53 ++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 1 + lib/librte_eal/linuxapp/eal/eal.c | 39 ++-------------------- 4 files changed, 59 insertions(+), 37 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +3 -0
@@ -543,6 +543,9 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); +if (eal_plugins_init () <0 ) +rte_panic ("Cannot init plugins\n" ); +eal_thread_init_master (rte_config.master_lcore); ret =eal_thread_dump_affinity (cpuset,RTE_CPU_AFFINITY_STR_LEN );
lib/librte_eal/common/eal_common_options.c +53 -0
83 lines not on this page · raw message
lib/librte_eal/common/eal_options.h +1 -0
@@ -93,5 +93,6 @@ int eal_adjust_config(struct internal_config *internal_cfg);int eal_check_common_options (struct internal_config *internal_cfg);void eal_common_usage (void );enum rte_proc_type_t eal_proc_type_detect (void ); +int eal_plugins_init (void );#endif /* EAL_OPTIONS_H */
lib/librte_eal/linuxapp/eal/eal.c +2 -37
@@ -43,7 +43,6 @@#include <getopt.h> #include <sys/file.h> #include <fcntl.h> -#include <dlfcn.h> #include <stddef.h> #include <errno.h> #include <limits.h>
@@ -90,20 +89,6 @@/* Allow the application to print its usage message too if set */ static rte_usage_hook_t rte_application_usage_hook =NULL ; -TAILQ_HEAD (shared_driver_list, shared_driver); - -/* Definition for shared object drivers. */ -struct shared_driver { -TAILQ_ENTRY (shared_driver) next; - -char name[PATH_MAX ]; -void * lib_handle; -}; - -/* List of external loadable drivers */ -static struct shared_driver_list solib_list = -TAILQ_HEAD_INITIALIZER (solib_list); -/* early configuration structure, when memory config is not mmapped */ static struct rte_mem_config early_mem_config;
@@ -350,7 +335,6 @@ eal_usage(const char *prgname)printf ("\nUsage: %s " , prgname);eal_common_usage ();printf ("EAL Linux options:\n" -" -d LIB.so Add driver (can be used multiple times)\n" " --" OPT_SOCKET_MEM " Memory to allocate on sockets (comma separated values)\n" " --" OPT_HUGE_DIR " Directory where hugetlbfs is mounted\n" " --"OPT_FILE_PREFIX" Prefix for hugepage filenames\n"
@@ -538,7 +522,6 @@ eal_parse_args(int argc, char **argv)char **argvopt;int option_index;char *prgname = argv[0 ]; -struct shared_driver *solib; argvopt = argv;
@@ -568,19 +551,6 @@ eal_parse_args(int argc, char **argv)eal_usage (prgname);exit (EXIT_SUCCESS ); -/* force loading of external driver */ -case 'd' : - solib =malloc (sizeof (*solib)); -if (solib ==NULL ) { -RTE_LOG (ERR ,EAL ,"malloc(solib) failed\n" ); -return -1 ; - } -memset (solib,0 ,sizeof (*solib)); -strncpy (solib->name, optarg,PATH_MAX -1 ); - solib->name[PATH_MAX -1 ] =0 ; -TAILQ_INSERT_TAIL (&solib_list, solib, next); -break ; -/* long options */ case OPT_XEN_DOM0_NUM :#ifdef RTE_LIBRTE_XEN_DOM0
@@ -731,7 +701,6 @@ rte_eal_init(int argc, char **argv)int i, fctret, ret;pthread_t thread_id;static rte_atomic32_t run_once =RTE_ATOMIC32_INIT (0 ); -struct shared_driver *solib =NULL ;const char *logid;char cpuset[RTE_CPU_AFFINITY_STR_LEN ];
@@ -824,12 +793,8 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); - TAILQ_FOREACH(solib, &solib_list, next) { -RTE_LOG (DEBUG ,EAL ,"open shared lib %s\n" , solib->name); - solib->lib_handle =dlopen (solib->name,RTLD_NOW ); -if (solib->lib_handle ==NULL ) -RTE_LOG (WARNING ,EAL ,"%s\n" ,dlerror ()); - } +if (eal_plugins_init () <0 ) +rte_panic ("Cannot init plugins\n" );eal_thread_init_master (rte_config.master_lcore);
Signature · 1 line
2.4.3
PATCH 2/2 eal: add support for driver directory concept
In reply to Panu MatilainenAdd a new EAL option -D for loading all drivers from a given directory. Additionally a default driver directory can be set in build-time configuration, in which case it will be always be used when EAL is initialized (but can be overridden or disabled with -D).
This simplifies usage in shared library configuration significantly over manually loading individual drivers with -d, and allows distros to establish a drop-in driver directory for seamless integration with 3rd party drivers etc.
--- config/common_bsdapp | 3 ++ config/common_linuxapp | 3 ++ lib/librte_eal/common/eal_common_options.c | 50 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)
config/common_bsdapp +3 -0
@@ -108,6 +108,9 @@ CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_MALLOC_DEBUG=n +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + # # FreeBSD contiguous memory driver settings #
config/common_linuxapp +3 -0
@@ -111,6 +111,9 @@ CONFIG_RTE_EAL_IGB_UIO=y CONFIG_RTE_EAL_VFIO=y CONFIG_RTE_MALLOC_DEBUG=n +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + # # Special configurations in PCI Config Space for high performance #
lib/librte_eal/common/eal_common_options.c +50 -0
91 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH 2/2] eal: add support for driver directory concept
2015-10-21 11:29, Panu Matilainen:
Quoted 4 lines
Add a new EAL option -D for loading all drivers from a given directory. Additionally a default driver directory can be set in build-time configuration, in which case it will be always be used when EAL is initialized (but can be overridden or disabled with -D).
[...]
lib/librte_eal/common/eal_common_options.c eal_common_usage(void) · line 1007
Quoted 5 lines
lib/librte_eal/common/eal_common_options.c +1
-0@@ -955,6 +1004,7 @@ eal_common_usage(void)" --" OPT_SYSLOG " Set syslog facility\n" " --" OPT_LOG_LEVEL " Set default log level\n" " -d LIB.so Add driver (can be used multiple times)\n" +" -D DIRECTORY Add driver directory)\n"
Another idea: instead of adding a new option, why not make -d able to deal with directories?
Re: [PATCH 2/2] eal: add support for driver directory concept
Quoted 6 lines · Thomas Monjalon
2015-10-21 11:29, Panu Matilainen:
Quoted 4 lines
Add a new EAL option -D for loading all drivers from a given directory. Additionally a default driver directory can be set in build-time configuration, in which case it will be always be used when EAL is initialized (but can be overridden or disabled with -D).
[...]
Quoted 9 lines
lib/librte_eal/common/eal_common_options.c eal_common_usage(void) · line 1007
Quoted 5 lines
lib/librte_eal/common/eal_common_options.c +1
-0@@ -955,6 +1004,7 @@ eal_common_usage(void)" --" OPT_SYSLOG " Set syslog facility\n" " --" OPT_LOG_LEVEL " Set default log level\n" " -d LIB.so Add driver (can be used multiple times)\n" +" -D DIRECTORY Add driver directory)\n" Another idea: instead of adding a new option, why not make -d able to deal with directories?
If that's what you want, sure. Just wishing you'd come up with this idea a bit earlier :)
- Panu -
Re: [PATCH 1/2] eal: move plugin loading to eal/common
In reply to Panu MatilainenQuoted 4 lines · Panu Matilainen
There's no good reason to limit plugins to Linux, make it available on FreeBSD too. Refactor the plugin code from Linux EAL to common helper functions, also check for potential errors during initialization.
Not sure about this "potential errors".
Quoted 16 lines
Signed-off-by Panu Matilainen <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++ lib/librte_eal/common/eal_common_options.c | 53 ++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 1 + lib/librte_eal/linuxapp/eal/eal.c | 39 ++-------------------- 4 files changed, 59 insertions(+), 37 deletions(-)lib/librte_eal/bsdapp/eal/eal.c +0
-0
lib/librte_eal/bsdapp/eal/eal.c rte_eal_init(int argc, char **argv) · line 549
Quoted 7 lines
lib/librte_eal/bsdapp/eal/eal.c +3
-0@@ -543,6 +543,9 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); +if (eal_plugins_init () <0 ) +rte_panic ("Cannot init plugins\n" ); +
Why testing for error when this cannot happen (see below) ?
lib/librte_eal/common/eal_common_options.c
Quoted 9 lines
lib/librte_eal/bsdapp/eal/eal.c +0
-0eal_thread_init_master (rte_config.master_lcore);ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);lib/librte_eal/common/eal_common_options.c +0
-0
[snip]
+
lib/librte_eal/common/eal_common_options.c eal_reset_internal_config(struct internal_config *internal_cfg) · line 182
Quoted 13 lines
lib/librte_eal/common/eal_common_options.c +13
-0+int +eal_plugins_init (void ) +{ +struct shared_driver *solib =NULL ; + + TAILQ_FOREACH(solib, &solib_list, next) { +RTE_LOG (DEBUG ,EAL ,"open shared lib %s\n" , solib->name); + solib->lib_handle =dlopen (solib->name,RTLD_NOW ); +if (solib->lib_handle ==NULL ) +RTE_LOG (WARNING ,EAL ,"%s\n" ,dlerror ()); + } +return 0 ; +}
I can't see a non 0 return here.
Btw, returning an error here would change current behavior of dpdk loading drivers.
Not sure we want this as people may rely on this loading not failing.
Signature · 1 line
David Marchand
Re: [PATCH 1/2] eal: move plugin loading to eal/common
Quoted 28 lines · David Marchand
Quoted 4 lines · Panu Matilainen
There's no good reason to limit plugins to Linux, make it available on FreeBSD too. Refactor the plugin code from Linux EAL to common helper functions, also check for potential errors during initialization.
Not sure about this "potential errors".
Quoted 17 lines
Signed-off-by Panu Matilainen <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++ lib/librte_eal/common/eal_common_options.c | 53 ++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 1 + lib/librte_eal/linuxapp/eal/eal.c | 39 ++-------------------- 4 files changed, 59 insertions(+), 37 deletions(-)lib/librte_eal/bsdapp/eal/eal.c +0
-0@@ -543,6 +543,9 @@ rte_eal_init(int argc, char **argv)
Quoted 8 lines
lib/librte_eal/bsdapp/eal/eal.c rte_eal_init(int argc, char **argv) · line 550
Quoted 6 lines
lib/librte_eal/bsdapp/eal/eal.c +3
-0rte_eal_mcfg_complete (); +if (eal_plugins_init () <0 ) +rte_panic ("Cannot init plugins\n" ); +Why testing for error when this cannot happen (see below) ?
This is just a preparation for the next patch which will add a possibility of failure. Its done here to get the new "infrastructure" in place in one commit, which seemed to be the preferred option by others.
Quoted 13 lines
lib/librte_eal/common/eal_common_options.c
Quoted 9 lines
lib/librte_eal/bsdapp/eal/eal.c +0
-0eal_thread_init_master (rte_config.master_lcore);ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);lib/librte_eal/common/eal_common_options.c +0
-0[snip]
+
Quoted 16 lines
lib/librte_eal/common/eal_common_options.c eal_reset_internal_config(struct internal_config *internal_cfg) · line 182
Quoted 13 lines
lib/librte_eal/common/eal_common_options.c +13
-0+int +eal_plugins_init (void ) +{ +struct shared_driver *solib =NULL ; + + TAILQ_FOREACH(solib, &solib_list, next) { +RTE_LOG (DEBUG ,EAL ,"open shared lib %s\n" , solib->name); + solib->lib_handle =dlopen (solib->name,RTLD_NOW ); +if (solib->lib_handle ==NULL ) +RTE_LOG (WARNING ,EAL ,"%s\n" ,dlerror ()); + } +return 0 ; +}I can't see a non 0 return here.
Yes, there is none, see above.
Quoted 3 lines
Btw, returning an error here would change current behavior of dpdk loading drivers.
Not sure we want this as people may rely on this loading not failing.
Yeah, dpdk currently doesn't fail if you pass garbage to -d, which is actually fairly questionable behavior. Why would you load drivers with -d if you dont care about them getting loaded? Well, maybe to handle an "everything" case but that's much better handled with the driver directory thing.
So actually the current patches make things a bit inconsistent, why should driver directories cause a failure if individual drivers do not? The question is, which behavior is the one people want: I personally would rather make -dgiddy.goo fail rather than just warn and chug away but its not exactly a deal-breaker for me.
- Panu -
Quoted 1 line
Re: [PATCH 1/2] eal: move plugin loading to eal/common
Quoted 12 lines · Panu Matilainen
Btw, returning an error here would change current behavior of dpdk loading
Quoted 3 lines
drivers.
Not sure we want this as people may rely on this loading not failing.Yeah, dpdk currently doesn't fail if you pass garbage to -d, which is actually fairly questionable behavior. Why would you load drivers with -d if you dont care about them getting loaded? Well, maybe to handle an "everything" case but that's much better handled with the driver directory thing.
Quoted 6 lines
So actually the current patches make things a bit inconsistent, why should driver directories cause a failure if individual drivers do not? The question is, which behavior is the one people want: I personally would rather make -dgiddy.goo fail rather than just warn and chug away but its not exactly a deal-breaker for me.
Neither to me.
I agree on the principle of failing when passing wrong stuff, it is saner. I just want to make sure nobody complains about this change later.
Thomas ? Bruce ?
Signature · 1 line
David Marchand
Re: [PATCH 1/2] eal: move plugin loading to eal/common
Quoted 21 lines · David Marchand
Quoted 12 lines · Panu Matilainen
Btw, returning an error here would change current behavior of dpdk loading
Quoted 3 lines
drivers.
Not sure we want this as people may rely on this loading not failing.Yeah, dpdk currently doesn't fail if you pass garbage to -d, which is actually fairly questionable behavior. Why would you load drivers with -d if you dont care about them getting loaded? Well, maybe to handle an "everything" case but that's much better handled with the driver directory thing.
Quoted 6 lines
So actually the current patches make things a bit inconsistent, why should driver directories cause a failure if individual drivers do not? The question is, which behavior is the one people want: I personally would rather make -dgiddy.goo fail rather than just warn and chug away but its not exactly a deal-breaker for me.
Quoted 6 lines
Neither to me.
I agree on the principle of failing when passing wrong stuff, it is saner. I just want to make sure nobody complains about this change later.Thomas ? Bruce ?
Error early rather than later. If the -d flag doesn't work crash then, rather than leaving people having to scroll-back to find why their NIC isn't working.
/Bruce
Re: [PATCH 1/2] eal: move plugin loading to eal/common
2015-10-21 12:15, Bruce Richardson:
Quoted 22 lines · David Marchand
Quoted 21 lines
Quoted 18 lines · Panu Matilainen
Btw, returning an error here would change current behavior of dpdk loading
Quoted 3 lines
drivers.
Not sure we want this as people may rely on this loading not failing.Yeah, dpdk currently doesn't fail if you pass garbage to -d, which is actually fairly questionable behavior. Why would you load drivers with -d if you dont care about them getting loaded? Well, maybe to handle an "everything" case but that's much better handled with the driver directory thing.
So actually the current patches make things a bit inconsistent, why should driver directories cause a failure if individual drivers do not? The question is, which behavior is the one people want: I personally would rather make -dgiddy.goo fail rather than just warn and chug away but its not exactly a deal-breaker for me.
Quoted 8 lines
Quoted 5 lines
Neither to me.
I agree on the principle of failing when passing wrong stuff, it is saner. I just want to make sure nobody complains about this change later.Thomas ? Bruce ?
Error early rather than later. If the -d flag doesn't work crash then, rather than leaving people having to scroll-back to find why their NIC isn't working.
Yes, no reason to ignore errors.
Re: [PATCH 1/2] eal: move plugin loading to eal/common
Quoted 27 lines · Thomas Monjalon
2015-10-21 12:15, Bruce Richardson:
Quoted 26 lines · David Marchand
Quoted 25 lines
Quoted 12 lines · Panu Matilainen
Btw, returning an error here would change current behavior of dpdk loading
Quoted 3 lines
drivers.
Not sure we want this as people may rely on this loading not failing.Yeah, dpdk currently doesn't fail if you pass garbage to -d, which is actually fairly questionable behavior. Why would you load drivers with -d if you dont care about them getting loaded? Well, maybe to handle an "everything" case but that's much better handled with the driver directory thing.
Quoted 6 lines
So actually the current patches make things a bit inconsistent, why should driver directories cause a failure if individual drivers do not? The question is, which behavior is the one people want: I personally would rather make -dgiddy.goo fail rather than just warn and chug away but its not exactly a deal-breaker for me.
Neither to me.
I agree on the principle of failing when passing wrong stuff, it is saner. I just want to make sure nobody complains about this change later.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Thomas ? Bruce ?
Error early rather than later. If the -d flag doesn't work crash then, rather than leaving people having to scroll-back to find why their NIC isn't working.
Yes, no reason to ignore errors.
Okay so we all vigorously agree on this :) Good then, I'll fix the error behavior too in the next version.
- Panu -
v4 cover Add support for driver directories
In reply to Panu MatilainenThis mini-series adds support for driver directory concept based on idea by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.html
In the process FreeBSD also gains plugin support (but untested).
v4: - introduce error-early behavior for invalid plugin paths
- support directories via the existing -d option instead of adding new
v3: - merge the first commits
v2: - move code to eal/common
- add bsd support
Panu Matilainen (2):
eal: move plugin loading to eal/common
eal: add support for driver directory concept
config/common_bsdapp | 3 + config/common_linuxapp | 3 + lib/librte_eal/bsdapp/eal/eal.c | 3 + lib/librte_eal/common/eal_common_options.c | 119 +++++++++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 1 + lib/librte_eal/linuxapp/eal/eal.c | 40 +--------- 6 files changed, 131 insertions(+), 38 deletions(-)
Signature · 1 line
2.5.0
PATCH v4 1/2 eal: move plugin loading to eal/common
There's no good reason to limit plugins to Linux, make it available on FreeBSD too. Refactor the plugin code from Linux EAL to common helper functions, also check for and fail on errors during initialization.
--- lib/librte_eal/bsdapp/eal/eal.c | 3 ++ lib/librte_eal/common/eal_common_options.c | 55 ++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 1 + lib/librte_eal/linuxapp/eal/eal.c | 40 ++-------------------- 4 files changed, 61 insertions(+), 38 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +3 -0
@@ -571,6 +571,9 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); +if (eal_plugins_init () <0 ) +rte_panic ("Cannot init plugins\n" ); +eal_thread_init_master (rte_config.master_lcore); ret =eal_thread_dump_affinity (cpuset,RTE_CPU_AFFINITY_STR_LEN );
lib/librte_eal/common/eal_common_options.c +55 -0
85 lines not on this page · raw message
lib/librte_eal/common/eal_options.h +1 -0
@@ -95,5 +95,6 @@ int eal_adjust_config(struct internal_config *internal_cfg);int eal_check_common_options (struct internal_config *internal_cfg);void eal_common_usage (void );enum rte_proc_type_t eal_proc_type_detect (void ); +int eal_plugins_init (void );#endif /* EAL_OPTIONS_H */
lib/librte_eal/linuxapp/eal/eal.c +2 -38
@@ -43,7 +43,6 @@#include <getopt.h> #include <sys/file.h> #include <fcntl.h> -#include <dlfcn.h> #include <stddef.h> #include <errno.h> #include <limits.h>
@@ -90,20 +89,6 @@/* Allow the application to print its usage message too if set */ static rte_usage_hook_t rte_application_usage_hook =NULL ; -TAILQ_HEAD (shared_driver_list, shared_driver); - -/* Definition for shared object drivers. */ -struct shared_driver { -TAILQ_ENTRY (shared_driver) next; - -char name[PATH_MAX ]; -void * lib_handle; -}; - -/* List of external loadable drivers */ -static struct shared_driver_list solib_list = -TAILQ_HEAD_INITIALIZER (solib_list); -/* early configuration structure, when memory config is not mmapped */ static struct rte_mem_config early_mem_config;
@@ -350,7 +335,6 @@ eal_usage(const char *prgname)printf ("\nUsage: %s " , prgname);eal_common_usage ();printf ("EAL Linux options:\n" -" -d LIB.so Add driver (can be used multiple times)\n" " --" OPT_SOCKET_MEM " Memory to allocate on sockets (comma separated values)\n" " --" OPT_HUGE_DIR " Directory where hugetlbfs is mounted\n" " --"OPT_FILE_PREFIX" Prefix for hugepage filenames\n"
@@ -545,7 +529,6 @@ eal_parse_args(int argc, char **argv)char **argvopt;int option_index;char *prgname = argv[0 ]; -struct shared_driver *solib;const int old_optind = optind;const int old_optopt = optopt;char *const old_optarg = optarg;
@@ -579,20 +562,6 @@ eal_parse_args(int argc, char **argv)eal_usage (prgname);exit (EXIT_SUCCESS ); -/* force loading of external driver */ -case 'd' : - solib =malloc (sizeof (*solib)); -if (solib ==NULL ) { -RTE_LOG (ERR ,EAL ,"malloc(solib) failed\n" ); - ret =-1 ; - goto out; - } -memset (solib,0 ,sizeof (*solib)); -strncpy (solib->name, optarg,PATH_MAX -1 ); - solib->name[PATH_MAX -1 ] =0 ; -TAILQ_INSERT_TAIL (&solib_list, solib, next); -break ; -/* long options */ case OPT_XEN_DOM0_NUM :#ifdef RTE_LIBRTE_XEN_DOM0
@@ -758,7 +727,6 @@ rte_eal_init(int argc, char **argv)int i, fctret, ret;pthread_t thread_id;static rte_atomic32_t run_once =RTE_ATOMIC32_INIT (0 ); -struct shared_driver *solib =NULL ;const char *logid;char cpuset[RTE_CPU_AFFINITY_STR_LEN ];char thread_name[RTE_MAX_THREAD_NAME_LEN ];
@@ -852,12 +820,8 @@ rte_eal_init(int argc, char **argv)rte_eal_mcfg_complete (); - TAILQ_FOREACH(solib, &solib_list, next) { -RTE_LOG (DEBUG ,EAL ,"open shared lib %s\n" , solib->name); - solib->lib_handle =dlopen (solib->name,RTLD_NOW ); -if (solib->lib_handle ==NULL ) -RTE_LOG (WARNING ,EAL ,"%s\n" ,dlerror ()); - } +if (eal_plugins_init () <0 ) +rte_panic ("Cannot init plugins\n" );eal_thread_init_master (rte_config.master_lcore);
Signature · 1 line
2.5.0
PATCH v4 2/2 eal: add support for driver directory concept
In reply to Panu MatilainenAdd support for directories as arguments to -d for loading all drivers from a given directory. Additionally a default driver directory can be set in build-time configuration, in which case it will be always be used when EAL is initialized.
This simplifies usage in shared library configuration significantly over manually loading individual drivers with -d, and allows distros to establish a drop-in driver directory for seamless integration with 3rd party drivers etc.
--- config/common_bsdapp | 3 ++ config/common_linuxapp | 3 ++ lib/librte_eal/common/eal_common_options.c | 74 ++++++++++++++++++++++++++++-- 3 files changed, 75 insertions(+), 5 deletions(-)
config/common_bsdapp +3 -0
@@ -108,6 +108,9 @@ CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_MALLOC_DEBUG=n +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + # # FreeBSD contiguous memory driver settings #
config/common_linuxapp +3 -0
@@ -111,6 +111,9 @@ CONFIG_RTE_EAL_IGB_UIO=y CONFIG_RTE_EAL_VFIO=y CONFIG_RTE_MALLOC_DEBUG=n +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + # # Special configurations in PCI Config Space for high performance #
lib/librte_eal/common/eal_common_options.c +69 -5
106 lines not on this page · raw message
Signature · 1 line
2.5.0
Hello,
Quoted 9 lines · Panu Matilainen
This mini-series adds support for driver directory concept based on idea by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.htmlIn the process FreeBSD also gains plugin support (but untested).
v4: - introduce error-early behavior for invalid plugin paths
- support directories via the existing -d option instead of adding new
Quoted 8 lines
v3: - merge the first commits
v2: - move code to eal/common
- add bsd supportPanu Matilainen (2):
eal: move plugin loading to eal/common
eal: add support for driver directory concept
checkpatch complains for some indent problem (Thomas, can you fix this ?), but the rest looks good to me.
Thanks Panu.
Signature · 1 line
David Marchand
Thomas Monjalon
AppliedQuoted 19 lines
Quoted 9 lines
This mini-series adds support for driver directory concept based on idea by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.htmlIn the process FreeBSD also gains plugin support (but untested).
v4: - introduce error-early behavior for invalid plugin paths
- support directories via the existing -d option instead of adding newQuoted 8 lines
v3: - merge the first commits
v2: - move code to eal/common
- add bsd supportPanu Matilainen (2):
eal: move plugin loading to eal/common
eal: add support for driver directory concept
Quoted 6 lines
checkpatch complains for some indent problem (Thomas, can you fix this ?), but the rest looks good to me.
Acked-by David Marchand <[email protected]>Thanks Panu.
Applied, thanks
Quoted 19 lines · On Thu, 12 Nov 2015 16:52:32 +0100 Thomas Monjalon <[email protected]>…
Quoted 19 lines
Quoted 17 lines
This mini-series adds support for driver directory concept based on idea by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.htmlIn the process FreeBSD also gains plugin support (but untested).
v4: - introduce error-early behavior for invalid plugin paths
- support directories via the existing -d option instead of adding newv3: - merge the first commits
v2: - move code to eal/common
- add bsd supportPanu Matilainen (2):
eal: move plugin loading to eal/common
eal: add support for driver directory concept
Quoted 8 lines
Quoted 6 lines
checkpatch complains for some indent problem (Thomas, can you fix this ?), but the rest looks good to me.
Acked-by David Marchand <[email protected]>Thanks Panu.
Applied, thanks
This patch introduces a new issue reported by Coverity.
The root cause of the problem is that you are checking that it s a directory first with stat then calling dlopen(). I malicious entity could get between the stat and the dlopen.
In this case the desire to handle both file name and directory is getting in the way. It really should just only take a directory now, or have two different config options in a method similar to other subsystems (look at /etc/xxx vs /etc/xxx.d as standard practice).
________________________________________________________________________________________________________
*** CID 120151: Security best practices violations (TOCTOU) /lib/librte_eal/common/eal_common_options.c: 232 in eal_plugins_init()
226 solib->name);
227 return -1;
228 }
229 } else {
230 RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
231 solib->name);
>>> CID 120151: Security best practices violations (TOCTOU)
>>> Calling function "dlopen" that uses "solib->name" after a check function. This can cause a time-of-check, time-of-use race condition.
232 solib->lib_handle = dlopen(solib->name, RTLD_NOW);
233 if (solib->lib_handle == NULL) {
234 RTE_LOG(ERR, EAL, "%s\n", dlerror());
235 return -1;
236 }
237 }2015-12-02 18:07, Stephen Hemminger:
Quoted 27 lines
Quoted 24 lines · On Thu, 12 Nov 2015 16:52:32 +0100 Thomas Monjalon <[email protected]>…
Quoted 24 lines
Quoted 9 lines
This mini-series adds support for driver directory concept based on idea by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.htmlIn the process FreeBSD also gains plugin support (but untested).
v4: - introduce error-early behavior for invalid plugin paths
- support directories via the existing -d option instead of adding newQuoted 8 lines
v3: - merge the first commits
v2: - move code to eal/common
- add bsd supportPanu Matilainen (2):
eal: move plugin loading to eal/common
eal: add support for driver directory conceptcheckpatch complains for some indent problem (Thomas, can you fix this ?), but the rest looks good to me.
Acked-by David Marchand <[email protected]>
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Thanks Panu.
Applied, thanks
This patch introduces a new issue reported by Coverity.
The root cause of the problem is that you are checking that it s a directory first with stat then calling
dlopen(). I malicious entity could get between the stat and the dlopen.
I think it is a false positive.
The aim of loading every files in the directory is out of a security scope IMHO.
Quoted 32 lines · Thomas Monjalon
2015-12-02 18:07, Stephen Hemminger:
Quoted 31 lines
Quoted 27 lines · On Thu, 12 Nov 2015 16:52:32 +0100 Thomas Monjalon <[email protected]>…
Quoted 19 lines
Quoted 9 lines
This mini-series adds support for driver directory concept based on idea by Thomas Monjalon back in February:
http://dpdk.org/ml/archives/dev/2015-February/013285.htmlIn the process FreeBSD also gains plugin support (but untested).
v4: - introduce error-early behavior for invalid plugin paths
- support directories via the existing -d option instead of adding newQuoted 8 lines
v3: - merge the first commits
v2: - move code to eal/common
- add bsd supportPanu Matilainen (2):
eal: move plugin loading to eal/common
eal: add support for driver directory conceptQuoted 6 lines
checkpatch complains for some indent problem (Thomas, can you fix this ?), but the rest looks good to me.
Acked-by David Marchand <[email protected]>Thanks Panu.
Applied, thanks
Quoted 8 lines
Quoted 4 lines
This patch introduces a new issue reported by Coverity.
The root cause of the problem is that you are checking that it s a directory first with stat then calling
dlopen(). I malicious entity could get between the stat and the dlopen.I think it is a false positive.
The aim of loading every files in the directory is out of a security scope IMHO.
Yes its a false positive. The security aspect relates to world-writable directories and even in there the problem is usually "test for existence before creation", this is neither (if somebody routinely loads their critical device drivers from /tmp on a system they have bigger problems than this)
If somebody changes a file to a directory or vice versa then the consecutive readdir() or dlopen() on that entry will just fail, end of story. And if somebody has the permission to change entries in that directory they dont have to bother with trying to time their changes between stat() and dlopen().
Sure it could just call dlopen() on everything and if it fails try readdir() on it. Matter of style, I dislike blindly stumbling and crashing when I can simply take a look to see whether its a door, a window or a wall :)
- Panu -