Thread (29 messages) 29 messages, 4 authors, 2026-02-26

Re: [PATCH net-next,2/2] virtio_net: replace RSS key size max check with BUILD_BUG_ON

From: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Date: 2026-02-25 09:22:11
Also in: virtualization

On Tue, 24 Feb 2026 12:28:50 +0530, Srujana Challa [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Since NETDEV_RSS_KEY_LEN was increased to 256 in net-next, use
BUILD_BUG_ON to enforce the limit at compile time and remove the
redundant runtime max check.

Signed-off-by: Srujana Challa <schalla@marvell.com>
---
 drivers/net/virtio_net.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index eeefe8abc122..768ad5523dfa 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -6639,13 +6639,7 @@ static int virtnet_validate(struct virtio_device *vdev)
 			__virtio_clear_bit(vdev, VIRTIO_NET_F_RSS);
 			__virtio_clear_bit(vdev, VIRTIO_NET_F_HASH_REPORT);
 		}
-		if (key_sz > NETDEV_RSS_KEY_LEN) {
-			dev_warn(&vdev->dev,
-				 "rss_max_key_size=%u exceeds driver limit %u, disabling RSS\n",
-				 key_sz, NETDEV_RSS_KEY_LEN);
-			__virtio_clear_bit(vdev, VIRTIO_NET_F_RSS);
-			__virtio_clear_bit(vdev, VIRTIO_NET_F_HASH_REPORT);
-		}
+		BUILD_BUG_ON(type_max(key_sz) >= NETDEV_RSS_KEY_LEN);
Do we really need this check?

If I understand correctly, the intention is to cap key_sz at 256. However, since
key_sz is of type u8, its maximum value is inherently 255, making this check
redundant. This is not only limited by this kernel code, the virtio-net spec
defines this.

Moreover, if NETDEV_RSS_KEY_LEN is ever reduced to a value smaller than 256 in
the future, this check would no longer enforce the intended limit correctly.


Moreover, you should add a cover letter.

Thanks.




 	}

 	return 0;
--
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help