git: 0c72405ee99e - stable/14 - ena: Fix RSS sysctl panic when the RSS table is destroyed

From: Arthur Kiyanovski <akiyano_at_FreeBSD.org>
Date: Wed, 04 Nov 2026 21:21:00 UTC
The branch stable/14 has been updated by akiyano:

URL: https://cgit.FreeBSD.org/src/commit/?id=0c72405ee99edf8916fac5ca8643b54d6a9c06d2

commit 0c72405ee99edf8916fac5ca8643b54d6a9c06d2
Author:     Arthur Kiyanovski <akiyano@amazon.com>
AuthorDate: 2026-10-30 01:38:44 +0000
Commit:     Arthur Kiyanovski <akiyano@FreeBSD.org>
CommitDate: 2026-11-04 21:18:02 +0000

    ena: Fix RSS sysctl panic when the RSS table is destroyed
    
    ena_set_io_queue_count() destroys the ena-com RSS state but left
    ENA_FLAG_RSS_ACTIVE set. The RSS sysctl handlers gate on that flag, so
    they ran against state that was gone.
    
    This causes 2 types of issues:
    1. Kernel panic when reading dev.ena.0.rss.key or writing to
       dev.ena.0.rss.indir_table
    2. Returning a stale cached RSS table when reading
       dev.ena.0.rss.indir_table, or a bogus 1 when reading
       dev.ena.0.rss.indir_table_size
    
    ena_set_io_queue_count() is called in 2 cases:
    1. The io_queues_nb sysctl.
    2. Device restore when the device comes back with fewer MSI-X vectors
       than before.
    
    Clear ENA_FLAG_RSS_ACTIVE when the RSS table is destroyed. The handlers
    then fail with ENOTSUP until the next ena_up() rebuilds RSS.
    This both fixes the panics, and stops returning cached and bogus values.
    
    Note: A plain ifconfig down does not destroy the table, so the sysctls
    keep working across a down/up cycle.
    
    Reviewed by: cperciva
    Fixes: 56d41ad5fe9c ("Add sysctl node for ENA IO queues number adjustment")
    Fixes: 2d4d2ed3fef6 ("ena: Reinit RSS table on device restore when queue count shrinks")
    MFC after: 3 days
    Sponsored by: Amazon, Inc.
    Differential Revision: https://reviews.freebsd.org/D61057
    
    (cherry picked from commit eb65bcbf6cb5b8ace59504ea721ff1802e912296)
---
 sys/dev/ena/ena.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c
index 767cccd3918f..04f9193f1bce 100644
--- a/sys/dev/ena/ena.c
+++ b/sys/dev/ena/ena.c
@@ -1302,6 +1302,7 @@ static void
 ena_set_io_queue_count(struct ena_adapter *adapter, uint32_t num)
 {
 	adapter->num_io_queues = num;
+	ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter);
 	/* Force indirection table to be reinitialized */
 	ena_com_rss_destroy(adapter->ena_dev);
 }