From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D838C0650F for ; Mon, 5 Aug 2019 16:38:41 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 0D05D2064A for ; Mon, 5 Aug 2019 16:38:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="XxPvo+gX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D05D2064A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=networkplumber.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8F7F01BDED; Mon, 5 Aug 2019 18:38:31 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id CF7DD1BDEC for ; Mon, 5 Aug 2019 18:38:28 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id i2so36710729plt.1 for ; Mon, 05 Aug 2019 09:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8v7OSOzARnVHBELM/KAu2BccRvpC7XvWrmT3Mxp8KjI=; b=XxPvo+gXYntKoxYBoqs+Ieegp3M0x1eE+hUuzyHx8Eyf/oG3YfqZCA4Kfw9xL2IrSV VnIjLzUySVHruBexxFKdUG2zrBa/JCgyLhVqHlEmzLgI1vRHROMrHIV9xyJhbaWsCOYY USo4hQLwMKF/gRkS73F2Bts2YqkNonA0PCbckWQb1xIurK5y6rnfCQ0D+yzS5o3/spmY DU4qJA2D9baeUMBWXzDdkcH0dYpYTLML5Qdy8sGecyGhq4XcHaPYEP+IURt9k0ISWdt4 2m/kTldZwC107nsRSLaxrJJxpmKruUNU8i3gf/yMHLaz/q0MhFdCewutXHXBlShQ4hMy VnyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8v7OSOzARnVHBELM/KAu2BccRvpC7XvWrmT3Mxp8KjI=; b=doeKKvcBP29n8nUUsFcOF7VUFecS3brwRKMRJWKcCm2rququpIVqTSTusqfMHAnAdx wuof4pMTTSSN75q/HvTTX8EzjoHObMVQNL06V+ig9gMienlj/7y9bk00i18+wzeJJWAK zhAnwaXMvASae/Mc89Rf3cGcrj83lWC8u2q1ecHKxY4UdFiVndyyEUcwxWQRGjtKr6E9 bbM5RVTrzBuBl58lJG1QPtY7fddiI/tEP8KOFwA3rARL9bCxx9IGEFSLjlqLKx2L+6W4 IuGvs5m6jpN4VwpWBw/UWyjZi2cQyGDBXtv5AVnR4aG9V0EGg7mOLwa0ssXIhQbgyFQ0 HSZA== X-Gm-Message-State: APjAAAVq425VnekWLY00snvVGdpbdNhrfNLJXquN1hCjAmenTVqYLgso 4LIA9lbxtrA616xNXCbMIkcwdFGx X-Google-Smtp-Source: APXvYqyqdTYYeNOSFNXN3MrzIsK7PNJeqS4v+5Zb0YbTyC7NQNmT6rp9QhAsJooesw+yjGWCtmk4zA== X-Received: by 2002:a17:902:2bcb:: with SMTP id l69mr146370856plb.155.1565023107774; Mon, 05 Aug 2019 09:38:27 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t9sm19512797pji.18.2019.08.05.09.38.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 09:38:26 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 5 Aug 2019 09:38:17 -0700 Message-Id: <20190805163817.3713-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190805163817.3713-1-stephen@networkplumber.org> References: <20190726165054.24078-1-stephen@networkplumber.org> <20190805163817.3713-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 2/2] examples/multi_process/client_server_mp - fix crash in mp_client with sparse ports X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger The mp_client crashes if run on Azure or any system where ethdev ports are owned. In that case, the tx_buffer and tx_stats for the real port were initialized correctly, but the wrong port was used. For example if the server has Ports 3 and 5. Then calling rte_eth_tx_buffer_flush on any other buffer will dereference null because the tx buffer for that port was not allocated. Also: - the flush code is common enough that it should not be marked unlikely - combine conditions to reduce indentation - avoid unnecessary if() if sent is zero. Fixes: e2366e74e029 ("examples: use buffered Tx") Signed-off-by: Stephen Hemminger --- .../client_server_mp/mp_client/client.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/multi_process/client_server_mp/mp_client/client.c b/examples/multi_process/client_server_mp/mp_client/client.c index c23dd3f378f7..361d90b54b2d 100644 --- a/examples/multi_process/client_server_mp/mp_client/client.c +++ b/examples/multi_process/client_server_mp/mp_client/client.c @@ -246,19 +246,19 @@ main(int argc, char *argv[]) for (;;) { uint16_t i, rx_pkts; - uint16_t port; rx_pkts = rte_ring_dequeue_burst(rx_ring, pkts, PKT_READ_SIZE, NULL); - if (unlikely(rx_pkts == 0)){ - if (need_flush) - for (port = 0; port < ports->num_ports; port++) { - sent = rte_eth_tx_buffer_flush(ports->id[port], client_id, - tx_buffer[port]); - if (unlikely(sent)) - tx_stats->tx[port] += sent; - } + if (rx_pkts == 0 && need_flush) { + for (i = 0; i < ports->num_ports; i++) { + uint16_t port = ports->id[i]; + + sent = rte_eth_tx_buffer_flush(port, + client_id, + tx_buffer[port]); + tx_stats->tx[port] += sent; + } need_flush = 0; continue; } -- 2.20.1