mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	packet: use common code for virtio_net_hdr and skb GSO conversion
Replace open coded conversion between virtio_net_hdr to skb GSO info with virtio_net_hdr_from_skb Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									e858fae2b0
								
							
						
					
					
						commit
						1276f24eee
					
				
					 1 changed files with 2 additions and 34 deletions
				
			
		| 
						 | 
					@ -1979,41 +1979,9 @@ static int __packet_rcv_vnet(const struct sk_buff *skb,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	*vnet_hdr = (const struct virtio_net_hdr) { 0 };
 | 
						*vnet_hdr = (const struct virtio_net_hdr) { 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (skb_is_gso(skb)) {
 | 
						if (virtio_net_hdr_from_skb(skb, vnet_hdr, vio_le()))
 | 
				
			||||||
		struct skb_shared_info *sinfo = skb_shinfo(skb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* This is a hint as to how much should be linear. */
 | 
					 | 
				
			||||||
		vnet_hdr->hdr_len =
 | 
					 | 
				
			||||||
			__cpu_to_virtio16(vio_le(), skb_headlen(skb));
 | 
					 | 
				
			||||||
		vnet_hdr->gso_size =
 | 
					 | 
				
			||||||
			__cpu_to_virtio16(vio_le(), sinfo->gso_size);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (sinfo->gso_type & SKB_GSO_TCPV4)
 | 
					 | 
				
			||||||
			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 | 
					 | 
				
			||||||
		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 | 
					 | 
				
			||||||
			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
 | 
					 | 
				
			||||||
		else if (sinfo->gso_type & SKB_GSO_UDP)
 | 
					 | 
				
			||||||
			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 | 
					 | 
				
			||||||
		else if (sinfo->gso_type & SKB_GSO_FCOE)
 | 
					 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
		BUG();
 | 
							BUG();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
 | 
					 | 
				
			||||||
			vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
 | 
					 | 
				
			||||||
	} else
 | 
					 | 
				
			||||||
		vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (skb->ip_summed == CHECKSUM_PARTIAL) {
 | 
					 | 
				
			||||||
		vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
 | 
					 | 
				
			||||||
		vnet_hdr->csum_start = __cpu_to_virtio16(vio_le(),
 | 
					 | 
				
			||||||
				  skb_checksum_start_offset(skb));
 | 
					 | 
				
			||||||
		vnet_hdr->csum_offset = __cpu_to_virtio16(vio_le(),
 | 
					 | 
				
			||||||
						 skb->csum_offset);
 | 
					 | 
				
			||||||
	} else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
 | 
					 | 
				
			||||||
		vnet_hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
 | 
					 | 
				
			||||||
	} /* else everything is zero */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue