From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 6393F1B9CC for ; Thu, 18 Apr 2019 15:11:28 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id j9so2920358wrn.6 for ; Thu, 18 Apr 2019 06:11:28 -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:mime-version:content-disposition; bh=hwRfl+u0iCW2lNfmR8L5HxnpFObV3SdBghyoIIaZ4/0=; b=V8IrMch7xfv4rDp9i6QI1A+s7bjWESGKXuZkOgus+V/wDarByQj7kU2syQA5McaRcX eo6qpbk7a0HGWasIErZXvyjkXp0UTao78+xaosA5P+rf6vx4NjkPucNlABlrPJGTGZLn C7bTowiKFWal3rzDDv2MhZUD0b4FSdmBzNJKH9YPbcnzIIr0753vqpXBAPLHdVlE2YmI bZvwHpkzUDoYjWC6cn4KtTntbCLIvQ9N2O/KwOaQvgAQDmLvFlU7wTui2HVvR2iOA53W UwiUMxa/3MY16EeUea1OdhUiYxf94dlrbuO//BSPmEVJpIzuI9mTvvy7ByU7tEMZ+LJf nd4g== 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:mime-version :content-disposition; bh=hwRfl+u0iCW2lNfmR8L5HxnpFObV3SdBghyoIIaZ4/0=; b=JKbkWl5nDi4Z4H/XZN30gVik0td6yspRzP0Hq4+5Vs3bqFC4ivXgivgtaSYGC4g08Q MoJ+DJPHTLt0HQlC3b7pehs1td43N/wjNZZCD9r8liX6QvNg0hScQQoJchKOahGlH7q6 YXNci+SipqBdlebTExKHpa1gXmatG42tWHapAvXZlFE3RVXMI7jv9VbO4gv6QUJ4qYU8 GmQM9UCWEHOJ8S8wjY0/EM4j2gLmKG9Gu8Oi8sfVmm4p2SVygnh/sN8c2lFzrnGvBoH4 rCYgQnr+hay8PCFBKqPmt75IMHA08a8t1SEb86vHFJmyzhrEAhoLbTExGQChlGi0F9O4 KSCw== X-Gm-Message-State: APjAAAWDiK5lXqQUGA8Mf6SDuP1Pc0mRtOpYSfL3Fucu8KFJeClNX/g6 Y//4GL2/7UZaiOqOxeP6Pcjz2A== X-Google-Smtp-Source: APXvYqzu3ada448XDNm6HTVbJTkgKKwDzWc8rsNmcyRqsG/M3ynL155taVBcctLMZCzwQHAwAbn2Zg== X-Received: by 2002:adf:ee42:: with SMTP id w2mr6663777wro.161.1555593088221; Thu, 18 Apr 2019 06:11:28 -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 x5sm1445303wmi.37.2019.04.18.06.11.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 06:11:27 -0700 (PDT) Date: Thu, 18 Apr 2019 15:11:26 +0200 From: Adrien Mazarguil To: Gaetan Rivet Cc: Ferruh Yigit , dev@dpdk.org Message-ID: <20190418130419.25675-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] 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 13:11:28 -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") Signed-off-by: Adrien Mazarguil --- 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..e78624127 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->dev->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->dev->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 A533BA00E6 for ; Thu, 18 Apr 2019 15:11:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 759B61B9E7; Thu, 18 Apr 2019 15:11:29 +0200 (CEST) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 6393F1B9CC for ; Thu, 18 Apr 2019 15:11:28 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id j9so2920358wrn.6 for ; Thu, 18 Apr 2019 06:11:28 -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:mime-version:content-disposition; bh=hwRfl+u0iCW2lNfmR8L5HxnpFObV3SdBghyoIIaZ4/0=; b=V8IrMch7xfv4rDp9i6QI1A+s7bjWESGKXuZkOgus+V/wDarByQj7kU2syQA5McaRcX eo6qpbk7a0HGWasIErZXvyjkXp0UTao78+xaosA5P+rf6vx4NjkPucNlABlrPJGTGZLn C7bTowiKFWal3rzDDv2MhZUD0b4FSdmBzNJKH9YPbcnzIIr0753vqpXBAPLHdVlE2YmI bZvwHpkzUDoYjWC6cn4KtTntbCLIvQ9N2O/KwOaQvgAQDmLvFlU7wTui2HVvR2iOA53W UwiUMxa/3MY16EeUea1OdhUiYxf94dlrbuO//BSPmEVJpIzuI9mTvvy7ByU7tEMZ+LJf nd4g== 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:mime-version :content-disposition; bh=hwRfl+u0iCW2lNfmR8L5HxnpFObV3SdBghyoIIaZ4/0=; b=JKbkWl5nDi4Z4H/XZN30gVik0td6yspRzP0Hq4+5Vs3bqFC4ivXgivgtaSYGC4g08Q MoJ+DJPHTLt0HQlC3b7pehs1td43N/wjNZZCD9r8liX6QvNg0hScQQoJchKOahGlH7q6 YXNci+SipqBdlebTExKHpa1gXmatG42tWHapAvXZlFE3RVXMI7jv9VbO4gv6QUJ4qYU8 GmQM9UCWEHOJ8S8wjY0/EM4j2gLmKG9Gu8Oi8sfVmm4p2SVygnh/sN8c2lFzrnGvBoH4 rCYgQnr+hay8PCFBKqPmt75IMHA08a8t1SEb86vHFJmyzhrEAhoLbTExGQChlGi0F9O4 KSCw== X-Gm-Message-State: APjAAAWDiK5lXqQUGA8Mf6SDuP1Pc0mRtOpYSfL3Fucu8KFJeClNX/g6 Y//4GL2/7UZaiOqOxeP6Pcjz2A== X-Google-Smtp-Source: APXvYqzu3ada448XDNm6HTVbJTkgKKwDzWc8rsNmcyRqsG/M3ynL155taVBcctLMZCzwQHAwAbn2Zg== X-Received: by 2002:adf:ee42:: with SMTP id w2mr6663777wro.161.1555593088221; Thu, 18 Apr 2019 06:11:28 -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 x5sm1445303wmi.37.2019.04.18.06.11.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 06:11:27 -0700 (PDT) Date: Thu, 18 Apr 2019 15:11:26 +0200 From: Adrien Mazarguil To: Gaetan Rivet Cc: Ferruh Yigit , dev@dpdk.org Message-ID: <20190418130419.25675-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] 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: <20190418131126.iivRoRkPowTa3ts7BgibIu5hmvLp9gcXxFJb6uLT5Q0@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") Signed-off-by: Adrien Mazarguil --- 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..e78624127 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->dev->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->dev->data->port_id); return nb_rx; } -- 2.11.0