aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet
diff options
context:
space:
mode:
authorJarno Rajahalme <jarno@ovn.org>2016-11-18 18:40:41 -0500
committerDavid S. Miller <davem@davemloft.net>2016-11-19 10:37:03 -0500
commitdb60eb5f6506cbfb437cf51be050368e6577a848 (patch)
tree5d64ea849e655fd6a04e6e30619c08b8c0382567 /net/packet
parent9403cd7cbb08aa3709c632decafa2014c8ed96e6 (diff)
af_packet: Use virtio_net_hdr_to_skb().
Use the common virtio_net_hdr_to_skb() instead of open coding it. Other call sites were changed by commit fd2a0437dc, but this one was missed, maybe because it is split in two parts of the source code. Interim comparisons of 'vnet_hdr->gso_type' still work as both the vnet_hdr and skb notion of gso_type is zero when there is no gso. Fixes: fd2a0437dc ("virtio_net: introduce virtio_net_hdr_{from,to}_skb") Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet')
-rw-r--r--net/packet/af_packet.c51
1 files changed, 3 insertions, 48 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index abe6c0b6683c..1816b77e55b5 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2388,8 +2388,6 @@ static void tpacket_set_protocol(const struct net_device *dev,
2388 2388
2389static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t len) 2389static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t len)
2390{ 2390{
2391 unsigned short gso_type = 0;
2392
2393 if ((vnet_hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && 2391 if ((vnet_hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
2394 (__virtio16_to_cpu(vio_le(), vnet_hdr->csum_start) + 2392 (__virtio16_to_cpu(vio_le(), vnet_hdr->csum_start) +
2395 __virtio16_to_cpu(vio_le(), vnet_hdr->csum_offset) + 2 > 2393 __virtio16_to_cpu(vio_le(), vnet_hdr->csum_offset) + 2 >
@@ -2401,29 +2399,6 @@ static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t len)
2401 if (__virtio16_to_cpu(vio_le(), vnet_hdr->hdr_len) > len) 2399 if (__virtio16_to_cpu(vio_le(), vnet_hdr->hdr_len) > len)
2402 return -EINVAL; 2400 return -EINVAL;
2403 2401
2404 if (vnet_hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
2405 switch (vnet_hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
2406 case VIRTIO_NET_HDR_GSO_TCPV4:
2407 gso_type = SKB_GSO_TCPV4;
2408 break;
2409 case VIRTIO_NET_HDR_GSO_TCPV6:
2410 gso_type = SKB_GSO_TCPV6;
2411 break;
2412 case VIRTIO_NET_HDR_GSO_UDP:
2413 gso_type = SKB_GSO_UDP;
2414 break;
2415 default:
2416 return -EINVAL;
2417 }
2418
2419 if (vnet_hdr->gso_type & VIRTIO_NET_HDR_GSO_ECN)
2420 gso_type |= SKB_GSO_TCP_ECN;
2421
2422 if (vnet_hdr->gso_size == 0)
2423 return -EINVAL;
2424 }
2425
2426 vnet_hdr->gso_type = gso_type; /* changes type, temporary storage */
2427 return 0; 2402 return 0;
2428} 2403}
2429 2404
@@ -2443,27 +2418,6 @@ static int packet_snd_vnet_parse(struct msghdr *msg, size_t *len,
2443 return __packet_snd_vnet_parse(vnet_hdr, *len); 2418 return __packet_snd_vnet_parse(vnet_hdr, *len);
2444} 2419}
2445 2420
2446static int packet_snd_vnet_gso(struct sk_buff *skb,
2447 struct virtio_net_hdr *vnet_hdr)
2448{
2449 if (vnet_hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
2450 u16 s = __virtio16_to_cpu(vio_le(), vnet_hdr->csum_start);
2451 u16 o = __virtio16_to_cpu(vio_le(), vnet_hdr->csum_offset);
2452
2453 if (!skb_partial_csum_set(skb, s, o))
2454 return -EINVAL;
2455 }
2456
2457 skb_shinfo(skb)->gso_size =
2458 __virtio16_to_cpu(vio_le(), vnet_hdr->gso_size);
2459 skb_shinfo(skb)->gso_type = vnet_hdr->gso_type;
2460
2461 /* Header must be checked, and gso_segs computed. */
2462 skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
2463 skb_shinfo(skb)->gso_segs = 0;
2464 return 0;
2465}
2466
2467static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb, 2421static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
2468 void *frame, struct net_device *dev, void *data, int tp_len, 2422 void *frame, struct net_device *dev, void *data, int tp_len,
2469 __be16 proto, unsigned char *addr, int hlen, int copylen, 2423 __be16 proto, unsigned char *addr, int hlen, int copylen,
@@ -2723,7 +2677,8 @@ tpacket_error:
2723 } 2677 }
2724 } 2678 }
2725 2679
2726 if (po->has_vnet_hdr && packet_snd_vnet_gso(skb, vnet_hdr)) { 2680 if (po->has_vnet_hdr && virtio_net_hdr_to_skb(skb, vnet_hdr,
2681 vio_le())) {
2727 tp_len = -EINVAL; 2682 tp_len = -EINVAL;
2728 goto tpacket_error; 2683 goto tpacket_error;
2729 } 2684 }
@@ -2914,7 +2869,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
2914 packet_pick_tx_queue(dev, skb); 2869 packet_pick_tx_queue(dev, skb);
2915 2870
2916 if (po->has_vnet_hdr) { 2871 if (po->has_vnet_hdr) {
2917 err = packet_snd_vnet_gso(skb, &vnet_hdr); 2872 err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le());
2918 if (err) 2873 if (err)
2919 goto out_free; 2874 goto out_free;
2920 len += sizeof(vnet_hdr); 2875 len += sizeof(vnet_hdr);