From patchwork Thu Nov 19 09:43:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 56973 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3073365lbb; Thu, 19 Nov 2015 01:48:47 -0800 (PST) X-Received: by 10.140.19.177 with SMTP id 46mr5987845qgh.67.1447926526926; Thu, 19 Nov 2015 01:48:46 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a76si724400qhc.94.2015.11.19.01.48.46; Thu, 19 Nov 2015 01:48:46 -0800 (PST) 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 8BC4E61E13; Thu, 19 Nov 2015 09:48:46 +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 E7BC761FDF; Thu, 19 Nov 2015 09:44:56 +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 B9F0261FD9; Thu, 19 Nov 2015 09:44:47 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 10C6B61FD1 for ; Thu, 19 Nov 2015 09:43:47 +0000 (UTC) Received: by lfdo63 with SMTP id o63so44192116lfd.2 for ; Thu, 19 Nov 2015 01:43:46 -0800 (PST) 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=dvfrWDdAD1o7IPPvWFqPilREx7F6QkZqIp0ECKD/FFI=; b=htr0ya+xaEz22BgG55N2E4k2xhZf36eLrJlcw127ENIZ7l7H8b3iJBuNYlOn/jFqSh 2z8X/o73u0Lt04aobPiphS7LRpAO75aGOtEVW+cTZj+RRU+eECGEYLezwtItJhDHHy/W Zq23sD1EpJ+AJI7Zvg/b02TDrlpm1rMTrh8nx+hzXt5AvFuHyKr1jV5hxCc6dKkWsb6G Ynv3GcOM/kJ341Pkjo8hJ2bryGg87CcXMwRysI+VdlDX1J24Xf0IIH7S6u24Av+jxlRu 0/vhiBQwJtS3S9/wZwoqep520eQqKeerMIT/ocoqacZj9nBhJ0a+H4FfiRm9dxDLSmDG 5V3A== 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=dvfrWDdAD1o7IPPvWFqPilREx7F6QkZqIp0ECKD/FFI=; b=CgEY0v+t6vHKzOchY5eLRjxQf8ZUZ3l5y1bZ3uXGVOo1bd6m/C+O6lM2YPE3+l3L96 H7l9mb24SdPpuZfXCf7GP/bMX271PnmhN46khf1tT/Nyv5hzKPR74KtCY9OkMlRAKyrV jhDZPBOtwDEvk0p2/MNVtrk34UIGG/d4yX3hs9NxQWq28RPg7wcP5Ogz2E7Giw/ye0Aa gMYvo6BfIi6inXgYSqpZVw4VOAsgYlwHKybvuSyuP7aEH1Ch7W0gCXqnZDcruG4xS4tW ZUry5B1vDUW/Ucnt9YwDwNL4paRW9Y5sslZ5mUh1cxSpO1aTyLKbbVCA35CI1hZ8CbWs uQOQ== X-Gm-Message-State: ALoCoQmfdg46MQhiL4gKvC+E7iGTtSotncWQzVNfvQiH17p+MZ/Ev/HWkhu8uk/r+2TYQMS1cAvK X-Received: by 10.25.157.85 with SMTP id g82mr2422865lfe.104.1447926225956; Thu, 19 Nov 2015 01:43:45 -0800 (PST) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id 194sm1081186lfd.4.2015.11.19.01.43.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Nov 2015 01:43:45 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 19 Nov 2015 12:43:29 +0300 Message-Id: <1447926212-15365-7-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447926212-15365-1-git-send-email-maxim.uvarov@linaro.org> References: <1447926212-15365-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv14 6/9] 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 c3bc6a0..c8ccca2 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -708,7 +708,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) { @@ -723,7 +723,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; @@ -732,7 +734,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) { @@ -748,7 +750,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; @@ -757,7 +760,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) { @@ -773,13 +776,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; @@ -804,7 +807,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;