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 D4AE0A00E6 for ; Thu, 18 Apr 2019 17:32:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B55AE1BBED; Thu, 18 Apr 2019 17:32:58 +0200 (CEST) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id 7E8261BBD0 for ; Thu, 18 Apr 2019 17:32:55 +0200 (CEST) Received: by mail-wm1-f68.google.com with SMTP id z11so3273565wmi.0 for ; Thu, 18 Apr 2019 08:32:55 -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=GziczzaKEmMsyXUeOrByM+6PquQok/wMrKBLW6oRWAA=; b=VUIbw/P0kPeDXXALC1jupxWC0gsux1sanF0rVjxfZXCc2/fLUwuKcGHeupfz5dVyE9 ahkJ4kQpP33mkMXh+Rj6HQcPHSwrUhS0j9RNM3xWIRfr+lpOjx+cTIqKg/50uKJ/DuSu dSdZ1cgJ7QOQlfRZGS1HCy9lSnfw9SAfxs5EPoS+/PbET+R3gJC7Om99CAqpn6VKac3Q iE9c7b4J4kVJqB2QtNmUdbg0R1LTZJZQG+CHfYkMeikMtFwEf8W2M35kwscH9n+4Utw5 HfSnqKanGYuqdhr/pUUZJGXCxlkFCrAct4VczQqyabL/8Fq64MkQA/0/AqpDiZQsCb0V hLkg== 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=GziczzaKEmMsyXUeOrByM+6PquQok/wMrKBLW6oRWAA=; b=T3+bvbYMtF8SoI2XtPku+XOq83rTwbrToE8OJqWL25C7uDbj34Orq0wSv7DrfqkhtJ Xv5X0R+L4/1v37a7tyZQRnRb7NlQ24NrsvdX2lPW3hLou/wxog42NEiAQtepDoFKyfjK dwRvbwLrKoIUV81i+LyhI9UwNDM0wBTJhwE969dSYfZBG0ESv7L13aC27sPK0/FxkEVz OaEGgl7CMB5RptQRWBzkFwzP+KIZB+HPgfIxu0lbcZNMv/CMs6qerB8aCLjiZGmnmRGa F+JptnRShGbwStgCiGAoZ+hR3tdTh9RUxp+CQfDsFv0TSaupMOFOeNB3i9Ld/iBaQ5ug Ejhw== X-Gm-Message-State: APjAAAUwX4m/gv+skjCCpZ2NHDAXle6LurtXl0jiFiLDs0n7FQNUlqi8 S67eU4FfyJDTxYR4tFgMZkiiSQ== X-Google-Smtp-Source: APXvYqzOWZC1QhMhAQLbGoBrKzuRQGwOT8Mppm74kIvfqanSHWbeUMJIXQO+a9bjptQagUaOEPoOpg== X-Received: by 2002:a1c:7f10:: with SMTP id a16mr3533680wmd.30.1555601575208; Thu, 18 Apr 2019 08:32:55 -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 w12sm2090529wrg.29.2019.04.18.08.32.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 08:32:53 -0700 (PDT) Date: Thu, 18 Apr 2019 17:32:52 +0200 From: Adrien Mazarguil To: Gaetan Rivet Cc: Ferruh Yigit , David Marchand , dev@dpdk.org, stable@dpdk.org Message-ID: <20190418152229.13554-1-adrien.mazarguil@6wind.com> References: <20190418130419.25675-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190418130419.25675-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-stable] [PATCH v2] 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 -- 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..b9cddec78 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 + * slaves. 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