From patchwork Mon Jun 2 17:10:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 31298 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6D698203C2 for ; Mon, 2 Jun 2014 17:10:40 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id cm18sf9102092qab.5 for ; Mon, 02 Jun 2014 10:10:40 -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:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=t/9249lk41LrveyUi/LXEz2B++7Gc9eTOl+RVfOQCzc=; b=TeAf1RRtRwVALYqhzBR5c8eLmnZx64ZF1b6hHhOAqUs1SCF45XJqBG3Gy4ve2Jmr6L jqBYv8NOVG/VtrC0OFUtYw9qZeWjTqqWrVUtebFlKCFy4zOM0LmvXP9Eh3b5shiC5N8P 7ZzyUWUX7KQkkYg1yo46Se5m+izQQZ9iIpJfUWBSUUe7vFYwo6FOS/gSGK4WtSaeiZ8m MydyZBlT0/qSZYoONOO7yCCpmROZOO2q/91MYJfG2cZZOkvklzBEiMKvfLlMTezeY3cU JvNfz9NJwOiA65fXvMZbmgen8JHYQXRCKFm77sRkVpB/szzG2F0lWINLzbcb5VwBQkKT cIGw== X-Gm-Message-State: ALoCoQkIDa47nwIaQ43IuruqaG6TC8UAC60sI28e4P9tjY9QShmdB7G/B2OLQpB5HYDWEWy7zwun X-Received: by 10.236.162.9 with SMTP id x9mr12146694yhk.17.1401729040175; Mon, 02 Jun 2014 10:10:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.115 with SMTP id e106ls2098996qgd.65.gmail; Mon, 02 Jun 2014 10:10:40 -0700 (PDT) X-Received: by 10.58.82.106 with SMTP id h10mr1823639vey.60.1401729040027; Mon, 02 Jun 2014 10:10:40 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id cb8si8274042vcb.36.2014.06.02.10.10.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 10:10:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id pa12so5470811veb.40 for ; Mon, 02 Jun 2014 10:10:39 -0700 (PDT) X-Received: by 10.58.245.2 with SMTP id xk2mr31507209vec.9.1401729039945; Mon, 02 Jun 2014 10:10:39 -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.220.221.72 with SMTP id ib8csp113223vcb; Mon, 2 Jun 2014 10:10:39 -0700 (PDT) X-Received: by 10.140.85.102 with SMTP id m93mr48504737qgd.26.1401729039454; Mon, 02 Jun 2014 10:10:39 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id n6si18182850qct.3.2014.06.02.10.10.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Jun 2014 10:10:39 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WrVja-0002PG-CV; Mon, 02 Jun 2014 17:09:18 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WrVjS-0002Ou-5O for lng-odp@lists.linaro.org; Mon, 02 Jun 2014 17:09:10 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 02 Jun 2014 18:10:29 +0100 Received: from e106441.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 Jun 2014 18:10:26 +0100 From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Mon, 2 Jun 2014 18:10:00 +0100 Message-Id: <1401729001-15729-2-git-send-email-stuart.haslam@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401729001-15729-1-git-send-email-stuart.haslam@arm.com> References: <1401729001-15729-1-git-send-email-stuart.haslam@arm.com> X-OriginalArrivalTime: 02 Jun 2014 17:10:26.0621 (UTC) FILETIME=[8C466ED0:01CF7E85] X-MC-Unique: 114060218102903201 X-Topics: patch Subject: [lng-odp] [PATCH 1/2] Fix drop_err_pkts to correctly discard bad packets X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 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 The drop_err_pkts function is intended to discard packets that input parsing has marked as containing errors (e.g. short frame). It correctly identifies and frees bad packets but an error in the way pkt_tbl is updated means bad packet handles aren't actually removed, later use of the stale packet handle results in a SEGV. The pkt_cnt is decremented though, so for each bad packet a good packet (within the same burst) is dropped and leaked. Signed-off-by: Stuart Haslam Reviewed-by: Anders Roxell --- test/l2fwd/l2fwd.c | 2 +- test/packet/odp_example_pktio.c | 2 +- test/packet_netmap/odp_example_pktio_netmap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/l2fwd/l2fwd.c b/test/l2fwd/l2fwd.c index fb1b949..49e113d 100644 --- a/test/l2fwd/l2fwd.c +++ b/test/l2fwd/l2fwd.c @@ -447,7 +447,7 @@ static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len) odp_packet_free(pkt); /* Drop */ pkt_cnt--; } else if (odp_unlikely(i != j++)) { - pkt_tbl[j] = pkt; + pkt_tbl[j-1] = pkt; } } diff --git a/test/packet/odp_example_pktio.c b/test/packet/odp_example_pktio.c index 3acb1fb..91aa6d1 100644 --- a/test/packet/odp_example_pktio.c +++ b/test/packet/odp_example_pktio.c @@ -411,7 +411,7 @@ static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len) odp_packet_free(pkt); /* Drop */ pkt_cnt--; } else if (odp_unlikely(i != j++)) { - pkt_tbl[j] = pkt; + pkt_tbl[j-1] = pkt; } } diff --git a/test/packet_netmap/odp_example_pktio_netmap.c b/test/packet_netmap/odp_example_pktio_netmap.c index f50f764..7d33b19 100644 --- a/test/packet_netmap/odp_example_pktio_netmap.c +++ b/test/packet_netmap/odp_example_pktio_netmap.c @@ -370,7 +370,7 @@ static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len) odp_packet_free(pkt); /* Drop */ pkt_cnt--; } else if (odp_unlikely(i != j++)) { - pkt_tbl[j] = pkt; + pkt_tbl[j-1] = pkt; } }