>From f77c3143f3fbefdfa2f0cc873c2665b5aa78e8c9 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Mon, 20 Sep 2010 15:29:31 -0500 Subject: [PATCH] tap: make sure packets are at least 40 bytes long This is required by ethernet drivers but not enforced in the Linux tap code so we need to fix it up ourselves. Signed-off-by: Anthony Liguori diff --git a/net/tap.c b/net/tap.c index 4afb314..822241a 100644 --- a/net/tap.c +++ b/net/tap.c @@ -179,7 +179,13 @@ static int tap_can_send(void *opaque) #ifndef __sun__ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) { - return read(tapfd, buf, maxlen); + ssize_t len; + + len = read(tapfd, buf, maxlen); + if (len > 0) { + len = MAX(MIN(maxlen, 40), len); + } + return len; } #endif -- 1.7.0.4