Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Linus Walleij
Tue, 10 Nov 2026 22:13
[PATCH net-next v7 18/18] net: ethernet: cortina: Fix ethtool statistics reads
Author: Linus Walleij
Date: Tue, 10 Nov 2026 22:13
Date: Tue, 10 Nov 2026 22:13
65 lines
10040 bytes
10040 bytes
The TX statistics reader resets p on a seqcount retry but writes through
values instead. A retry on 32-bit systems therefore writes another 18
counters past the end of the ethtool statistics array. ETHTOOL_GSTATS
does not require privileges.
Write through p so each retry overwrites the same output slots. Stop
clearing the fragment counters from the reader, which races with TX
updates and resets the counters on each read. Snapshot tx_hw_csummed
under ir_stats_syncp, matching its writer, and retain its output position.
Found during Sashiko review and checked with an extracted-reader host
harness that forces seqcount retries. The old reader overwrote guard
entries and cleared counters; the fixed reader stays within the output
array and preserves counters.
Tested on the D-Link DIR-685 with intense transfers and ping storms,
reading out stats with ethtool at the same time.
Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
drivers/net/ethernet/cortina/gemini.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 1007fd54cb05..b586205a7e20 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -2478,6 +2478,7 @@ static void gmac_get_ethtool_stats(struct net_device *netdev,
{
struct gemini_ethernet_port *port = netdev_priv(netdev);
unsigned int start;
+ u64 tx_hw_csummed;
u64 *p;
int i;
@@ -2490,6 +2491,7 @@ static void gmac_get_ethtool_stats(struct net_device *netdev,
for (i = 0; i < RX_STATS_NUM; i++)
*p++ = port->hw_stats[i];
+ tx_hw_csummed = port->tx_hw_csummed;
} while (u64_stats_fetch_retry(&port->ir_stats_syncp, start));
values = p;
@@ -2513,12 +2515,10 @@ static void gmac_get_ethtool_stats(struct net_device *netdev,
p = values;
start = u64_stats_fetch_begin(&port->tx_stats_syncp);
- for (i = 0; i < TX_MAX_FRAGS; i++) {
- *values++ = port->tx_frag_stats[i];
- port->tx_frag_stats[i] = 0;
- }
- *values++ = port->tx_frags_linearized;
- *values++ = port->tx_hw_csummed;
+ for (i = 0; i < TX_MAX_FRAGS; i++)
+ *p++ = port->tx_frag_stats[i];
+ *p++ = port->tx_frags_linearized;
+ *p++ = tx_hw_csummed;
} while (u64_stats_fetch_retry(&port->tx_stats_syncp, start));
}
--
2.56.0
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads