[dpdk-dev] kni: ignore double calls to rte_kni_init()

Message ID 1433118752-14600-1-git-send-email-marc.sune@bisdn.de (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Marc Sune June 1, 2015, 12:32 a.m. UTC
  Prevent double initialization of the KNI subsytem.

Signed-off-by: Marc Sune <marc.sune@bisdn.de>
---
 lib/librte_kni/rte_kni.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Zhang, Helin June 15, 2015, 1:08 a.m. UTC | #1
Hi Marc

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marc Sune
> Sent: Monday, June 1, 2015 8:33 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] kni: ignore double calls to rte_kni_init()
> 
> Prevent double initialization of the KNI subsytem.
> 
> Signed-off-by: Marc Sune <marc.sune@bisdn.de>
> ---
>  lib/librte_kni/rte_kni.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index
> c5a0089..df0449f 100644
> --- a/lib/librte_kni/rte_kni.c
> +++ b/lib/librte_kni/rte_kni.c
> @@ -201,6 +201,10 @@ rte_kni_init(unsigned int max_kni_ifaces)
>  	char obj_name[OBJNAMSIZ];
>  	char mz_name[RTE_MEMZONE_NAMESIZE];
> 
> +	/* Immediately return if KNI is already initialized */
> +	if (kni_memzone_pool.initialized)
> +		return;
I'd prefer to have a debug log before returning out, as there is no error code for it.
Thanks,
Helin

> +
>  	if (max_kni_ifaces == 0) {
>  		RTE_LOG(ERR, KNI, "Invalid number of max_kni_ifaces %d\n",
>  							max_kni_ifaces);
> --
> 2.1.4
  

Patch

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index c5a0089..df0449f 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -201,6 +201,10 @@  rte_kni_init(unsigned int max_kni_ifaces)
 	char obj_name[OBJNAMSIZ];
 	char mz_name[RTE_MEMZONE_NAMESIZE];
 
+	/* Immediately return if KNI is already initialized */
+	if (kni_memzone_pool.initialized)
+		return;
+
 	if (max_kni_ifaces == 0) {
 		RTE_LOG(ERR, KNI, "Invalid number of max_kni_ifaces %d\n",
 							max_kni_ifaces);