From nobody Tue Nov 11 17:27:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1565275000; cv=none; d=zoho.com; s=zohoarc; b=FAmM9B9tBdAP69NUgf3PnREH7dr93jUhLMMqR43EbyyqzjUP/5RbwA96CP5ThpMboGosLkrem1AfHA1n1k+aJtgTyTb8wzwwX5DsbrY/QzF+3g/S3qg41ws2KAgLxlvMp0Vpn4301U5Ppr57pkJhJOKKNKtjLxFuJ9U67mNgQlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565275000; 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:ARC-Authentication-Results; bh=20JLC0kEHkoqz0git/hWwhoSGnG86HXCgEhQLLE5Y8M=; b=ABv7ZFqvbnYVALyUZP2yw0zZUuY3g0fFynBVyJ1TLrHT9e5LGrIH6rDEAR7kZr065TkNNCnmUgZIr069f90Rg+N9nz1mtbjtciDx5wVOi86C7KPs1XmG23fDgLNohzBR9HtLCxahSb7O3DidQkkRcgT3uuRfHG2R1VFKcGLldqI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1565275000961812.7841969272275; Thu, 8 Aug 2019 07:36:40 -0700 (PDT) Received: from localhost ([::1]:52306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjWv-00019n-Uu for importer@patchew.org; Thu, 08 Aug 2019 10:36:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56972) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjWG-0000GQ-5L for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:35:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvjWE-0005dx-5k for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:35:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvjWC-0005dK-85 for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:35:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4DBAB3061524; Thu, 8 Aug 2019 14:35:51 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02A791001B07; Thu, 8 Aug 2019 14:35:21 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 16:34:52 +0200 Message-Id: <20190808143457.14111-2-philmd@redhat.com> In-Reply-To: <20190808143457.14111-1-philmd@redhat.com> References: <20190808143457.14111-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 08 Aug 2019 14:35:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 1/6] hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros 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: Dmitry Fleytman , Li Zhijian , "Michael S. Tsirkin" , Jason Wang , Zhang Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" "net/eth.h" provides convenient macros to avoid manipulating the TCP header flags/offset bits manually, let's use them. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dmitry Fleytman --- RFC: Check the macro uses the correct bits hw/net/virtio-net.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b9e1cd71cf..867f50613e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -46,9 +46,6 @@ =20 #define VIRTIO_NET_IP4_ADDR_SIZE 8 /* ipv4 saddr + daddr */ =20 -#define VIRTIO_NET_TCP_FLAG 0x3F -#define VIRTIO_NET_TCP_HDR_LENGTH 0xF000 - /* IPv4 max payload, 16 bits in the header */ #define VIRTIO_NET_MAX_IP4_PAYLOAD (65535 - sizeof(struct ip_header)) #define VIRTIO_NET_MAX_TCP_PAYLOAD 65535 @@ -1658,10 +1655,8 @@ static int virtio_net_rsc_tcp_ctrl_check(VirtioNetRs= cChain *chain, uint16_t tcp_hdr; uint16_t tcp_flag; =20 - tcp_flag =3D htons(tcp->th_offset_flags); - tcp_hdr =3D (tcp_flag & VIRTIO_NET_TCP_HDR_LENGTH) >> 10; - tcp_flag &=3D VIRTIO_NET_TCP_FLAG; - tcp_flag =3D htons(tcp->th_offset_flags) & 0x3F; + tcp_hdr =3D TCP_HEADER_DATA_OFFSET(tcp); + tcp_flag =3D TCP_HEADER_FLAGS(tcp); if (tcp_flag & TH_SYN) { chain->stat.tcp_syn++; return RSC_BYPASS; --=20 2.20.1 From nobody Tue Nov 11 17:27:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1565275062; cv=none; d=zoho.com; s=zohoarc; b=gIM2Xc16uhiqh8fjS7qyJN8+OCZ0VbrwIxepC8lXALhuGQWiuUd40lW0XRvROLL7T6lJk5fWRTEA+jJHpgv0JoV0RFCCByNBLtZ1YzLOQzm/QqjVjXYxxBLDrYMZKyW672XPP4SDGq8JSp0n8ynanhTn01ZzaR1uCBzpCdr10qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565275062; 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:ARC-Authentication-Results; bh=bMDOmELgWS1Mud6SuQx2jxfML4/puZzvaiVsa2mu+VI=; b=d/rHl1Wbe8W1JTGQWWeOR4EoWSNYqz6UpXM5YM43s9H7g5hRO546yMpg+vb+qVYWrVpTUgqhCU4lI/H9yW4oZ3F9GFE/NZxGCTwS5fG2OSIxGM+uiGttDcFmXpvxl3w2u+9wmaWOqbKaMr14GpgHtQbo80U8pUfZbqOOUu402zU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1565275062677346.7222153899288; Thu, 8 Aug 2019 07:37:42 -0700 (PDT) Received: from localhost ([::1]:52332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjXx-00047S-OA for importer@patchew.org; Thu, 08 Aug 2019 10:37:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56983) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjWH-0000IQ-8R for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:35:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvjWG-0005em-8U for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:35:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43164) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvjWG-0005e9-3O for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:35:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93C362D0FCE; Thu, 8 Aug 2019 14:35:54 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D68410016F3; Thu, 8 Aug 2019 14:35:51 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 16:34:53 +0200 Message-Id: <20190808143457.14111-3-philmd@redhat.com> In-Reply-To: <20190808143457.14111-1-philmd@redhat.com> References: <20190808143457.14111-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 08 Aug 2019 14:35:54 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 2/6] net/colo-compare: Use the tcp_header structure 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: Dmitry Fleytman , Li Zhijian , "Michael S. Tsirkin" , Jason Wang , Zhang Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The tcp_header structure comes convenient macros to avoid manipulating the TCP header flags/offset bits manually. Replace the tcp_hdr structure by the tcp_header equivalent, and use the macros. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dmitry Fleytman --- RFC: Verify th_off endianess net/colo-compare.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 7489840bde..14ee4166ba 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -161,28 +161,28 @@ static void colo_compare_inconsistency_notify(Compare= State *s) =20 static gint seq_sorter(Packet *a, Packet *b, gpointer data) { - struct tcp_hdr *atcp, *btcp; + struct tcp_header *atcp, *btcp; =20 - atcp =3D (struct tcp_hdr *)(a->transport_header); - btcp =3D (struct tcp_hdr *)(b->transport_header); + atcp =3D (struct tcp_header *)(a->transport_header); + btcp =3D (struct tcp_header *)(b->transport_header); return ntohl(atcp->th_seq) - ntohl(btcp->th_seq); } =20 static void fill_pkt_tcp_info(void *data, uint32_t *max_ack) { Packet *pkt =3D data; - struct tcp_hdr *tcphd; + struct tcp_header *tcphd; =20 - tcphd =3D (struct tcp_hdr *)pkt->transport_header; + tcphd =3D (struct tcp_header *)pkt->transport_header; =20 pkt->tcp_seq =3D ntohl(tcphd->th_seq); pkt->tcp_ack =3D ntohl(tcphd->th_ack); *max_ack =3D *max_ack > pkt->tcp_ack ? *max_ack : pkt->tcp_ack; pkt->header_size =3D pkt->transport_header - (uint8_t *)pkt->data - + (tcphd->th_off << 2) - pkt->vnet_hdr_len; + + TCP_HEADER_DATA_OFFSET(tcphd) - pkt->vnet_hdr_len; pkt->payload_size =3D pkt->size - pkt->header_size; pkt->seq_end =3D pkt->tcp_seq + pkt->payload_size; - pkt->flags =3D tcphd->th_flags; + pkt->flags =3D TCP_HEADER_FLAGS(tcphd); } =20 /* --=20 2.20.1 From nobody Tue Nov 11 17:27:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1565275034; cv=none; d=zoho.com; s=zohoarc; b=nPkytB1ynmP943E2heneOy/Q/f/TA53lImCSBSQiyOgmr1UaItqZtgyCqcVzqISG9MGLy68O+8sBwk/jgslFQMPSlVjVShcCw2REAf/begYQRpd2kNzc9I8BrRD2cHY+eWrFHAVQ0Nv3acSXoaE6/PVnB/XUKyBa9sh0jaA3HXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565275034; 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:ARC-Authentication-Results; bh=61h2V1wI27VSrgDz62tDLyJ4tvkH0sT3O8fcqGUd/ZM=; b=Y6vfupTEOukCiYBQ4pMGAKJ81tCQLcPjBOuXKjtzyO8nzn6fbNC/942rnUTre2aP2JXYUVWWF25bc1xMX/vmxPPgzAKCdyQMZdIvJUgof7xmRfJkJuuDecuWv10LuCOV5OgwOGro4XyLavk4H/i4R+2jkqTbI+mu6smK8hXIQ7Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 156527503422987.6817552364015; Thu, 8 Aug 2019 07:37:14 -0700 (PDT) Received: from localhost ([::1]:52320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjXV-0002XA-6e for importer@patchew.org; Thu, 08 Aug 2019 10:37:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57011) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjWh-00019p-SP for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:36:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvjWg-0005rg-HE for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:36:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54474) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvjWf-0005qz-VV for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:36:22 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33BFC316E532; Thu, 8 Aug 2019 14:36:20 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 470451001956; Thu, 8 Aug 2019 14:35:55 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 16:34:54 +0200 Message-Id: <20190808143457.14111-4-philmd@redhat.com> In-Reply-To: <20190808143457.14111-1-philmd@redhat.com> References: <20190808143457.14111-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 08 Aug 2019 14:36:20 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/6] net/filter-rewriter: Use the tcp_header structure 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: Dmitry Fleytman , Li Zhijian , "Michael S. Tsirkin" , Jason Wang , Zhang Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The tcp_header structure comes convenient macros to avoid manipulating the TCP header flags/offset bits manually. Replace the tcp_hdr structure by the tcp_header equivalent, and use the TCP_HEADER_FLAGS macro. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dmitry Fleytman --- net/filter-rewriter.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index 31da08a2f4..62e0de1293 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -73,23 +73,26 @@ static int handle_primary_tcp_pkt(RewriterState *rf, Connection *conn, Packet *pkt, ConnectionKey *key) { - struct tcp_hdr *tcp_pkt; + struct tcp_header *tcp_pkt; + uint8_t tcp_flags; + + tcp_pkt =3D (struct tcp_header *)pkt->transport_header; + tcp_flags =3D TCP_HEADER_FLAGS(tcp_pkt); =20 - tcp_pkt =3D (struct tcp_hdr *)pkt->transport_header; if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) { trace_colo_filter_rewriter_pkt_info(__func__, inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst), ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), - tcp_pkt->th_flags); + tcp_flags); trace_colo_filter_rewriter_conn_offset(conn->offset); } =20 - if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) =3D=3D (TH_ACK | TH_SYN))= && + if (((tcp_flags & (TH_ACK | TH_SYN)) =3D=3D (TH_ACK | TH_SYN)) && conn->tcp_state =3D=3D TCPS_SYN_SENT) { conn->tcp_state =3D TCPS_ESTABLISHED; } =20 - if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) =3D=3D TH_SYN)) { + if (((tcp_flags & (TH_ACK | TH_SYN)) =3D=3D TH_SYN)) { /* * we use this flag update offset func * run once in independent tcp connection @@ -97,7 +100,7 @@ static int handle_primary_tcp_pkt(RewriterState *rf, conn->tcp_state =3D TCPS_SYN_RECEIVED; } =20 - if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) =3D=3D TH_ACK)) { + if (((tcp_flags & (TH_ACK | TH_SYN)) =3D=3D TH_ACK)) { if (conn->tcp_state =3D=3D TCPS_SYN_RECEIVED) { /* * offset =3D secondary_seq - primary seq @@ -119,13 +122,13 @@ static int handle_primary_tcp_pkt(RewriterState *rf, * Passive close step 3 */ if ((conn->tcp_state =3D=3D TCPS_LAST_ACK) && - (ntohl(tcp_pkt->th_ack) =3D=3D (conn->fin_ack_seq + 1))) { + (ldl_be_p(&tcp_pkt->th_ack) =3D=3D (conn->fin_ack_seq + 1))) { conn->tcp_state =3D TCPS_CLOSED; g_hash_table_remove(rf->connection_track_table, key); } } =20 - if ((tcp_pkt->th_flags & TH_FIN) =3D=3D TH_FIN) { + if ((tcp_flags & TH_FIN) =3D=3D TH_FIN) { /* * Passive close. * Step 1: @@ -176,20 +179,22 @@ static int handle_secondary_tcp_pkt(RewriterState *rf, Connection *conn, Packet *pkt, ConnectionKey *key) { - struct tcp_hdr *tcp_pkt; + struct tcp_header *tcp_pkt; + uint8_t tcp_flags; =20 - tcp_pkt =3D (struct tcp_hdr *)pkt->transport_header; + tcp_pkt =3D (struct tcp_header *)pkt->transport_header; + tcp_flags =3D TCP_HEADER_FLAGS(tcp_pkt); =20 if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) { trace_colo_filter_rewriter_pkt_info(__func__, inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst), ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), - tcp_pkt->th_flags); + tcp_flags); trace_colo_filter_rewriter_conn_offset(conn->offset); } =20 if (conn->tcp_state =3D=3D TCPS_SYN_RECEIVED && - ((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) =3D=3D (TH_ACK | TH_SYN))= ) { + ((tcp_flags & (TH_ACK | TH_SYN)) =3D=3D (TH_ACK | TH_SYN))) { /* * save offset =3D secondary_seq and then * in handle_primary_tcp_pkt make offset @@ -200,11 +205,11 @@ static int handle_secondary_tcp_pkt(RewriterState *rf, =20 /* VM active connect */ if (conn->tcp_state =3D=3D TCPS_CLOSED && - ((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) =3D=3D TH_SYN)) { + ((tcp_flags & (TH_ACK | TH_SYN)) =3D=3D TH_SYN)) { conn->tcp_state =3D TCPS_SYN_SENT; } =20 - if ((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) =3D=3D TH_ACK) { + if ((tcp_flags & (TH_ACK | TH_SYN)) =3D=3D TH_ACK) { /* Only need to adjust seq while offset is Non-zero */ if (conn->offset) { /* handle packets to the primary from the secondary*/ @@ -219,7 +224,7 @@ static int handle_secondary_tcp_pkt(RewriterState *rf, * Passive close step 2: */ if (conn->tcp_state =3D=3D TCPS_CLOSE_WAIT && - (tcp_pkt->th_flags & (TH_ACK | TH_FIN)) =3D=3D (TH_ACK | TH_FIN)) { + (tcp_flags & (TH_ACK | TH_FIN)) =3D=3D (TH_ACK | TH_FIN)) { conn->fin_ack_seq =3D ntohl(tcp_pkt->th_seq); conn->tcp_state =3D TCPS_LAST_ACK; } @@ -237,7 +242,7 @@ static int handle_secondary_tcp_pkt(RewriterState *rf, * CLOSING status. */ if (conn->tcp_state =3D=3D TCPS_ESTABLISHED && - (tcp_pkt->th_flags & (TH_ACK | TH_FIN)) =3D=3D TH_FIN) { + (tcp_flags & (TH_ACK | TH_FIN)) =3D=3D TH_FIN) { conn->tcp_state =3D TCPS_FIN_WAIT_1; } =20 --=20 2.20.1 From nobody Tue Nov 11 17:27:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1565275056; cv=none; d=zoho.com; s=zohoarc; b=lGgBVj9oNmbG4Yp70R3fkmMrIT40HXMUgKTfvuuOR9EmA3rpLsBrxRfSnPzDlpkNOynDZM80xrYDFc6XVMG3DX0djTMbjvckuGmR+EqtHEvcVpNKz3UARSap1rAwdptDIACFtOQoMblTWiZxyg/Jh/Hn0jjRvGpiszWPeCoAeTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565275056; 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:ARC-Authentication-Results; bh=b5/NnMIYTPicvvll/vCiHM4J3JfKbJNX1mZH866peNA=; b=mrA/3BRxHGrf4sCRw7RRI+3NLWGK93W/TuM52JMUhSxITmMmALjAfyyFrbjX9WDGaGNIMt59k3BvlK2PsuQUiTZkPfewwXzY8SCMxk5spCFRYz8gQ7C6o863wcE8FuhWlHvFo+J46++udVjnpQ4brRklSa/+gf9pP16MXoZ6Uj8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1565275056038177.9381499241075; Thu, 8 Aug 2019 07:37:36 -0700 (PDT) Received: from localhost ([::1]:52330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjXr-0003iQ-1A for importer@patchew.org; Thu, 08 Aug 2019 10:37:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57146) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjX8-0001zB-Fx for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:36:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvjX7-00062t-9Q for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:36:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42208) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvjX5-00061v-Ax for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:36:47 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68E0330A00DC; Thu, 8 Aug 2019 14:36:46 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F31E51001956; Thu, 8 Aug 2019 14:36:20 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 16:34:55 +0200 Message-Id: <20190808143457.14111-5-philmd@redhat.com> In-Reply-To: <20190808143457.14111-1-philmd@redhat.com> References: <20190808143457.14111-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 08 Aug 2019 14:36:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 4/6] hw/net/vmxnet3: Use the tcp_header structure 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: Dmitry Fleytman , Li Zhijian , "Michael S. Tsirkin" , Jason Wang , Zhang Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The tcp_header structure comes convenient macros to avoid manipulating the TCP header flags/offset bits manually. Replace the tcp_hdr structure by the tcp_header equivalent, and use the macros. Since we will remove the duplicated TCP_FLAG_ACK definition in the next commit, replace its use now. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dmitry Fleytman --- RFC: Verify th_off endianess hw/net/net_rx_pkt.c | 2 +- hw/net/net_tx_pkt.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c index 98a5030ace..7558f0646a 100644 --- a/hw/net/net_rx_pkt.c +++ b/hw/net/net_rx_pkt.c @@ -376,7 +376,7 @@ bool net_rx_pkt_is_tcp_ack(struct NetRxPkt *pkt) assert(pkt); =20 if (pkt->istcp) { - return TCP_HEADER_FLAGS(&pkt->l4hdr_info.hdr.tcp) & TCP_FLAG_ACK; + return TCP_HEADER_FLAGS(&pkt->l4hdr_info.hdr.tcp) & TH_ACK; } =20 return false; diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 162f802dd7..fc4514416c 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -307,7 +307,7 @@ func_exit: void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable, bool csum_enable, uint32_t gso_size) { - struct tcp_hdr l4hdr; + struct tcp_header l4hdr; assert(pkt); =20 /* csum has to be enabled if tso is. */ @@ -330,7 +330,8 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, boo= l tso_enable, case VIRTIO_NET_HDR_GSO_TCPV6: iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags, 0, &l4hdr, sizeof(l4hdr)); - pkt->virt_hdr.hdr_len =3D pkt->hdr_len + l4hdr.th_off * sizeof(uin= t32_t); + pkt->virt_hdr.hdr_len =3D pkt->hdr_len + + TCP_HEADER_DATA_OFFSET(&l4hdr) * sizeof(uint= 32_t); pkt->virt_hdr.gso_size =3D gso_size; break; =20 @@ -343,7 +344,7 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, boo= l tso_enable, case IP_PROTO_TCP: pkt->virt_hdr.flags =3D VIRTIO_NET_HDR_F_NEEDS_CSUM; pkt->virt_hdr.csum_start =3D pkt->hdr_len; - pkt->virt_hdr.csum_offset =3D offsetof(struct tcp_hdr, th_sum); + pkt->virt_hdr.csum_offset =3D offsetof(struct tcp_header, th_s= um); break; case IP_PROTO_UDP: pkt->virt_hdr.flags =3D VIRTIO_NET_HDR_F_NEEDS_CSUM; --=20 2.20.1 From nobody Tue Nov 11 17:27:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1565275102; cv=none; d=zoho.com; s=zohoarc; b=nn5gIC0VG4gsMzP1RHMXhnaSIpyJPn5ldhbwtz2mHnEh++7XGHvqzToge0e2uTJuArrhKXN/ZJmxuFIx10vnwVFuiHRFlIIsOU+Ptv9rWlZ2IolEDanpM2+g2c0TtmpXopL8t2+LJ+szQUY7v+3oqOreoeR9Wt/Y6SFjnfXQhPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565275102; 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:ARC-Authentication-Results; bh=jDYOZyF9Tyl0PpwYdYvZgNT8SDhdCtY9DY05eGjrwhc=; b=IT3iqJ0cpxzwpecbSLN1HNzvWYPqldwkfnlEuk/c8H4MtsnSuwPvh2KguqpjaIWQlXOQ+8gNKkkeTFL2Zezx4HPSrvkIjp6QxvaM6JIeO29UFcYCv1j+vunwKe8U5rZGBKgoY4Zc2GdHNcvSe7FuXxsLF0L+FHV4DeSeFBtVdG0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1565275102446621.8307773864129; Thu, 8 Aug 2019 07:38:22 -0700 (PDT) Received: from localhost ([::1]:52352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjYb-0006Ao-EH for importer@patchew.org; Thu, 08 Aug 2019 10:38:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57201) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjXL-0002lK-W0 for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:37:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvjXK-0006FK-Se for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:37:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvjXK-0006EB-Na for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:37:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03A5B6404E; Thu, 8 Aug 2019 14:37:02 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 010661001955; Thu, 8 Aug 2019 14:36:46 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 16:34:56 +0200 Message-Id: <20190808143457.14111-6-philmd@redhat.com> In-Reply-To: <20190808143457.14111-1-philmd@redhat.com> References: <20190808143457.14111-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 08 Aug 2019 14:37:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/6] net/eth: Remove the unused tcp_hdr structure 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: Dmitry Fleytman , Li Zhijian , "Michael S. Tsirkin" , Jason Wang , Zhang Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Commit 75020a70215 introduced 2 very similar structures: tcp_header and tcp_hdr. We replaced the uses of struct tcp_hdr with the equivalent struct tcp_header. Remove the unused one. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dmitry Fleytman --- I prefer the TCP_FLAG_XXX name, but there is only one single use of TCP_FLAG_ACK vs many use of the other set, so I'm keeping the set. include/net/eth.h | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/include/net/eth.h b/include/net/eth.h index 7f45c678e7..0b2584328a 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -72,7 +72,14 @@ typedef struct tcp_header { #define TCP_HEADER_FLAGS(tcp) \ TCP_FLAGS_ONLY(be16_to_cpu((tcp)->th_offset_flags)) =20 -#define TCP_FLAG_ACK 0x10 +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 +#define TH_ECE 0x40 +#define TH_CWR 0x80 =20 #define TCP_HEADER_DATA_OFFSET(tcp) \ (((be16_to_cpu((tcp)->th_offset_flags) >> 12) & 0xf) << 2) @@ -153,37 +160,6 @@ struct udp_hdr { uint16_t uh_sum; /* udp checksum */ }; =20 -struct tcp_hdr { - u_short th_sport; /* source port */ - u_short th_dport; /* destination port */ - uint32_t th_seq; /* sequence number */ - uint32_t th_ack; /* acknowledgment number */ -#ifdef HOST_WORDS_BIGENDIAN - u_char th_off : 4, /* data offset */ - th_x2:4; /* (unused) */ -#else - u_char th_x2 : 4, /* (unused) */ - th_off:4; /* data offset */ -#endif - -#define TH_ELN 0x1 /* explicit loss notification */ -#define TH_ECN 0x2 /* explicit congestion notification */ -#define TH_FS 0x4 /* fast start */ - - u_char th_flags; -#define TH_FIN 0x01 -#define TH_SYN 0x02 -#define TH_RST 0x04 -#define TH_PUSH 0x08 -#define TH_ACK 0x10 -#define TH_URG 0x20 -#define TH_ECE 0x40 -#define TH_CWR 0x80 - u_short th_win; /* window */ - u_short th_sum; /* checksum */ - u_short th_urp; /* urgent pointer */ -}; - #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt #define ip6_ecn_acc ip6_ctlun.ip6_un3.ip6_un3_ecn =20 --=20 2.20.1 From nobody Tue Nov 11 17:27:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1565275135; cv=none; d=zoho.com; s=zohoarc; b=MGu5HSnMUfS5PeCkwGmGmuq3ytA9jBsvHs/+C7RPyAkC1xrV12BinHKl6XFvS/TnxZTIBHrDDDdHq79/WU7wWy1BNsMnXgGhVRuZQx78Jf9jyBmBeRjF0YIW/IRsINLKik/mBWmd0iOJ5omLHcDZYPEB6zsbZS3r2zDCjGJrT+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565275135; 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:ARC-Authentication-Results; bh=Z3gII6moczYAJ+UX2oFBHoF/CU0wJyCImZPXcw2581I=; b=ERR/WEMUER8ztw0eyPqfFlAUQMjP4KObkBsED+4z8hej9axKp85SYIZCOQuDfOcvZ4UEQmZYVJf629E2XU7NbJUqeID4Ta9E5C9i7u4tUgMGE/nftfNixwcW22ITJJLkH11TBwQLNQY48fI5HJ20/YiyHplg8U8WU54X1SKMlDk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1565275135232767.8817330962523; Thu, 8 Aug 2019 07:38:55 -0700 (PDT) Received: from localhost ([::1]:52358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjZ8-00072r-Aj for importer@patchew.org; Thu, 08 Aug 2019 10:38:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57245) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvjXR-00031I-3X for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:37:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvjXQ-0006I5-55 for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:37:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11114) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvjXP-0006Hd-VR for qemu-devel@nongnu.org; Thu, 08 Aug 2019 10:37:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 336713147B12; Thu, 8 Aug 2019 14:37:07 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58B0B10016E9; Thu, 8 Aug 2019 14:37:02 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 16:34:57 +0200 Message-Id: <20190808143457.14111-7-philmd@redhat.com> In-Reply-To: <20190808143457.14111-1-philmd@redhat.com> References: <20190808143457.14111-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 08 Aug 2019 14:37:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 6/6] net/eth: Remove the single use of udp_hdr structure 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: Dmitry Fleytman , Li Zhijian , "Michael S. Tsirkin" , Jason Wang , Zhang Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Commit 75020a70215 introduced 2 very equivalent structures: udp_header and udp_hdr. Replace the single use of udp_hdr by udp_header (which has few more uses in the codebase) and remove the now unused structure. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dmitry Fleytman --- hw/net/net_tx_pkt.c | 2 +- include/net/eth.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index fc4514416c..25148cf01b 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -349,7 +349,7 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, boo= l tso_enable, case IP_PROTO_UDP: pkt->virt_hdr.flags =3D VIRTIO_NET_HDR_F_NEEDS_CSUM; pkt->virt_hdr.csum_start =3D pkt->hdr_len; - pkt->virt_hdr.csum_offset =3D offsetof(struct udp_hdr, uh_sum); + pkt->virt_hdr.csum_offset =3D offsetof(struct udp_header, uh_s= um); break; default: break; diff --git a/include/net/eth.h b/include/net/eth.h index 0b2584328a..740ec225fb 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -153,13 +153,6 @@ struct ip6_option_hdr { uint8_t len; }; =20 -struct udp_hdr { - uint16_t uh_sport; /* source port */ - uint16_t uh_dport; /* destination port */ - uint16_t uh_ulen; /* udp length */ - uint16_t uh_sum; /* udp checksum */ -}; - #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt #define ip6_ecn_acc ip6_ctlun.ip6_un3.ip6_un3_ecn =20 --=20 2.20.1