From patchwork Thu Apr 7 18:53:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 65335 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp248398lbl; Thu, 7 Apr 2016 11:54:41 -0700 (PDT) X-Received: by 10.140.108.229 with SMTP id j92mr5968041qgf.17.1460055280931; Thu, 07 Apr 2016 11:54:40 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 88si6915429qgz.127.2016.04.07.11.54.40; Thu, 07 Apr 2016 11:54:40 -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 98ACD619E6; Thu, 7 Apr 2016 18:54:40 +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 D885E619D0; Thu, 7 Apr 2016 18:54: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 3D23B619C1; Thu, 7 Apr 2016 18:54:15 +0000 (UTC) Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by lists.linaro.org (Postfix) with ESMTPS id 4D3F16197B for ; Thu, 7 Apr 2016 18:54:13 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id 191so101378857wmq.0 for ; Thu, 07 Apr 2016 11:54:13 -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:in-reply-to :references; bh=ogyIAk4LN0SBNJ5neLcNwN1UsFn2pEPE/Ix6ST6wPTg=; b=NzfxnOL/t7Gtad158CQY1eZ21LehGGT8kbl40fATLhwRFZgMjwkYGOcyyRHTulaR3r 9iUuzLQK+pNgVHbnFAkkxlwei4yOOYdHlbEWd2qHao2XlN8wKgYdq4QjdzIw1cbG202C tePlXAzLWk1y+8kFDpisc6OQPiJU/HcrAn4hHjwUjtEGsKdEU3Torw/jZvkd7kYq1aqk uPV124IH1vAlZmtzR5l8262Cslu2AjdVYjOqbDBTrLFfr87LUXPERQARUlAAcpQ9vlu8 zyT9OKQUztlNRFSK8R8vgnkrJAJ4Tvo4NHYNegGS95jisDEnVCKvZF5mbKsIpMXaVUE3 8iYg== X-Gm-Message-State: AD7BkJLa6vDwilL1ZH2AGd3Yj69xb1f/HRe2bBoTFBkM00hQJwz+njhXgd/7G5/s04vClEbPARA= X-Received: by 10.28.13.79 with SMTP id 76mr32827941wmn.5.1460055252536; Thu, 07 Apr 2016 11:54:12 -0700 (PDT) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id i5sm9801915wjx.15.2016.04.07.11.54.11 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Apr 2016 11:54:11 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Thu, 7 Apr 2016 19:53:32 +0100 Message-Id: <1460055213-29479-2-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460055213-29479-1-git-send-email-zoltan.kiss@linaro.org> References: <1460055213-29479-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: Classification patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCH 1/2] 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" The callers are only interested whether there is a CoS or not. It is not an error if there isn't, so it has a positive return value. Any other case needs to release the packet, which is not handled after calling queue_enq(). Signed-off-by: Zoltan Kiss --- platform/linux-generic/odp_classification.c | 9 +++++++-- platform/linux-generic/pktio/loop.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index f5e4673..4f2974b 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -743,7 +743,7 @@ int _odp_packet_classifier(pktio_entry_t *entry, odp_packet_t pkt) /* Matching PMR and selecting the CoS for the packet*/ cos = pktio_select_cos(entry, pkt_addr, pkt_hdr); if (cos == NULL) - return -1; + return 1; if (cos->s.pool == NULL) { odp_packet_free(pkt); @@ -766,7 +766,12 @@ int _odp_packet_classifier(pktio_entry_t *entry, odp_packet_t pkt) /* Enqueuing the Packet based on the CoS */ queue = cos->s.queue; - return queue_enq(queue, odp_buf_to_hdr((odp_buffer_t)new_pkt), 0); + if (queue_enq(queue, odp_buf_to_hdr((odp_buffer_t)new_pkt), 0)) { + odp_packet_free(new_pkt); + return -1; + } else { + return 0; + } } int packet_classifier(odp_pktio_t pktio, odp_packet_t pkt) diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 0ea6d0e..5ed4ca9 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -70,7 +70,7 @@ 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)) { + if (_odp_packet_classifier(pktio_entry, pkt) == 1) { pkts[j++] = pkt; pktio_entry->s.stats.in_octets += odp_packet_len(pkts[i]);