From patchwork Wed Oct 28 13:42:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 55693 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp130198lbr; Wed, 28 Oct 2015 06:47:30 -0700 (PDT) X-Received: by 10.55.78.149 with SMTP id c143mr28225704qkb.107.1446040050304; Wed, 28 Oct 2015 06:47:30 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w15si42037002qha.131.2015.10.28.06.47.30; Wed, 28 Oct 2015 06:47:30 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id EE84161941; Wed, 28 Oct 2015 13:47:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3534C61FC5; Wed, 28 Oct 2015 13:44:18 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 04E1761FB5; Wed, 28 Oct 2015 13:43:19 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id C21AD61FBD for ; Wed, 28 Oct 2015 13:43:04 +0000 (UTC) Received: by lfbn126 with SMTP id n126so3853025lfb.2 for ; Wed, 28 Oct 2015 06:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A4WsYaIRWdrBQ6HX4/GKWEtIEd3QmWgrs7xjyao5NcQ=; b=wc2Y8WNDZA3+jwgmIEnPfQ+0B4jYt98OclSQnBOjqMeRAkfNBShrxw2YG7Cesbk4fn vCIJH4KlknHsPV+tbzwdoHfjmfUoE/OScH5w5ERL+1IBHiGC5h/wQDVguthdFCpJ8jTk f9NPU5imFvFnDd16yj0nLhOXzDjEaRGVYE/hCA0eoCH1KA7O02TkO4tpBJGOQVQSxZsY zQa7tk8icQOBfe2AGtAtck1CWREHG4KMdLlKy8TVNk/lIMtQgdCEtLTRPoe8OgajZ8cj lgKbgDu/dzbGv4Pzv/pjhFVPBTxayHxqN3PTPcAtHnH340MriYkHQKj4XMwDpbvLPDO+ H0KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A4WsYaIRWdrBQ6HX4/GKWEtIEd3QmWgrs7xjyao5NcQ=; b=b6a7rE8MPhM0kZWSCH9WsTfQdp30eaLpaE3ab296cKmw6BoIY900jZWpNOTGYCMl0T 0t8BLcwiMmrsjotLyk7IziLcVF3x/6mb/WOZqDLDdPKUqSoCaC3f1m4S5X1BZwRh/xus 7PIRDRgAnJxkVU2tC1gQGOdP4mXAHJLV0hMTFKB4T2PoqU+Ni0y15eB7QFZt4nuTWzqk YZgXk87iLixO2YcYfDqUXfYCx5aDWMIwGuR7lNw6T8MZrg9Ir5C+9wRdLNkRksSHs/vq TUh5HdcP1ym6GY0ZW6O2sE3Lo1DFR+F5cLp8IHn7HK4/efLRvzC+/RkkjsU2TUwjzcYS AD1A== X-Gm-Message-State: ALoCoQnsYDrONQFRkuUrgYlfKDwO8NYAm480DGadlKXjVeyMbGX3Uf1F4yzpFdI+iY3Jr0LOSY8M X-Received: by 10.25.136.132 with SMTP id k126mr7016553lfd.97.1446039783500; Wed, 28 Oct 2015 06:43:03 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id b142sm4471309lfb.46.2015.10.28.06.43.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Oct 2015 06:43:02 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 28 Oct 2015 16:42:51 +0300 Message-Id: <1446039773-28325-7-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446039773-28325-1-git-send-email-maxim.uvarov@linaro.org> References: <1446039773-28325-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv12 6/8] linix-generic: return error for unsupported pktio calls X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" For some pktios like loop and ipc functions like mtu, promisc, and mac addr are not applicable. Instead of crash on deference null pointer just return error if functions are not defined. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_packet_io.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 1246bff..41613e3 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -716,7 +716,7 @@ int pktin_poll(pktio_entry_t *entry) int odp_pktio_mtu(odp_pktio_t id) { pktio_entry_t *entry; - int ret; + int ret = -1; entry = get_pktio_entry(id); if (entry == NULL) { @@ -731,7 +731,9 @@ int odp_pktio_mtu(odp_pktio_t id) ODP_DBG("already freed pktio\n"); return -1; } - ret = entry->s.ops->mtu_get(entry); + + if (entry->s.ops->mtu_get) + ret = entry->s.ops->mtu_get(entry); unlock_entry(entry); return ret; @@ -740,7 +742,7 @@ int odp_pktio_mtu(odp_pktio_t id) int odp_pktio_promisc_mode_set(odp_pktio_t id, odp_bool_t enable) { pktio_entry_t *entry; - int ret; + int ret = -1; entry = get_pktio_entry(id); if (entry == NULL) { @@ -756,7 +758,8 @@ int odp_pktio_promisc_mode_set(odp_pktio_t id, odp_bool_t enable) return -1; } - ret = entry->s.ops->promisc_mode_set(entry, enable); + if (entry->s.ops->promisc_mode_set) + ret = entry->s.ops->promisc_mode_set(entry, enable); unlock_entry(entry); return ret; @@ -765,7 +768,7 @@ int odp_pktio_promisc_mode_set(odp_pktio_t id, odp_bool_t enable) int odp_pktio_promisc_mode(odp_pktio_t id) { pktio_entry_t *entry; - int ret; + int ret = -1; entry = get_pktio_entry(id); if (entry == NULL) { @@ -781,13 +784,13 @@ int odp_pktio_promisc_mode(odp_pktio_t id) return -1; } - ret = entry->s.ops->promisc_mode_get(entry); + if (entry->s.ops->promisc_mode_get) + ret = entry->s.ops->promisc_mode_get(entry); unlock_entry(entry); return ret; } - int odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, int addr_size) { pktio_entry_t *entry; @@ -812,7 +815,12 @@ int odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, int addr_size) return -1; } - ret = entry->s.ops->mac_get(entry, mac_addr); + if (entry->s.ops->mac_get) + ret = entry->s.ops->mac_get(entry, mac_addr); + else { + ODP_DBG("pktio does not support mac addr get\n"); + ret = -1; + } unlock_entry(entry); return ret;