Skip to contentSkip to conversation

virtio_net: fix endian-ness for RSS

PATCH In review Michael S. Tsirkin 2 participants 2 messages Aug 11, 2022 – Aug 15, 2022 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 virtio_net: fix endian-ness for RSS

Using native endian-ness for device supplied fields is wrong on BE platforms. Sparse warns about this.

Fixes 91f41f01d219 ("drivers/net/virtio_net: Added RSS hash report.")
Cc "Andrew Melnychenko" <[email protected]>
---
 drivers/net/virtio_net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio_net.c +2 -2
index d9c434b00e9b..6e9868c860bc 100644
@@ -1208,7 +1208,7 @@ static void virtio_skb_set_hash(const struct virtio_net_hdr_v1_hash *hdr_hash,
 	if (!hdr_hash || !skb)
 		return;
 
-	switch ((int)hdr_hash->hash_report) {
+	switch (__le16_to_cpu(hdr_hash->hash_report)) {
 	case VIRTIO_NET_HASH_REPORT_TCPv4:
 	case VIRTIO_NET_HASH_REPORT_UDPv4:
 	case VIRTIO_NET_HASH_REPORT_TCPv6:
@@ -1226,7 +1226,7 @@ static void virtio_skb_set_hash(const struct virtio_net_hdr_v1_hash *hdr_hash,
 	default:
 		rss_hash_type = PKT_HASH_TYPE_NONE;
 	}
-	skb_set_hash(skb, (unsigned int)hdr_hash->hash_value, rss_hash_type);
+	skb_set_hash(skb, __le32_to_cpu(hdr_hash->hash_value), rss_hash_type);
 }
 
 static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
Signature · 6 lines
MST

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

A message that is not in the archive (sent off-list or not yet received): 166030021657.10916.8438944707929097441.git-patchwork-notify@kernel.org

Reviewed-by
#2 lore raw
Quoted 16 lines · On Fri, Aug 12, 2022 at 1:30 PM <[email protected]> wrote:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Thu, 11 Aug 2022 08:51:58 -0400 you wrote:

Using native endian-ness for device supplied fields is wrong on BE platforms. Sparse warns about this.

Fixes 91f41f01d219 ("drivers/net/virtio_net: Added RSS hash report.")
Cc "Andrew Melnychenko" <[email protected]>

[...]

Quoted 10 lines

Here is the summary with links:
- virtio_net: fix endian-ness for RSS

    https://git.kernel.org/netdev/net/c/95bb633048fa

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization