From patchwork Fri Sep 2 09:51:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 15592 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id EA65A4CE7; Fri, 2 Sep 2016 11:51:57 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 07EFC4CE4 for ; Fri, 2 Sep 2016 11:51:52 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP; 02 Sep 2016 02:51:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.30,270,1470726000"; d="scan'208"; a="1034636878" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 02 Sep 2016 02:51:51 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u829poFm016646 for ; Fri, 2 Sep 2016 10:51:50 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u829pomn010997 for ; Fri, 2 Sep 2016 10:51:50 +0100 Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id u829poQK010993 for dev@dpdk.org; Fri, 2 Sep 2016 10:51:50 +0100 X-Authentication-Warning: sivswdev02.ir.intel.com: fyigit set sender to ferruh.yigit@intel.com using -f From: Ferruh Yigit To: dev@dpdk.org Date: Fri, 2 Sep 2016 10:51:49 +0100 Message-Id: <1472809909-10962-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] kni: remove rte_panic exits from library X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This also helps to remove stack backtrace when kernel module is not inserted. Signed-off-by: Ferruh Yigit --- lib/librte_kni/rte_kni.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index f48b72b..d88a70d 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -210,14 +210,18 @@ rte_kni_init(unsigned int max_kni_ifaces) if (max_kni_ifaces == 0) { RTE_LOG(ERR, KNI, "Invalid number of max_kni_ifaces %d\n", max_kni_ifaces); - rte_panic("Unable to initialize KNI\n"); + RTE_LOG(ERR, KNI, "Unable to initialize KNI\n"); + return; } /* Check FD and open */ if (kni_fd < 0) { kni_fd = open("/dev/" KNI_DEVICE, O_RDWR); - if (kni_fd < 0) - rte_panic("Can not open /dev/%s\n", KNI_DEVICE); + if (kni_fd < 0) { + RTE_LOG(ERR, KNI, + "Can not open /dev/%s\n", KNI_DEVICE); + return; + } } /* Allocate slot objects */ @@ -307,8 +311,8 @@ rte_kni_init(unsigned int max_kni_ifaces) return; kni_fail: - rte_panic("Unable to allocate memory for max_kni_ifaces:%d. Increase the amount of hugepages memory\n", - max_kni_ifaces); + RTE_LOG(ERR, KNI, "Unable to allocate memory for max_kni_ifaces:%d." + "Increase the amount of hugepages memory\n", max_kni_ifaces); } @@ -483,8 +487,9 @@ rte_kni_release(struct rte_kni *kni) /* Release memzone */ if (slot_id > kni_memzone_pool.max_ifaces) { - rte_panic("KNI pool: corrupted slot ID: %d, max: %d\n", + RTE_LOG(ERR, KNI, "KNI pool: corrupted slot ID: %d, max: %d\n", slot_id, kni_memzone_pool.max_ifaces); + return -1; } kni_memzone_pool_release(&kni_memzone_pool.slots[slot_id]); @@ -506,7 +511,8 @@ rte_kni_handle_request(struct rte_kni *kni) return 0; /* It is OK of can not getting the request mbuf */ if (req != kni->sync_addr) { - rte_panic("Wrong req pointer %p\n", req); + RTE_LOG(ERR, KNI, "Wrong req pointer %p\n", req); + return -1; } /* Analyze the request and call the relevant actions for it */