Skip to content

Commit c53cff5

Browse files
basilgordavem330
authored andcommitted
vhost-net: fix handle_rx buffer size
Take vlan header length into account, when vlan id is stored as vlan_tci. Otherwise tagged packets coming from macvtap will be truncated. Signed-off-by: Basil Gor <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 13a8e0c commit c53cff5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/vhost/net.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/if_arp.h>
2525
#include <linux/if_tun.h>
2626
#include <linux/if_macvlan.h>
27+
#include <linux/if_vlan.h>
2728

2829
#include <net/sock.h>
2930

@@ -283,8 +284,12 @@ static int peek_head_len(struct sock *sk)
283284

284285
spin_lock_irqsave(&sk->sk_receive_queue.lock, flags);
285286
head = skb_peek(&sk->sk_receive_queue);
286-
if (likely(head))
287+
if (likely(head)) {
287288
len = head->len;
289+
if (vlan_tx_tag_present(head))
290+
len += VLAN_HLEN;
291+
}
292+
288293
spin_unlock_irqrestore(&sk->sk_receive_queue.lock, flags);
289294
return len;
290295
}

0 commit comments

Comments
 (0)