From nobody Fri May 17 21:44:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611577494; cv=none; d=zohomail.com; s=zohoarc; b=TQl+QpZixyRVS+Q+KanITcIf26tjN2+oD1d8nsw+RBHJQS11TRcM6sSC5BI2EjKRuo2qn88MXYB8Dhuw9dsczqNlCq/DgPEA2JUBTE3+jN4zabloczZsAKqHPADFEUl47PqbNseyKd4V6xZo0STbx685xZVs8dNFuPn0nYwk9Hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611577494; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=e8mSm93PDo22g/Om/8RnrmZIy773rIqY04U8fKyMke0=; b=dHqTJp5tVfUSIEdxS91JI7LQKjDYBQ/cGavEA5+CfJh0rkD0Hbbwro4YGIHuiPCuOnTeplAUIhcsilS1xaTUtODSwnRaglkNpW1zBoK4463FwqiOzHR7JjGL1iNACOwvLg3+bdJxYjhK9mAhRKgM2T7sMwGbDMPdDOCcaLhjiMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611577494507133.7631904022478; Mon, 25 Jan 2021 04:24:54 -0800 (PST) Received: from localhost ([::1]:42526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l40vN-0004bH-EX for importer@patchew.org; Mon, 25 Jan 2021 07:24:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l40tt-0002uF-L8 for qemu-devel@nongnu.org; Mon, 25 Jan 2021 07:23:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l40tr-0007rL-Og for qemu-devel@nongnu.org; Mon, 25 Jan 2021 07:23:21 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-vIbo_zdiNPi67M63ehX4KA-1; Mon, 25 Jan 2021 07:23:14 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A840100558A; Mon, 25 Jan 2021 12:23:13 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66BFD19C44; Mon, 25 Jan 2021 12:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611577398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=e8mSm93PDo22g/Om/8RnrmZIy773rIqY04U8fKyMke0=; b=Rbs2nVro/rgIitYNGg1Jc134yW/fIt+JQ/sfFMaoK5TV/DB9Y93I1erzb/y6Yxy+3dDJRN QrgPjSXIscpH1WEXRxMWNDSIfbYgtwoUE7ou8JxelamKve3bZnSYZ8crMqf0GInIx6yaZi Y4L+coEh7yZz77sB6vzdwsJ+uAflzqw= X-MC-Unique: vIbo_zdiNPi67M63ehX4KA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [RESEND PULL 1/4] net: Fix handling of id in netdev_add and netdev_del Date: Mon, 25 Jan 2021 20:23:04 +0800 Message-Id: <1611577387-4296-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1611577387-4296-1-git-send-email-jasowang@redhat.com> References: <1611577387-4296-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Markus Armbruster , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster CLI -netdev accumulates in option group "netdev". Before commit 08712fcb85 "net: Track netdevs in NetClientState rather than QemuOpt", netdev_add added to the option group, and netdev_del removed from it, both HMP and QMP. Thus, every netdev had a corresponding QemuOpts in this option group. Commit 08712fcb85 dropped this for QMP netdev_add and both netdev_del. Now a netdev has a corresponding QemuOpts only when it was created with CLI or HMP. Two issues: * QMP and HMP netdev_del can leave QemuOpts behind, breaking HMP netdev_add. Reproducer: $ qemu-system-x86_64 -S -display none -nodefaults -monitor stdio QEMU 5.1.92 monitor - type 'help' for more information (qemu) netdev_add user,id=3Dnet0 (qemu) info network net0: index=3D0,type=3Duser,net=3D10.0.2.0,restrict=3Doff (qemu) netdev_del net0 (qemu) info network (qemu) netdev_add user,id=3Dnet0 upstream-qemu: Duplicate ID 'net0' for netdev Try "help netdev_add" for more information Fix by restoring the QemuOpts deletion in qmp_netdev_del(), but with a guard, because the QemuOpts need not exist. * QMP netdev_add loses its "no duplicate ID" check. Reproducer: $ qemu-system-x86_64 -S -display none -qmp stdio {"QMP": {"version": {"qemu": {"micro": 92, "minor": 1, "major": 5}, "pa= ckage": "v5.2.0-rc2-1-g02c1f0142c"}, "capabilities": ["oob"]}} {"execute": "qmp_capabilities"} {"return": {}} {"execute": "netdev_add", "arguments": {"type": "user", "id":"net0"}} {"return": {}} {"execute": "netdev_add", "arguments": {"type": "user", "id":"net0"}} {"return": {}} Fix by adding a duplicate ID check to net_client_init1() to replace the lost one. The check is redundant for callers where QemuOpts still checks, i.e. for CLI and HMP. Reported-by: Andrew Melnichenko Fixes: 08712fcb851034228b61f75bd922863a984a4f60 Cc: qemu-stable@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Jason Wang --- net/net.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/net.c b/net/net.c index e1035f2..c1cd9c7 100644 --- a/net/net.c +++ b/net/net.c @@ -983,6 +983,7 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIV= ER__MAX])( static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **= errp) { NetClientState *peer =3D NULL; + NetClientState *nc; =20 if (is_netdev) { if (netdev->type =3D=3D NET_CLIENT_DRIVER_NIC || @@ -1010,6 +1011,12 @@ static int net_client_init1(const Netdev *netdev, bo= ol is_netdev, Error **errp) } } =20 + nc =3D qemu_find_netdev(netdev->id); + if (nc) { + error_setg(errp, "Duplicate ID '%s'", netdev->id); + return -1; + } + if (net_client_init_fun[netdev->type](netdev, netdev->id, peer, errp) = < 0) { /* FIXME drop when all init functions store an Error */ if (errp && !*errp) { @@ -1020,8 +1027,6 @@ static int net_client_init1(const Netdev *netdev, boo= l is_netdev, Error **errp) } =20 if (is_netdev) { - NetClientState *nc; - nc =3D qemu_find_netdev(netdev->id); assert(nc); nc->is_netdev =3D true; @@ -1135,6 +1140,7 @@ void qmp_netdev_add(Netdev *netdev, Error **errp) void qmp_netdev_del(const char *id, Error **errp) { NetClientState *nc; + QemuOpts *opts; =20 nc =3D qemu_find_netdev(id); if (!nc) { @@ -1149,6 +1155,16 @@ void qmp_netdev_del(const char *id, Error **errp) } =20 qemu_del_net_client(nc); + + /* + * Wart: we need to delete the QemuOpts associated with netdevs + * created via CLI or HMP, to avoid bogus "Duplicate ID" errors in + * HMP netdev_add. + */ + opts =3D qemu_opts_find(qemu_find_opts("netdev"), id); + if (opts) { + qemu_opts_del(opts); + } } =20 static void netfilter_print_info(Monitor *mon, NetFilterState *nf) --=20 2.7.4 From nobody Fri May 17 21:44:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611577687; cv=none; d=zohomail.com; s=zohoarc; b=TjoUj2D01unDamtqvz0pfIHgNNbZYxKhwMhwhak/jfnwNtWvWKCc6T2YZdn6Jad5HxJ4Iy1CXKPg5VihJ8Lm1B9FYXFJmQcQT3yvD09/gdzNaRk/OWfk8CnhqK/pqRWwPlc97f65951wMsORGSegtKUoFYaZ0r7mbpL1zB9WhQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611577687; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=u2G89Z36/wSDze7ulXLsFFw66Wxg90K6z0OfUh+k1qY=; b=UJDUTyo1qnTPWm1Ape3jXQGeK8jbVfNblS8LDVoDZBTvN5q/Hi7N8t82PfQ0ML7rDZbwc+Cdpz0w7BDYfX3XY6ugKGhPDROP0ZAAcLBiTe6cXAhPRy+fU2Z2BoFRZDH+GqHYl4XNCVGGV9y3+MzgRf5MujTdA+UnnOPRdujAcpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611577687636298.8357632080141; Mon, 25 Jan 2021 04:28:07 -0800 (PST) Received: from localhost ([::1]:49390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l40yU-0007Z3-J8 for importer@patchew.org; Mon, 25 Jan 2021 07:28:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l40u0-00031J-Mq for qemu-devel@nongnu.org; Mon, 25 Jan 2021 07:23:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37684) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l40tt-0007tR-Ts for qemu-devel@nongnu.org; Mon, 25 Jan 2021 07:23:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-Hf2P1JsPPLGNPWl_f-kxCg-1; Mon, 25 Jan 2021 07:23:17 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C17B5100558A; Mon, 25 Jan 2021 12:23:15 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2C6419C44; Mon, 25 Jan 2021 12:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611577401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=u2G89Z36/wSDze7ulXLsFFw66Wxg90K6z0OfUh+k1qY=; b=SopUM0Tyz+1ehRqy0na6vvllVnAnwF4DcQdLJ2CT6bxYuVrqg+pjwVje3MIz+8qPA+JcaW QQAouyNN0aPsap8oh7r4droiFsOsZsbgUcJjrNYUGprCJHN7qHCDkPqr8rjTKBuNu4cqAy 5mb4d+0WlfPkXG3RKY1IXTb9/E9fKLI= X-MC-Unique: Hf2P1JsPPLGNPWl_f-kxCg-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [RESEND PULL 2/4] net: checksum: Skip fragmented IP packets Date: Mon, 25 Jan 2021 20:23:05 +0800 Message-Id: <1611577387-4296-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1611577387-4296-1-git-send-email-jasowang@redhat.com> References: <1611577387-4296-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Bin Meng , Markus Carlstedt Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Carlstedt To calculate the TCP/UDP checksum we need the whole datagram. Unless the hardware has some logic to collect all fragments before sending the whole datagram first, it can only be done by the network stack, which is normally the case for the NICs we have seen so far. Skip these fragmented IP packets to avoid checksum corruption. Signed-off-by: Markus Carlstedt Signed-off-by: Bin Meng Signed-off-by: Jason Wang --- net/checksum.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/checksum.c b/net/checksum.c index aaa4000..5cb8b2c 100644 --- a/net/checksum.c +++ b/net/checksum.c @@ -106,6 +106,10 @@ void net_checksum_calculate(uint8_t *data, int length) return; /* not IPv4 */ } =20 + if (IP4_IS_FRAGMENT(ip)) { + return; /* a fragmented IP packet */ + } + ip_len =3D lduw_be_p(&ip->ip_len); =20 /* Last, check that we have enough data for the all IP frame */ --=20 2.7.4 From nobody Fri May 17 21:44:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611577601; cv=none; d=zohomail.com; s=zohoarc; b=NsRD1i8Tu6o0F1hF9rPpyieEp7yr7XsmYbHGJQZmaEq3lbqduaLV9MN4YnDyTKHBlebUmBBhya+JZ/u6UD1FEOGeLSgZFYU+R2BJWc1HNGVqkcxN6TycFI5wMiVqx/XztUneT9lfyz3MtuNseA6dhGbXrh7haRg4GmU2+e/qp1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611577601; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7hHfDZ2RcIUnVWRCkZBOrLDzrIEoqdZ+sv/eDpbf5T8=; b=ATGi8gg+mPSMhjzOcXFIHKOlSzEsx5J1kBivm3mCGwf/KaS216PaCtpJGFem8qWTkWi1w2nt3Tz0Uh1VHV5mVR1akIYsRt+xO7s97dhMN2OOj3Pt7dUjATVXrPVC39OMpiaAQJsQbEIP5RwsqFe3MErvj0jqTXqq02nY3BtQlNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611577601746658.5911258385701; Mon, 25 Jan 2021 04:26:41 -0800 (PST) Received: from localhost ([::1]:45826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l40x6-00064o-LP for importer@patchew.org; Mon, 25 Jan 2021 07:26:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l40u0-00031b-PY for qemu-devel@nongnu.org; Mon, 25 Jan 2021 07:23:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30952) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l40tz-0007uG-1r for qemu-devel@nongnu.org; Mon, 25 Jan 2021 07:23:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-133-YmbrQFTJNre46Leexs8Vmg-1; Mon, 25 Jan 2021 07:23:20 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 776098145E0; Mon, 25 Jan 2021 12:23:19 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45B4319C44; Mon, 25 Jan 2021 12:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611577402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7hHfDZ2RcIUnVWRCkZBOrLDzrIEoqdZ+sv/eDpbf5T8=; b=TT25y21NYafhT0VWoxAtCvHEX9gAUh0QExgxzTRVeE1wcwxbaxu1I04QrjerNoufzhXW9s TiKFVZQl/mP4DUmLClsPdlKoAJHW0NQaK1gm5YutEGjsnv9lMzlLcrXnndo8n8ol3x9QOx 45VMI7IPxaPPekKGOUomDiV97maM4Uc= X-MC-Unique: YmbrQFTJNre46Leexs8Vmg-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [RESEND PULL 3/4] net: checksum: Add IP header checksum calculation Date: Mon, 25 Jan 2021 20:23:06 +0800 Message-Id: <1611577387-4296-4-git-send-email-jasowang@redhat.com> In-Reply-To: <1611577387-4296-1-git-send-email-jasowang@redhat.com> References: <1611577387-4296-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng , Yabing Liu , Jason Wang , Guishan Qin Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Guishan Qin At present net_checksum_calculate() only calculates TCP/UDP checksum in an IP packet, but assumes the IP header checksum to be provided by the software, e.g.: Linux kernel always calculates the IP header checksum. However this might not always be the case, e.g.: for an IP checksum offload enabled stack like VxWorks, the IP header checksum can be zero. This adds the checksum calculation of the IP header. Signed-off-by: Guishan Qin Signed-off-by: Yabing Liu Signed-off-by: Bin Meng Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Jason Wang --- net/checksum.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/checksum.c b/net/checksum.c index 5cb8b2c..dabd290 100644 --- a/net/checksum.c +++ b/net/checksum.c @@ -61,6 +61,7 @@ void net_checksum_calculate(uint8_t *data, int length) { int mac_hdr_len, ip_len; struct ip_header *ip; + uint16_t csum; =20 /* * Note: We cannot assume "data" is aligned, so the all code uses @@ -106,6 +107,11 @@ void net_checksum_calculate(uint8_t *data, int length) return; /* not IPv4 */ } =20 + /* Calculate IP checksum */ + stw_he_p(&ip->ip_sum, 0); + csum =3D net_raw_checksum((uint8_t *)ip, IP_HDR_GET_LEN(ip)); + stw_be_p(&ip->ip_sum, csum); + if (IP4_IS_FRAGMENT(ip)) { return; /* a fragmented IP packet */ } @@ -122,7 +128,6 @@ void net_checksum_calculate(uint8_t *data, int length) switch (ip->ip_p) { case IP_PROTO_TCP: { - uint16_t csum; tcp_header *tcp =3D (tcp_header *)(ip + 1); =20 if (ip_len < sizeof(tcp_header)) { @@ -143,7 +148,6 @@ void net_checksum_calculate(uint8_t *data, int length) } case IP_PROTO_UDP: { - uint16_t csum; udp_header *udp =3D (udp_header *)(ip + 1); =20 if (ip_len < sizeof(udp_header)) { --=20 2.7.4 From nobody Fri May 17 21:44:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611577738; cv=none; d=zohomail.com; s=zohoarc; b=R60B7D/Ansmugl9aXWkHyxomrwVJ/3Zyt6HqS6+Bu2QlJPMuFo39iBPW82jVm1CHhweO6AbkCJyetAUD2gZrpsDFZo1pCHjafc2+Jr2hD0F3UlqxSIqoBtVChpkbWjuDgl00ZKLrVwOTZezRaP69hd+s5f0GTA4lNAbY1UDHYp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611577738; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=gT50dWcb6n+Vmf0qd3yXV4AfOgHc9f6xuSFTrODJjUc=; b=Lo2yRQhEWp5KIvOnISJJ+1TxIPnaL0glnlwxkjK2uqLJj1WzrHoavrydp0QmMJphXaC7yoau0WfAQ1rolBiLiPt5onEX/CaLDRVQ3zDOEXdqxP6zwzmbHMeYDENjd1pM9+x9BiMQaXcaL4f0ov0f6zMyO1bzmJZ5usxtL8AEyrE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611577738112633.306825225759; Mon, 25 Jan 2021 04:28:58 -0800 (PST) Received: from localhost ([::1]:52054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l40zI-0000Fj-0V for importer@patchew.org; Mon, 25 Jan 2021 07:28:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l40u1-000343-T1 for qemu-devel@nongnu.org; Mon, 25 Jan 2021 07:23:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l40tz-0007uX-20 for qemu-devel@nongnu.org; Mon, 25 Jan 2021 07:23:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-316-ii243_9wPXiFGG9ijhclgA-1; Mon, 25 Jan 2021 07:23:22 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5817110054FF; Mon, 25 Jan 2021 12:23:21 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id C770719C44; Mon, 25 Jan 2021 12:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611577404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=gT50dWcb6n+Vmf0qd3yXV4AfOgHc9f6xuSFTrODJjUc=; b=S5ZXduEuBnFniViDjbMVl4DF3KSxwvJF1zRFXcpghle1BfpvXP++iHk5MafS4+3kzejs4w lnX7hzDf6vpF2Dkm/1CbZilOkIvQ2NUX+xbVzru98PZXhkpv8nZtx5ZLjBoUt75400cUo9 lYm942Efi97aHgZVQhPT18B7FDxYE+A= X-MC-Unique: ii243_9wPXiFGG9ijhclgA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [RESEND PULL 4/4] net: checksum: Introduce fine control over checksum type Date: Mon, 25 Jan 2021 20:23:07 +0800 Message-Id: <1611577387-4296-5-git-send-email-jasowang@redhat.com> In-Reply-To: <1611577387-4296-1-git-send-email-jasowang@redhat.com> References: <1611577387-4296-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bin Meng At present net_checksum_calculate() blindly calculates all types of checksums (IP, TCP, UDP). Some NICs may have a per type setting in their BDs to control what checksum should be offloaded. To support such hardware behavior, introduce a 'csum_flag' parameter to the net_checksum_calculate() API to allow fine control over what type checksum is calculated. Existing users of this API are updated accordingly. Signed-off-by: Bin Meng Signed-off-by: Jason Wang --- hw/net/allwinner-sun8i-emac.c | 2 +- hw/net/cadence_gem.c | 2 +- hw/net/fsl_etsec/rings.c | 18 +++++++++--------- hw/net/ftgmac100.c | 13 ++++++++++++- hw/net/imx_fec.c | 20 ++++++++------------ hw/net/virtio-net.c | 2 +- hw/net/xen_nic.c | 2 +- include/net/checksum.h | 7 ++++++- net/checksum.c | 18 ++++++++++++++---- net/filter-rewriter.c | 4 ++-- 10 files changed, 55 insertions(+), 33 deletions(-) diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c index 38d3285..0427689 100644 --- a/hw/net/allwinner-sun8i-emac.c +++ b/hw/net/allwinner-sun8i-emac.c @@ -514,7 +514,7 @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacSt= ate *s) /* After the last descriptor, send the packet */ if (desc.status2 & TX_DESC_STATUS2_LAST_DESC) { if (desc.status2 & TX_DESC_STATUS2_CHECKSUM_MASK) { - net_checksum_calculate(packet_buf, packet_bytes); + net_checksum_calculate(packet_buf, packet_bytes, CSUM_ALL); } =20 qemu_send_packet(nc, packet_buf, packet_bytes); diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index 7a53469..9a4474a 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -1266,7 +1266,7 @@ static void gem_transmit(CadenceGEMState *s) =20 /* Is checksum offload enabled? */ if (s->regs[GEM_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) { - net_checksum_calculate(s->tx_packet, total_bytes); + net_checksum_calculate(s->tx_packet, total_bytes, CSUM= _ALL); } =20 /* Update MAC statistics */ diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c index 628648a..121415a 100644 --- a/hw/net/fsl_etsec/rings.c +++ b/hw/net/fsl_etsec/rings.c @@ -183,13 +183,11 @@ static void process_tx_fcb(eTSEC *etsec) uint8_t *l3_header =3D etsec->tx_buffer + 8 + l3_header_offset; /* L4 header */ uint8_t *l4_header =3D l3_header + l4_header_offset; + int csum =3D 0; =20 /* if packet is IP4 and IP checksum is requested */ if (flags & FCB_TX_IP && flags & FCB_TX_CIP) { - /* do IP4 checksum (TODO This function does TCP/UDP checksum - * but not sure if it also does IP4 checksum.) */ - net_checksum_calculate(etsec->tx_buffer + 8, - etsec->tx_buffer_len - 8); + csum |=3D CSUM_IP; } /* TODO Check the correct usage of the PHCS field of the FCB in case t= he NPH * flag is on */ @@ -201,9 +199,7 @@ static void process_tx_fcb(eTSEC *etsec) /* if checksum is requested */ if (flags & FCB_TX_CTU) { /* do UDP checksum */ - - net_checksum_calculate(etsec->tx_buffer + 8, - etsec->tx_buffer_len - 8); + csum |=3D CSUM_UDP; } else { /* set checksum field to 0 */ l4_header[6] =3D 0; @@ -211,10 +207,14 @@ static void process_tx_fcb(eTSEC *etsec) } } else if (flags & FCB_TX_CTU) { /* if TCP and checksum is request= ed */ /* do TCP checksum */ - net_checksum_calculate(etsec->tx_buffer + 8, - etsec->tx_buffer_len - 8); + csum |=3D CSUM_TCP; } } + + if (csum) { + net_checksum_calculate(etsec->tx_buffer + 8, + etsec->tx_buffer_len - 8, csum); + } } =20 static void process_tx_bd(eTSEC *etsec, diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c index 782ff19..25685ba 100644 --- a/hw/net/ftgmac100.c +++ b/hw/net/ftgmac100.c @@ -564,6 +564,7 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t= tx_ring, ptr +=3D len; frame_size +=3D len; if (bd.des0 & FTGMAC100_TXDES0_LTS) { + int csum =3D 0; =20 /* Check for VLAN */ if (flags & FTGMAC100_TXDES1_INS_VLANTAG && @@ -573,8 +574,18 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_= t tx_ring, } =20 if (flags & FTGMAC100_TXDES1_IP_CHKSUM) { - net_checksum_calculate(s->frame, frame_size); + csum |=3D CSUM_IP; } + if (flags & FTGMAC100_TXDES1_TCP_CHKSUM) { + csum |=3D CSUM_TCP; + } + if (flags & FTGMAC100_TXDES1_UDP_CHKSUM) { + csum |=3D CSUM_UDP; + } + if (csum) { + net_checksum_calculate(s->frame, frame_size, csum); + } + /* Last buffer in frame. */ qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size); ptr =3D s->frame; diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 2c14804..f03450c 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -561,22 +561,18 @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t i= ndex) ptr +=3D len; frame_size +=3D len; if (bd.flags & ENET_BD_L) { + int csum =3D 0; + if (bd.option & ENET_BD_PINS) { - struct ip_header *ip_hd =3D PKT_GET_IP_HDR(s->frame); - if (IP_HEADER_VERSION(ip_hd) =3D=3D 4) { - net_checksum_calculate(s->frame, frame_size); - } + csum |=3D (CSUM_TCP | CSUM_UDP); } if (bd.option & ENET_BD_IINS) { - struct ip_header *ip_hd =3D PKT_GET_IP_HDR(s->frame); - /* We compute checksum only for IPv4 frames */ - if (IP_HEADER_VERSION(ip_hd) =3D=3D 4) { - uint16_t csum; - ip_hd->ip_sum =3D 0; - csum =3D net_raw_checksum((uint8_t *)ip_hd, sizeof(*ip= _hd)); - ip_hd->ip_sum =3D cpu_to_be16(csum); - } + csum |=3D CSUM_IP; + } + if (csum) { + net_checksum_calculate(s->frame, frame_size, csum); } + /* Last buffer in frame. */ =20 qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 09ceb02..5150f29 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1464,7 +1464,7 @@ static void work_around_broken_dhclient(struct virtio= _net_hdr *hdr, (buf[12] =3D=3D 0x08 && buf[13] =3D=3D 0x00) && /* ethertype =3D= =3D IPv4 */ (buf[23] =3D=3D 17) && /* ip.protocol =3D=3D UDP */ (buf[34] =3D=3D 0 && buf[35] =3D=3D 67)) { /* udp.srcport =3D=3D b= ootps */ - net_checksum_calculate(buf, size); + net_checksum_calculate(buf, size, CSUM_UDP); hdr->flags &=3D ~VIRTIO_NET_HDR_F_NEEDS_CSUM; } } diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 00a7fdf..5c815b4 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -174,7 +174,7 @@ static void net_tx_packets(struct XenNetDev *netdev) tmpbuf =3D g_malloc(XC_PAGE_SIZE); } memcpy(tmpbuf, page + txreq.offset, txreq.size); - net_checksum_calculate(tmpbuf, txreq.size); + net_checksum_calculate(tmpbuf, txreq.size, CSUM_ALL); qemu_send_packet(qemu_get_queue(netdev->nic), tmpbuf, txreq.size); } else { diff --git a/include/net/checksum.h b/include/net/checksum.h index 05a0d27..7dec37e 100644 --- a/include/net/checksum.h +++ b/include/net/checksum.h @@ -21,11 +21,16 @@ #include "qemu/bswap.h" struct iovec; =20 +#define CSUM_IP 0x01 +#define CSUM_TCP 0x02 +#define CSUM_UDP 0x04 +#define CSUM_ALL (CSUM_IP | CSUM_TCP | CSUM_UDP) + uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq); uint16_t net_checksum_finish(uint32_t sum); uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, uint8_t *addrs, uint8_t *buf); -void net_checksum_calculate(uint8_t *data, int length); +void net_checksum_calculate(uint8_t *data, int length, int csum_flag); =20 static inline uint32_t net_checksum_add(int len, uint8_t *buf) diff --git a/net/checksum.c b/net/checksum.c index dabd290..70f4eae 100644 --- a/net/checksum.c +++ b/net/checksum.c @@ -57,7 +57,7 @@ uint16_t net_checksum_tcpudp(uint16_t length, uint16_t pr= oto, return net_checksum_finish(sum); } =20 -void net_checksum_calculate(uint8_t *data, int length) +void net_checksum_calculate(uint8_t *data, int length, int csum_flag) { int mac_hdr_len, ip_len; struct ip_header *ip; @@ -108,9 +108,11 @@ void net_checksum_calculate(uint8_t *data, int length) } =20 /* Calculate IP checksum */ - stw_he_p(&ip->ip_sum, 0); - csum =3D net_raw_checksum((uint8_t *)ip, IP_HDR_GET_LEN(ip)); - stw_be_p(&ip->ip_sum, csum); + if (csum_flag & CSUM_IP) { + stw_he_p(&ip->ip_sum, 0); + csum =3D net_raw_checksum((uint8_t *)ip, IP_HDR_GET_LEN(ip)); + stw_be_p(&ip->ip_sum, csum); + } =20 if (IP4_IS_FRAGMENT(ip)) { return; /* a fragmented IP packet */ @@ -128,6 +130,10 @@ void net_checksum_calculate(uint8_t *data, int length) switch (ip->ip_p) { case IP_PROTO_TCP: { + if (!(csum_flag & CSUM_TCP)) { + return; + } + tcp_header *tcp =3D (tcp_header *)(ip + 1); =20 if (ip_len < sizeof(tcp_header)) { @@ -148,6 +154,10 @@ void net_checksum_calculate(uint8_t *data, int length) } case IP_PROTO_UDP: { + if (!(csum_flag & CSUM_UDP)) { + return; + } + udp_header *udp =3D (udp_header *)(ip + 1); =20 if (ip_len < sizeof(udp_header)) { diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index fc0e64c..10fe393 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -114,7 +114,7 @@ static int handle_primary_tcp_pkt(RewriterState *rf, tcp_pkt->th_ack =3D htonl(ntohl(tcp_pkt->th_ack) + conn->offse= t); =20 net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_le= n, - pkt->size - pkt->vnet_hdr_len); + pkt->size - pkt->vnet_hdr_len, CSUM_TCP= ); } =20 /* @@ -216,7 +216,7 @@ static int handle_secondary_tcp_pkt(RewriterState *rf, tcp_pkt->th_seq =3D htonl(ntohl(tcp_pkt->th_seq) - conn->offse= t); =20 net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_le= n, - pkt->size - pkt->vnet_hdr_len); + pkt->size - pkt->vnet_hdr_len, CSUM_TCP= ); } } =20 --=20 2.7.4