From patchwork Thu Jul 16 16:07:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 51183 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AC0B222A8A for ; Thu, 16 Jul 2015 16:07:49 +0000 (UTC) Received: by lbvb1 with SMTP id b1sf19373225lbv.3 for ; Thu, 16 Jul 2015 09:07:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=WTHQXDAkjG6H9gFGWVhF1UzygY+qG+AMHul4pW0AAWA=; b=WZXofih5vrt3NhDNImTy2jUVM41nBqXrTMrol1dRnq/dB6Ss3Qg9wH4zOFnBSU3fWk ShcnyM5dOMGW8RJqKPD5InDhej93B8Xb6wj0/7goppT1GxjcCFfTPW4sJBpE2o8WcQO/ YtsaFTYNc7bF6H0GxlviwGv+5xRJ+sF1268MuUr0FYwTdm49OxdNX2mjSYoYzfW3KT8G YNv9lI+uR99GD84P7VDt2O5ehH9sZkRNf5nsMOGfd8XTwCWSj6wK5vEfbHo2dX0C/szq kdZDVSo/CcIKQ+hMqFdWaObM87KIrcAeQEWUM4rcD9tYHA7mnGbJ7DfxzpaZCUxZMWv7 EZrg== X-Gm-Message-State: ALoCoQkr/Xe0nJ+sN1b2KDNCdGFG2YmDIARDIx5xWXgVOrOtov24Ot2hJADFceryPbWZnfppkQlT X-Received: by 10.180.36.242 with SMTP id t18mr1745493wij.3.1437062868227; Thu, 16 Jul 2015 09:07:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.7 with SMTP id f7ls371192lah.48.gmail; Thu, 16 Jul 2015 09:07:48 -0700 (PDT) X-Received: by 10.152.42.205 with SMTP id q13mr9917905lal.119.1437062868061; Thu, 16 Jul 2015 09:07:48 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id p6si7295622lbm.170.2015.07.16.09.07.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 09:07:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lblf12 with SMTP id f12so46550082lbl.2 for ; Thu, 16 Jul 2015 09:07:47 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr10049674lbb.29.1437062867879; Thu, 16 Jul 2015 09:07:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp351347lbb; Thu, 16 Jul 2015 09:07:46 -0700 (PDT) X-Received: by 10.55.17.197 with SMTP id 66mr18453016qkr.90.1437062866461; Thu, 16 Jul 2015 09:07:46 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c93si10109957qgd.5.2015.07.16.09.07.45; Thu, 16 Jul 2015 09:07:46 -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; Received: by lists.linaro.org (Postfix, from userid 109) id AC3A6620B2; Thu, 16 Jul 2015 16:07:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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, T_FRT_BELOW2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 93392620AE; Thu, 16 Jul 2015 16:07:41 +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 04F02620AF; Thu, 16 Jul 2015 16:07:39 +0000 (UTC) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by lists.linaro.org (Postfix) with ESMTPS id EB357620AD for ; Thu, 16 Jul 2015 16:07:37 +0000 (UTC) Received: by wibud3 with SMTP id ud3so20696627wib.0 for ; Thu, 16 Jul 2015 09:07:37 -0700 (PDT) X-Received: by 10.194.158.42 with SMTP id wr10mr19878513wjb.81.1437062857116; Thu, 16 Jul 2015 09:07:37 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id m4sm13800655wjb.37.2015.07.16.09.07.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 09:07:35 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 16 Jul 2015 19:07:31 +0300 Message-Id: <1437062851-24624-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] test: l2fwd: do not use negativ array index X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 odp_pktio_send() can return -1 error and that return code can be used as array index in code bellow. On error just increase drop counter and free packets. https://bugs.linaro.org/show_bug.cgi?id=1688 Signed-off-by: Maxim Uvarov Reviewed-by: Bill Fischofer --- example/packet/odp_pktio.c | 1 + test/performance/odp_l2fwd.c | 1 + 2 files changed, 2 insertions(+) diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 8004d69..040571b 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -291,6 +291,7 @@ static void *pktio_ifburst_thread(void *arg) /* Swap Eth MACs and IP-addrs */ swap_pkt_addrs(pkt_tbl, pkts_ok); sent = odp_pktio_send(pktio, pkt_tbl, pkts_ok); + sent = sent > 0 ? sent : 0; if (odp_unlikely(sent < pkts_ok)) { err_cnt += pkts_ok - sent; do diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index 9cc201f..a408c7d 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -231,6 +231,7 @@ static void *pktio_ifburst_thread(void *arg) if (pkts_ok > 0) { int sent = odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok); + sent = sent > 0 ? sent : 0; if (odp_unlikely(sent < pkts_ok)) { stats->drops += pkts_ok - sent; do