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 2/6] net/colo-compare: Use the tcp_header structure
Date: Thu, 8 Aug 2019 16:34:53 +0200 [thread overview]
Message-ID: <20190808143457.14111-3-philmd@redhat.com> (raw)
In-Reply-To: <20190808143457.14111-1-philmd@redhat.com>
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é <philmd@redhat.com>
---
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(CompareState *s)
static gint seq_sorter(Packet *a, Packet *b, gpointer data)
{
- struct tcp_hdr *atcp, *btcp;
+ struct tcp_header *atcp, *btcp;
- atcp = (struct tcp_hdr *)(a->transport_header);
- btcp = (struct tcp_hdr *)(b->transport_header);
+ atcp = (struct tcp_header *)(a->transport_header);
+ btcp = (struct tcp_header *)(b->transport_header);
return ntohl(atcp->th_seq) - ntohl(btcp->th_seq);
}
static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
{
Packet *pkt = data;
- struct tcp_hdr *tcphd;
+ struct tcp_header *tcphd;
- tcphd = (struct tcp_hdr *)pkt->transport_header;
+ tcphd = (struct tcp_header *)pkt->transport_header;
pkt->tcp_seq = ntohl(tcphd->th_seq);
pkt->tcp_ack = ntohl(tcphd->th_ack);
*max_ack = *max_ack > pkt->tcp_ack ? *max_ack : pkt->tcp_ack;
pkt->header_size = 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 = pkt->size - pkt->header_size;
pkt->seq_end = pkt->tcp_seq + pkt->payload_size;
- pkt->flags = tcphd->th_flags;
+ pkt->flags = TCP_HEADER_FLAGS(tcphd);
}
/*
--
2.20.1
next prev parent reply other threads:[~2019-08-08 14:37 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 ` [Qemu-devel] [RFC PATCH 1/6] hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros Philippe Mathieu-Daudé
2019-08-08 14:34 ` Philippe Mathieu-Daudé [this message]
2019-08-08 14:34 ` [Qemu-devel] [PATCH 3/6] net/filter-rewriter: Use the tcp_header structure 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-3-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).