qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Dmitry Fleytman" <dmitry.fleytman@gmail.com>,
	"Li Zhijian" <lizhijian@cn.fujitsu.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Zhang Chen" <chen.zhang@intel.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [Qemu-devel] [RFC PATCH 1/6] hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros
Date: Thu,  8 Aug 2019 16:34:52 +0200	[thread overview]
Message-ID: <20190808143457.14111-2-philmd@redhat.com> (raw)
In-Reply-To: <20190808143457.14111-1-philmd@redhat.com>

"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é <philmd@redhat.com>
---
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 @@
 
 #define VIRTIO_NET_IP4_ADDR_SIZE   8        /* ipv4 saddr + daddr */
 
-#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(VirtioNetRscChain *chain,
     uint16_t tcp_hdr;
     uint16_t tcp_flag;
 
-    tcp_flag = htons(tcp->th_offset_flags);
-    tcp_hdr = (tcp_flag & VIRTIO_NET_TCP_HDR_LENGTH) >> 10;
-    tcp_flag &= VIRTIO_NET_TCP_FLAG;
-    tcp_flag = htons(tcp->th_offset_flags) & 0x3F;
+    tcp_hdr = TCP_HEADER_DATA_OFFSET(tcp);
+    tcp_flag = TCP_HEADER_FLAGS(tcp);
     if (tcp_flag & TH_SYN) {
         chain->stat.tcp_syn++;
         return RSC_BYPASS;
-- 
2.20.1



  reply	other threads:[~2019-08-08 14:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08 14:34 [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures Philippe Mathieu-Daudé
2019-08-08 14:34 ` Philippe Mathieu-Daudé [this message]
2019-08-08 14:34 ` [Qemu-devel] [RFC PATCH 2/6] net/colo-compare: Use the tcp_header structure Philippe Mathieu-Daudé
2019-08-08 14:34 ` [Qemu-devel] [PATCH 3/6] net/filter-rewriter: " Philippe Mathieu-Daudé
2019-08-08 14:34 ` [Qemu-devel] [RFC PATCH 4/6] hw/net/vmxnet3: " Philippe Mathieu-Daudé
2019-08-08 14:34 ` [Qemu-devel] [PATCH 5/6] net/eth: Remove the unused tcp_hdr structure Philippe Mathieu-Daudé
2019-08-08 14:34 ` [Qemu-devel] [PATCH 6/6] net/eth: Remove the single use of udp_hdr structure Philippe Mathieu-Daudé
2019-08-12  8:21 ` [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures Dmitry Fleytman
2019-08-18 21:38 ` Philippe Mathieu-Daudé
2019-08-19  3:08   ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190808143457.14111-2-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=chen.zhang@intel.com \
    --cc=dmitry.fleytman@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).