From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id 84DD61BBD9 for ; Thu, 18 Apr 2019 17:32:55 +0200 (CEST) Received: by mail-wm1-f65.google.com with SMTP id c1so3219844wml.4 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=sK4ZBsfqXNiUtIXHTpXJcjaBx+/YyS9fO4cEOXcGu+SF0tBY+M/8wvtwX34a1pK+r9 Ak0U3cFzXEabtlXy9sP8mMvaFOSbTxbK3zo5U4FcYYqJA/zuEQUbvYOOWParUbEVvc9s FFochZOpk83ktMLygtnT/K9tXCYetfQaNoa1UlSXdkS//doJ3CiX1dKoaGqmSxyZTz3W 3BTiD3UqI6mu3twcvheUH4YVXNpXSrML+IJomsXGIk3kZ7Uo7M55294BgfLQkk9HjgoO kGyRdE2D5yiMzOskDojEz4uCsFOMCzOrUkIXGTCMHaqYq4vBZTX7gzH92C+GSdnWfFTh usxQ== X-Gm-Message-State: APjAAAW670ntfr6OvDL1Sy7TL4qeWkczQXAGTTVFQW9Y7GeOkObSY8Bz StSccIRDgPgdzPs6B5RX69JTIw== 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-dev] [PATCH v2] net/failsafe: fix source port ID in Rx packets 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: , X-List-Received-Date: Thu, 18 Apr 2019 15:32:55 -0000 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 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 C3598A00E6 for ; Thu, 18 Apr 2019 17:32:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2794E1BBD9; Thu, 18 Apr 2019 17:32:56 +0200 (CEST) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id 84DD61BBD9 for ; Thu, 18 Apr 2019 17:32:55 +0200 (CEST) Received: by mail-wm1-f65.google.com with SMTP id c1so3219844wml.4 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=sK4ZBsfqXNiUtIXHTpXJcjaBx+/YyS9fO4cEOXcGu+SF0tBY+M/8wvtwX34a1pK+r9 Ak0U3cFzXEabtlXy9sP8mMvaFOSbTxbK3zo5U4FcYYqJA/zuEQUbvYOOWParUbEVvc9s FFochZOpk83ktMLygtnT/K9tXCYetfQaNoa1UlSXdkS//doJ3CiX1dKoaGqmSxyZTz3W 3BTiD3UqI6mu3twcvheUH4YVXNpXSrML+IJomsXGIk3kZ7Uo7M55294BgfLQkk9HjgoO kGyRdE2D5yiMzOskDojEz4uCsFOMCzOrUkIXGTCMHaqYq4vBZTX7gzH92C+GSdnWfFTh usxQ== X-Gm-Message-State: APjAAAW670ntfr6OvDL1Sy7TL4qeWkczQXAGTTVFQW9Y7GeOkObSY8Bz StSccIRDgPgdzPs6B5RX69JTIw== 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="UTF-8" Content-Disposition: inline In-Reply-To: <20190418130419.25675-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v2] net/failsafe: fix source port ID in Rx packets 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" Message-ID: <20190418153252.sAD2559BTGgfXqKcyP7GYzXNGKUCjhF5JOo0YquWbYE@z> 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