From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 2E29BA00E6 for ; Thu, 18 Apr 2019 19:20:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 10E8F1BC12; Thu, 18 Apr 2019 19:20:59 +0200 (CEST) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 0116C1BC12 for ; Thu, 18 Apr 2019 19:20:57 +0200 (CEST) Received: by mail-wr1-f67.google.com with SMTP id w10so3906735wrm.4 for ; Thu, 18 Apr 2019 10:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ee6F7YLGP6ed/POR9F2AEonwCOIzEWYAuTExUzuqerw=; b=OMTy3zHIhDitrRqeoULwYn6VQZadVQHq9uFOAhFfB1Kmw9wUwrfIP+FcTYL74m/P2G /nhllpMho/bNcre3gBG/34a6mHHOBk5wOVPXIuQzsqt7QbI5vm17n2WwBDUFEiXIbDHd SgjExrE3KTVjzWbpJBUqfCGxqzTFKP2HrEEStYgd68uHgG1TGJynHkPr8r0DG5/tm0zl E8Qo3Z5/NlV9Y4IoVRMBQNuk16XQNNgfIcZq8OwXZn5spSpxscGDy3AhnjdPlNuVlXmm 68Q0UA0QCdHxi3TuXDLbCH2DGsyeg3QidqvnX13TCw8QfbBLH+7Xn1BHhe+eqSe95YEN YfEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ee6F7YLGP6ed/POR9F2AEonwCOIzEWYAuTExUzuqerw=; b=A8bv9HMJcH7R/Wx2wkh4lDYC11lwqeHZGE1J12jQPAI+kxkJ3haYdSDoS+qO6bve8N ZHxOMQYu2KGXYWTY21CBlZokXRmDxfZTTsqa6M716jahf1qAxam3DCPIXzIUGH4okSdA TWYqkGEkc8CHP8d4jOFMiRcEW/gMPJoPiWcC3e17KptOWrvEbjY0TU2girDGDOjjoaGX koQeGkhslGe5CQvJZYMH6WvfkJBf5dh76xiB55afsoMvTVjP4NPPZfs1zNKxdXqU9YXN qYRWDCtW8vxgPFM70C4Dz+t2r0OF8nxvw9DgiSBPn5a3HTFjZR0TvL2Gv68kEQLkXtU2 7RGw== X-Gm-Message-State: APjAAAUY69n6o0EhMqCf286BtmMtWnvmVxokd6iA4zXmodiyM8lRp4hu 1fLL9dudBkgo7G3BwA6OQOI07lf6hgty+Q== X-Google-Smtp-Source: APXvYqy1YCgWypi/65n4ORUJ/kJLKl6+Yly/jsQ/y9tdvI3OYrth/nUDlNoLmeFHYeHFsYRM390gkw== X-Received: by 2002:a5d:434c:: with SMTP id u12mr2015292wrr.92.1555608057778; Thu, 18 Apr 2019 10:20:57 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id c20sm3200878wre.28.2019.04.18.10.20.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 10:20:57 -0700 (PDT) Date: Thu, 18 Apr 2019 19:20:55 +0200 From: Adrien Mazarguil To: Gaetan Rivet Cc: Ferruh Yigit , David Marchand , dev@dpdk.org, stable@dpdk.org Message-ID: <20190418171859.11624-1-adrien.mazarguil@6wind.com> References: <20190418152229.13554-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190418152229.13554-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-stable] [PATCH v3] net/failsafe: fix source port ID in Rx packets X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" When passed to the application, Rx packets retain the port ID value originally set by slave devices. Unfortunately these IDs have no meaning to applications, which are typically unaware of their existence. This confuses those caring about the source port field in mbufs (m->port) which experience issues ranging from traffic drop to crashes. Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD") Cc: stable@dpdk.org Signed-off-by: Adrien Mazarguil Reviewed-by: David Marchand Acked-by: Gaetan Rivet -- v3 changes: Removed unnecessary reference to slavery ("slave" device) for political correctness. Also kept *-by lines as in v2. v2 changes: Modified "rxq->priv->dev->data->port_id" (v18.11-style) to "rxq->priv->data->port_id" (since v19.05) and checked compilation against master this time. Given the limited scope of that change, reviewed-by/acked-by lines were kept. --- drivers/net/failsafe/failsafe_rxtx.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/failsafe/failsafe_rxtx.c b/drivers/net/failsafe/failsafe_rxtx.c index 231c83291..fee08fa23 100644 --- a/drivers/net/failsafe/failsafe_rxtx.c +++ b/drivers/net/failsafe/failsafe_rxtx.c @@ -61,6 +61,21 @@ failsafe_set_burst_fn(struct rte_eth_dev *dev, int force_safe) rte_wmb(); } +/* + * Override source port in Rx packets. + * + * Make Rx packets originate from this PMD instance instead of one of its + * sub-devices. This is mandatory to avoid breaking applications. + */ +static void +failsafe_rx_set_port(struct rte_mbuf **rx_pkts, uint16_t nb_pkts, uint16_t port) +{ + unsigned int i; + + for (i = 0; i != nb_pkts; ++i) + rx_pkts[i]->port = port; +} + uint16_t failsafe_rx_burst(void *queue, struct rte_mbuf **rx_pkts, @@ -87,6 +102,9 @@ failsafe_rx_burst(void *queue, sdev = sdev->next; } while (nb_rx == 0 && sdev != rxq->sdev); rxq->sdev = sdev; + if (nb_rx) + failsafe_rx_set_port(rx_pkts, nb_rx, + rxq->priv->data->port_id); return nb_rx; } @@ -112,6 +130,9 @@ failsafe_rx_burst_fast(void *queue, sdev = sdev->next; } while (nb_rx == 0 && sdev != rxq->sdev); rxq->sdev = sdev; + if (nb_rx) + failsafe_rx_set_port(rx_pkts, nb_rx, + rxq->priv->data->port_id); return nb_rx; } -- 2.11.0