]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gve: handle overflow when reporting TX consumed descriptors
authorJoshua Washington <joshwash@google.com>
Wed, 2 Apr 2025 00:10:37 +0000 (00:10 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:43:45 +0000 (10:43 +0200)
commit 15970e1b23f5c25db88c613fddf9131de086f28e upstream.

When the tx tail is less than the head (in cases of wraparound), the TX
consumed descriptor statistic in DQ will be reported as
UINT32_MAX - head + tail, which is incorrect. Mask the difference of
head and tail according to the ring size when reporting the statistic.

Cc: stable@vger.kernel.org
Fixes: 2c9198356d56 ("gve: Add consumed counts to ethtool stats")
Signed-off-by: Joshua Washington <joshwash@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250402001037.2717315-1-hramamurthy@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/google/gve/gve_ethtool.c

index 033f17cb96be022a966886a8c1f241cd32c59b78..7e60139f8ac574424e6be43241e14da88dc81912 100644 (file)
@@ -327,7 +327,9 @@ gve_get_ethtool_stats(struct net_device *netdev,
                                 */
                                data[i++] = 0;
                                data[i++] = 0;
-                               data[i++] = tx->dqo_tx.tail - tx->dqo_tx.head;
+                               data[i++] =
+                                       (tx->dqo_tx.tail - tx->dqo_tx.head) &
+                                       tx->mask;
                        }
                        do {
                                start =