kni: ignore double initialization
authorMarc Sune <marc.sune@bisdn.de>
Thu, 18 Jun 2015 16:34:48 +0000 (18:34 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 22 Jun 2015 16:39:40 +0000 (18:39 +0200)
Prevent double initialization of the KNI subsytem.

Signed-off-by: Marc Sune <marc.sune@bisdn.de>
Acked-by: Helin Zhang <helin.zhang@intel.com>
lib/librte_kni/rte_kni.c

index c5a0089..08155db 100644 (file)
@@ -201,6 +201,12 @@ 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) {
+               RTE_LOG(WARNING, KNI, "Double call to rte_kni_init()");
+               return;
+       }
+
        if (max_kni_ifaces == 0) {
                RTE_LOG(ERR, KNI, "Invalid number of max_kni_ifaces %d\n",
                                                        max_kni_ifaces);