From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQA27-0003ye-EM for qemu-devel@nongnu.org; Mon, 01 Feb 2016 03:40:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQA26-0004tN-L3 for qemu-devel@nongnu.org; Mon, 01 Feb 2016 03:40:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQA26-0004tH-Eu for qemu-devel@nongnu.org; Mon, 01 Feb 2016 03:40:26 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 0B4DAA37FC for ; Mon, 1 Feb 2016 08:40:26 +0000 (UTC) Message-ID: <56AF19ED.1000309@redhat.com> Date: Mon, 01 Feb 2016 16:40:13 +0800 From: Wei Xu MIME-Version: 1.0 References: <1454264009-24094-1-git-send-email-wexu@redhat.com> <1454264009-24094-7-git-send-email-wexu@redhat.com> <56AEFBC2.3040700@redhat.com> In-Reply-To: <56AEFBC2.3040700@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC Patch v2 06/10] virtio-net rsc: IPv4 checksum List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang , qemu-devel@nongnu.org Cc: Wei Xu , victork@redhat.com, mst@redhat.com, yvugenfi@redhat.com, marcel@redhat.com, dfleytma@redhat.com On 02/01/2016 02:31 PM, Jason Wang wrote: > > On 02/01/2016 02:13 AM, wexu@redhat.com wrote: >> From: Wei Xu >> >> If a field in the IPv4 header is modified, then the checksum >> have to be recalculated before sending it out. > This in fact breaks bisection. I think you need either squash this into > previous patch or introduce virtio_net_rsc_ipv4_checksum() as a helper > before the patch of ipv4 coalescing. OK. >> Signed-off-by: Wei Xu >> --- >> hw/net/virtio-net.c | 19 +++++++++++++++++++ >> 1 file changed, 19 insertions(+) >> >> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c >> index 93df0d5..88fc4f8 100644 >> --- a/hw/net/virtio-net.c >> +++ b/hw/net/virtio-net.c >> @@ -1630,6 +1630,18 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, >> return 0; >> } >> >> +static void virtio_net_rsc_ipv4_checksum(NetRscSeg *seg) >> +{ >> + uint32_t sum; >> + struct ip_header *ip; >> + >> + ip = (struct ip_header *)(seg->buf + IP_OFFSET); >> + >> + ip->ip_sum = 0; >> + sum = net_checksum_add_cont(sizeof(struct ip_header), (uint8_t *)ip, 0); >> + ip->ip_sum = cpu_to_be16(net_checksum_finish(sum)); >> +} >> + >> static void virtio_net_rsc_purge(void *opq) >> { >> int ret = 0; >> @@ -1643,6 +1655,10 @@ static void virtio_net_rsc_purge(void *opq) >> continue; >> } >> >> + if ((chain->proto == ETH_P_IP) && seg->is_coalesced) { >> + virtio_net_rsc_ipv4_checksum(seg); >> + } >> + >> ret = virtio_net_do_receive(seg->nc, seg->buf, seg->size); >> QTAILQ_REMOVE(&chain->buffers, seg, next); >> g_free(seg->buf); >> @@ -1853,6 +1869,9 @@ static size_t virtio_net_rsc_callback(NetRscChain *chain, NetClientState *nc, >> QTAILQ_FOREACH_SAFE(seg, &chain->buffers, next, nseg) { >> ret = coalesce(chain, seg, buf, size); >> if (RSC_FINAL == ret) { >> + if ((chain->proto == ETH_P_IP) && seg->is_coalesced) { >> + virtio_net_rsc_ipv4_checksum(seg); >> + } >> ret = virtio_net_do_receive(seg->nc, seg->buf, seg->size); >> QTAILQ_REMOVE(&chain->buffers, seg, next); >> g_free(seg->buf); >