From: Adrien Mazarguil Date: Thu, 18 Apr 2019 17:20:55 +0000 (+0200) Subject: net/failsafe: fix source port id in Rx packets X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=98e91784d918f0575c9c74f5fdfd7602c3c9cc92;p=dpdk.git net/failsafe: fix source port id in Rx packets 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 --- diff --git a/drivers/net/failsafe/failsafe_rxtx.c b/drivers/net/failsafe/failsafe_rxtx.c index 231c832912..fee08fa23c 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; }