From patchwork Wed Apr 13 14:20:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 65726 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp39520qge; Wed, 13 Apr 2016 07:21:54 -0700 (PDT) X-Received: by 10.55.71.146 with SMTP id u140mr11639212qka.14.1460557314343; Wed, 13 Apr 2016 07:21:54 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r65si3876941qhc.52.2016.04.13.07.21.35; Wed, 13 Apr 2016 07:21:54 -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; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2DDB068393; Wed, 13 Apr 2016 14:21:35 +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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 BAF496837F; Wed, 13 Apr 2016 14:21:26 +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 EFC246838C; Wed, 13 Apr 2016 14:21:24 +0000 (UTC) Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by lists.linaro.org (Postfix) with ESMTPS id 3F9836837B for ; Wed, 13 Apr 2016 14:20:36 +0000 (UTC) Received: by mail-wm0-f47.google.com with SMTP id v188so177604795wme.1 for ; Wed, 13 Apr 2016 07:20:36 -0700 (PDT) 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; bh=gDdvFDaESc7+mACTyt7klOi7T8k6dhLgVDLIF11+pfc=; b=FzIDw/Q/KWG1Lb+i1BJ7bnPlpWb4o1/8w8A2ZE8zFvyTDcUkMiuca+ULk+CLkmVUpL ZcG423El+2WGMU9NhOceDMxRLLKxv+L4kZKmMXr8aeOm44qWghlXQX5a61sJRIihwuOI 97DnfEYgNghLG01yDlInQ51/Fm5swDs9Ez1YUjPwRx6FBB10HTrpxOYLH/jI2S7zTTP/ y/nDhfGCEh3+qQBlaViTNhrO6lJmW5ge0yBBnHcwLBB3gA+4FprJeI/uR+FiM7XhaBTl SgOviL1w6x0fFsHF15z288gbO94DFjnn06/MUlqCCk+8y7puC/cJo1i+DI3NKM+nEJN5 bnqQ== X-Gm-Message-State: AOPr4FUmz1NzJuzD3iKlRbuJz0b18Wv6aEToNOtmpAxLoBQ0FkUWMs33dQJUv4qLxYJGiN7iUFc= X-Received: by 10.28.125.2 with SMTP id y2mr10933291wmc.90.1460557235307; Wed, 13 Apr 2016 07:20:35 -0700 (PDT) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id c190sm1526994wmd.10.2016.04.13.07.20.34 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Apr 2016 07:20:34 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Wed, 13 Apr 2016 15:20:00 +0100 Message-Id: <1460557200-19922-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: Classification patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCH v2] linux-generic: classification: fix error checking _odp_packet_classifier() 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" In case of error the 'pkt' should be released by the calling function. Currently loopback gives it back to the receiver and report it as success in the stats. Signed-off-by: Zoltan Kiss Reviewed-by: Balasubramanian Manoharan --- v2: handle release in caller instead, and adjust stats. platform/linux-generic/odp_classification.c | 10 +++------- platform/linux-generic/pktio/loop.c | 9 ++++++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 8522023..3a18a78 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -745,21 +745,17 @@ int _odp_packet_classifier(pktio_entry_t *entry, odp_packet_t pkt) if (cos == NULL) return -1; - if (cos->s.pool == NULL) { - odp_packet_free(pkt); + if (cos->s.pool == NULL) return -1; - } - if (cos->s.queue == NULL) { - odp_packet_free(pkt); + if (cos->s.queue == NULL) return -1; - } if (odp_packet_pool(pkt) != cos->s.pool->s.pool_hdl) { new_pkt = odp_packet_copy(pkt, cos->s.pool->s.pool_hdl); - odp_packet_free(pkt); if (new_pkt == ODP_PACKET_INVALID) return -1; + odp_packet_free(pkt); } else { new_pkt = pkt; } diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 0ea6d0e..f6a8c1d 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -70,10 +70,13 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[], pkt_hdr = odp_packet_hdr(pkt); packet_parse_reset(pkt_hdr); packet_parse_l2(pkt_hdr); - if (0 > _odp_packet_classifier(pktio_entry, pkt)) { - pkts[j++] = pkt; + if (!_odp_packet_classifier(pktio_entry, pkt)) { pktio_entry->s.stats.in_octets += - odp_packet_len(pkts[i]); + odp_packet_len(pkt); + } else { + pktio_entry->s.stats.in_errors += + odp_packet_len(pkt); + odp_packet_free(pkt); } } nbr = j;