mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
net: in virtio_net_hdr only add VLAN_HLEN to csum_start if payload holds vlan
Tun, tap, virtio, packet and uml vector all use struct virtio_net_hdr to communicate packet metadata to userspace. For skbuffs with vlan, the first two return the packet as it may have existed on the wire, inserting the VLAN tag in the user buffer. Then virtio_net_hdr.csum_start needs to be adjusted by VLAN_HLEN bytes. Commitf09e2249c4
("macvtap: restore vlan header on user read") added this feature to macvtap. Commit3ce9b20f19
("macvtap: Fix csum_start when VLAN tags are present") then fixed up csum_start. Virtio, packet and uml do not insert the vlan header in the user buffer. When introducing virtio_net_hdr_from_skb to deduplicate filling in the virtio_net_hdr, the variant from macvtap which adds VLAN_HLEN was applied uniformly, breaking csum offset for packets with vlan on virtio and packet. Make insertion of VLAN_HLEN optional. Convert the callers to pass it when needed. Fixes:e858fae2b0
("virtio_net: use common code for virtio_net_hdr and skb GSO conversion") Fixes:1276f24eee
("packet: use common code for virtio_net_hdr and skb GSO conversion") Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7eced5ab5a
commit
fd3a886258
6 changed files with 16 additions and 13 deletions
|
@ -58,7 +58,8 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
|
|||
static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
|
||||
struct virtio_net_hdr *hdr,
|
||||
bool little_endian,
|
||||
bool has_data_valid)
|
||||
bool has_data_valid,
|
||||
int vlan_hlen)
|
||||
{
|
||||
memset(hdr, 0, sizeof(*hdr)); /* no info leak */
|
||||
|
||||
|
@ -83,12 +84,8 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
|
|||
|
||||
if (skb->ip_summed == CHECKSUM_PARTIAL) {
|
||||
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
|
||||
if (skb_vlan_tag_present(skb))
|
||||
hdr->csum_start = __cpu_to_virtio16(little_endian,
|
||||
skb_checksum_start_offset(skb) + VLAN_HLEN);
|
||||
else
|
||||
hdr->csum_start = __cpu_to_virtio16(little_endian,
|
||||
skb_checksum_start_offset(skb));
|
||||
hdr->csum_start = __cpu_to_virtio16(little_endian,
|
||||
skb_checksum_start_offset(skb) + vlan_hlen);
|
||||
hdr->csum_offset = __cpu_to_virtio16(little_endian,
|
||||
skb->csum_offset);
|
||||
} else if (has_data_valid &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue