aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-11-23 11:16:19 -0500
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 05:06:32 -0500
commitdc9e51534b70e5c4a99235e940dc6f0f466fe175 (patch)
treefc3c9e242e9dafd4e0186793d8f77c00b31799da /net/packet
parente72fd72e269115f659003bc62a3f020339fe84a6 (diff)
af_packet: virtio 1.0 stubs
This merely fixes sparse warnings, without actually adding support for the new APIs. Still working out the best way to enable the new functionality. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'net/packet')
-rw-r--r--net/packet/af_packet.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 07c04a841ba0..586229a14ad3 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2444,13 +2444,15 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
2444 goto out_unlock; 2444 goto out_unlock;
2445 2445
2446 if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && 2446 if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
2447 (vnet_hdr.csum_start + vnet_hdr.csum_offset + 2 > 2447 (__virtio16_to_cpu(false, vnet_hdr.csum_start) +
2448 vnet_hdr.hdr_len)) 2448 __virtio16_to_cpu(false, vnet_hdr.csum_offset) + 2 >
2449 vnet_hdr.hdr_len = vnet_hdr.csum_start + 2449 __virtio16_to_cpu(false, vnet_hdr.hdr_len)))
2450 vnet_hdr.csum_offset + 2; 2450 vnet_hdr.hdr_len = __cpu_to_virtio16(false,
2451 __virtio16_to_cpu(false, vnet_hdr.csum_start) +
2452 __virtio16_to_cpu(false, vnet_hdr.csum_offset) + 2);
2451 2453
2452 err = -EINVAL; 2454 err = -EINVAL;
2453 if (vnet_hdr.hdr_len > len) 2455 if (__virtio16_to_cpu(false, vnet_hdr.hdr_len) > len)
2454 goto out_unlock; 2456 goto out_unlock;
2455 2457
2456 if (vnet_hdr.gso_type != VIRTIO_NET_HDR_GSO_NONE) { 2458 if (vnet_hdr.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
@@ -2492,7 +2494,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
2492 err = -ENOBUFS; 2494 err = -ENOBUFS;
2493 hlen = LL_RESERVED_SPACE(dev); 2495 hlen = LL_RESERVED_SPACE(dev);
2494 tlen = dev->needed_tailroom; 2496 tlen = dev->needed_tailroom;
2495 skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, vnet_hdr.hdr_len, 2497 skb = packet_alloc_skb(sk, hlen + tlen, hlen, len,
2498 __virtio16_to_cpu(false, vnet_hdr.hdr_len),
2496 msg->msg_flags & MSG_DONTWAIT, &err); 2499 msg->msg_flags & MSG_DONTWAIT, &err);
2497 if (skb == NULL) 2500 if (skb == NULL)
2498 goto out_unlock; 2501 goto out_unlock;
@@ -2534,14 +2537,16 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
2534 2537
2535 if (po->has_vnet_hdr) { 2538 if (po->has_vnet_hdr) {
2536 if (vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { 2539 if (vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
2537 if (!skb_partial_csum_set(skb, vnet_hdr.csum_start, 2540 u16 s = __virtio16_to_cpu(false, vnet_hdr.csum_start);
2538 vnet_hdr.csum_offset)) { 2541 u16 o = __virtio16_to_cpu(false, vnet_hdr.csum_offset);
2542 if (!skb_partial_csum_set(skb, s, o)) {
2539 err = -EINVAL; 2543 err = -EINVAL;
2540 goto out_free; 2544 goto out_free;
2541 } 2545 }
2542 } 2546 }
2543 2547
2544 skb_shinfo(skb)->gso_size = vnet_hdr.gso_size; 2548 skb_shinfo(skb)->gso_size =
2549 __virtio16_to_cpu(false, vnet_hdr.gso_size);
2545 skb_shinfo(skb)->gso_type = gso_type; 2550 skb_shinfo(skb)->gso_type = gso_type;
2546 2551
2547 /* Header must be checked, and gso_segs computed. */ 2552 /* Header must be checked, and gso_segs computed. */
@@ -2912,8 +2917,10 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
2912 struct skb_shared_info *sinfo = skb_shinfo(skb); 2917 struct skb_shared_info *sinfo = skb_shinfo(skb);
2913 2918
2914 /* This is a hint as to how much should be linear. */ 2919 /* This is a hint as to how much should be linear. */
2915 vnet_hdr.hdr_len = skb_headlen(skb); 2920 vnet_hdr.hdr_len =
2916 vnet_hdr.gso_size = sinfo->gso_size; 2921 __cpu_to_virtio16(false, skb_headlen(skb));
2922 vnet_hdr.gso_size =
2923 __cpu_to_virtio16(false, sinfo->gso_size);
2917 if (sinfo->gso_type & SKB_GSO_TCPV4) 2924 if (sinfo->gso_type & SKB_GSO_TCPV4)
2918 vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4; 2925 vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
2919 else if (sinfo->gso_type & SKB_GSO_TCPV6) 2926 else if (sinfo->gso_type & SKB_GSO_TCPV6)
@@ -2931,8 +2938,10 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
2931 2938
2932 if (skb->ip_summed == CHECKSUM_PARTIAL) { 2939 if (skb->ip_summed == CHECKSUM_PARTIAL) {
2933 vnet_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; 2940 vnet_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
2934 vnet_hdr.csum_start = skb_checksum_start_offset(skb); 2941 vnet_hdr.csum_start = __cpu_to_virtio16(false,
2935 vnet_hdr.csum_offset = skb->csum_offset; 2942 skb_checksum_start_offset(skb));
2943 vnet_hdr.csum_offset = __cpu_to_virtio16(false,
2944 skb->csum_offset);
2936 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) { 2945 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
2937 vnet_hdr.flags = VIRTIO_NET_HDR_F_DATA_VALID; 2946 vnet_hdr.flags = VIRTIO_NET_HDR_F_DATA_VALID;
2938 } /* else everything is zero */ 2947 } /* else everything is zero */