]> git.baikalelectronics.ru Git - kernel.git/commitdiff
virtio_net: fix endian-ness for RSS
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 11 Aug 2022 12:51:58 +0000 (08:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 12 Aug 2022 10:26:19 +0000 (11:26 +0100)
Using native endian-ness for device supplied fields is wrong
on BE platforms. Sparse warns about this.

Fixes: 70cbb5174443 ("drivers/net/virtio_net: Added RSS hash report.")
Cc: "Andrew Melnychenko" <andrew@daynix.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c

index 3b3eebad39772c9160098f20e32b278dd6e7127b..d4e0a775b1ba794c4420bee76a87076f431d8377 100644 (file)
@@ -1199,7 +1199,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:
@@ -1217,7 +1217,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,