From eda11080cbdb44f4127fd6dc08eac0759e36145e Mon Sep 17 00:00:00 2001 From: Asias He Date: Thu, 25 Sep 2014 16:36:02 +0800 Subject: [PATCH] virtio: Check tcp packet using ip_hdr->ip_proto Signed-off-by: Avi Kivity --- net/virtio.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/virtio.cc b/net/virtio.cc index bdd1d63f96..f24d916146 100644 --- a/net/virtio.cc +++ b/net/virtio.cc @@ -13,9 +13,9 @@ #include #include #include -#include +#include #include -#include "tcp.hh" +#include "ip.hh" using namespace net; @@ -437,8 +437,8 @@ virtio_net_device::txq::transmit(semaphore& available) { // Handle TCP checksum offload if (_dev.hw_features().tx_csum_offload) { // FIXME: No magic numbers - auto hdr = p.get_header(14+ 20); - if (hdr) { + auto iph = p.get_header(14); + if (iph && iph->ip_proto == 6) { vhdr.needs_csum = 1; // 14 bytes ethernet header and 20 bytes IP header vhdr.csum_start = 14 + 20;