From patchwork Thu Jul 16 16:10:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 51184 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7560422A8A for ; Thu, 16 Jul 2015 16:11:19 +0000 (UTC) Received: by wgbbj7 with SMTP id bj7sf19904651wgb.2 for ; Thu, 16 Jul 2015 09:11:18 -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=Ir9+xZ603WcIpuMBk3+5f5Ed+7nkz6z88bFwBWbOuofcdry9xqHMU22HrYPPjanNjK 6BW2SAdiHE7kD9vHzOGL3mkt35365mbL9AFORvX4hg3mMh8frGUPMSAPWB2SSbaqZC2x EI/KSdLEhGIpP81UIGC+7dxPABROSRepnHgOBOFAxw4K8Zn1Pbf4zuvg8X+t/It2cBKS w8aZHfgsuBWmg9rP6KFJGitChDMzVaTgDHEj/t/GpSaJJSgeoaZ+mrEYiBbcCcQrR2xE Hd31q18Mq1+HVMSTtQhA4VA1gvbFofOJbCfcUmFjMwPholVRNEcOLGjfOv9GZ3fMGYdz IG0Q== X-Gm-Message-State: ALoCoQlt1NSb063gAYN4jGP5aoIQ9wRvK0e/v1t0CmPjuNW463iQI9lL1iEf/eN+p8P68XaXtktv X-Received: by 10.180.90.106 with SMTP id bv10mr2227374wib.6.1437063078774; Thu, 16 Jul 2015 09:11:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.3 with SMTP id ky3ls394948lab.70.gmail; Thu, 16 Jul 2015 09:11:18 -0700 (PDT) X-Received: by 10.112.155.164 with SMTP id vx4mr10075832lbb.38.1437063078483; Thu, 16 Jul 2015 09:11:18 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id c4si7315751laf.113.2015.07.16.09.11.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 09:11:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbpo10 with SMTP id po10so46482156lbb.3 for ; Thu, 16 Jul 2015 09:11:18 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr10325786lbc.32.1437063078344; Thu, 16 Jul 2015 09:11:18 -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 hn6csp353493lbb; Thu, 16 Jul 2015 09:11:17 -0700 (PDT) X-Received: by 10.140.86.212 with SMTP id p78mr18415570qgd.49.1437063077117; Thu, 16 Jul 2015 09:11:17 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a74si10110904qgf.30.2015.07.16.09.11.16; Thu, 16 Jul 2015 09:11:17 -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 3C517620B4; Thu, 16 Jul 2015 16:11:16 +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 67E6861FD0; Thu, 16 Jul 2015 16:11:10 +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 24F2561FA1; Thu, 16 Jul 2015 16:11:06 +0000 (UTC) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by lists.linaro.org (Postfix) with ESMTPS id 4357561EDD for ; Thu, 16 Jul 2015 16:11:01 +0000 (UTC) Received: by wibxm9 with SMTP id xm9so17710585wib.0 for ; Thu, 16 Jul 2015 09:11:00 -0700 (PDT) X-Received: by 10.194.78.84 with SMTP id z20mr21145107wjw.141.1437063060552; Thu, 16 Jul 2015 09:11:00 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id c7sm13832753wjb.19.2015.07.16.09.10.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 09:10:59 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 16 Jul 2015 19:10:55 +0300 Message-Id: <1437063055-14984-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCHv2] test: do not use negative 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.179 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