* [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures
@ 2019-08-08 14:34 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é
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-08 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin, Jason Wang,
Zhang Chen, Philippe Mathieu-Daudé
This is a preparatory cleanup series.
Commit 75020a70215 introduced 4 very equivalent structures:
- tcp_header and tcp_hdr,
- udp_header and udp_hdr.
Choose the most widely use in the codebase, which happens to
provide convenient bitfields manipulation macros and is not
endian-specific.
Philippe Mathieu-Daudé (6):
hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros
net/colo-compare: Use the tcp_header structure
net/filter-rewriter: Use the tcp_header structure
hw/net/vmxnet3: Use the tcp_header structure
net/eth: Remove the unused tcp_hdr structure
net/eth: Remove the single use of udp_hdr structure
hw/net/net_rx_pkt.c | 2 +-
hw/net/net_tx_pkt.c | 9 +++++----
hw/net/virtio-net.c | 9 ++-------
include/net/eth.h | 47 ++++++++-----------------------------------
net/colo-compare.c | 14 ++++++-------
net/filter-rewriter.c | 37 +++++++++++++++++++---------------
6 files changed, 44 insertions(+), 74 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [RFC PATCH 1/6] hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros
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é
2019-08-08 14:34 ` [Qemu-devel] [RFC PATCH 2/6] net/colo-compare: Use the tcp_header structure Philippe Mathieu-Daudé
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-08 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin, Jason Wang,
Zhang Chen, Philippe Mathieu-Daudé
"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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [RFC PATCH 2/6] net/colo-compare: Use the tcp_header structure
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é
2019-08-08 14:34 ` [Qemu-devel] [PATCH 3/6] net/filter-rewriter: " Philippe Mathieu-Daudé
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-08 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin, Jason Wang,
Zhang Chen, Philippe Mathieu-Daudé
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 3/6] net/filter-rewriter: Use the tcp_header structure
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 ` [Qemu-devel] [RFC PATCH 2/6] net/colo-compare: Use the tcp_header structure Philippe Mathieu-Daudé
@ 2019-08-08 14:34 ` Philippe Mathieu-Daudé
2019-08-08 14:34 ` [Qemu-devel] [RFC PATCH 4/6] hw/net/vmxnet3: " Philippe Mathieu-Daudé
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-08 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin, Jason Wang,
Zhang Chen, Philippe Mathieu-Daudé
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é <philmd@redhat.com>
---
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 = (struct tcp_header *)pkt->transport_header;
+ tcp_flags = TCP_HEADER_FLAGS(tcp_pkt);
- tcp_pkt = (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);
}
- if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == (TH_ACK | TH_SYN)) &&
+ if (((tcp_flags & (TH_ACK | TH_SYN)) == (TH_ACK | TH_SYN)) &&
conn->tcp_state == TCPS_SYN_SENT) {
conn->tcp_state = TCPS_ESTABLISHED;
}
- if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) {
+ if (((tcp_flags & (TH_ACK | TH_SYN)) == 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 = TCPS_SYN_RECEIVED;
}
- if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_ACK)) {
+ if (((tcp_flags & (TH_ACK | TH_SYN)) == TH_ACK)) {
if (conn->tcp_state == TCPS_SYN_RECEIVED) {
/*
* offset = secondary_seq - primary seq
@@ -119,13 +122,13 @@ static int handle_primary_tcp_pkt(RewriterState *rf,
* Passive close step 3
*/
if ((conn->tcp_state == TCPS_LAST_ACK) &&
- (ntohl(tcp_pkt->th_ack) == (conn->fin_ack_seq + 1))) {
+ (ldl_be_p(&tcp_pkt->th_ack) == (conn->fin_ack_seq + 1))) {
conn->tcp_state = TCPS_CLOSED;
g_hash_table_remove(rf->connection_track_table, key);
}
}
- if ((tcp_pkt->th_flags & TH_FIN) == TH_FIN) {
+ if ((tcp_flags & TH_FIN) == 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;
- tcp_pkt = (struct tcp_hdr *)pkt->transport_header;
+ tcp_pkt = (struct tcp_header *)pkt->transport_header;
+ tcp_flags = TCP_HEADER_FLAGS(tcp_pkt);
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);
}
if (conn->tcp_state == TCPS_SYN_RECEIVED &&
- ((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == (TH_ACK | TH_SYN))) {
+ ((tcp_flags & (TH_ACK | TH_SYN)) == (TH_ACK | TH_SYN))) {
/*
* save offset = secondary_seq and then
* in handle_primary_tcp_pkt make offset
@@ -200,11 +205,11 @@ static int handle_secondary_tcp_pkt(RewriterState *rf,
/* VM active connect */
if (conn->tcp_state == TCPS_CLOSED &&
- ((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) {
+ ((tcp_flags & (TH_ACK | TH_SYN)) == TH_SYN)) {
conn->tcp_state = TCPS_SYN_SENT;
}
- if ((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_ACK) {
+ if ((tcp_flags & (TH_ACK | TH_SYN)) == 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 == TCPS_CLOSE_WAIT &&
- (tcp_pkt->th_flags & (TH_ACK | TH_FIN)) == (TH_ACK | TH_FIN)) {
+ (tcp_flags & (TH_ACK | TH_FIN)) == (TH_ACK | TH_FIN)) {
conn->fin_ack_seq = ntohl(tcp_pkt->th_seq);
conn->tcp_state = TCPS_LAST_ACK;
}
@@ -237,7 +242,7 @@ static int handle_secondary_tcp_pkt(RewriterState *rf,
* CLOSING status.
*/
if (conn->tcp_state == TCPS_ESTABLISHED &&
- (tcp_pkt->th_flags & (TH_ACK | TH_FIN)) == TH_FIN) {
+ (tcp_flags & (TH_ACK | TH_FIN)) == TH_FIN) {
conn->tcp_state = TCPS_FIN_WAIT_1;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [RFC PATCH 4/6] hw/net/vmxnet3: Use the tcp_header structure
2019-08-08 14:34 [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2019-08-08 14:34 ` [Qemu-devel] [PATCH 3/6] net/filter-rewriter: " Philippe Mathieu-Daudé
@ 2019-08-08 14:34 ` Philippe Mathieu-Daudé
2019-08-08 14:34 ` [Qemu-devel] [PATCH 5/6] net/eth: Remove the unused tcp_hdr structure Philippe Mathieu-Daudé
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-08 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin, Jason Wang,
Zhang Chen, Philippe Mathieu-Daudé
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é <philmd@redhat.com>
---
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);
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;
}
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);
/* csum has to be enabled if tso is. */
@@ -330,7 +330,8 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool 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 = pkt->hdr_len + l4hdr.th_off * sizeof(uint32_t);
+ pkt->virt_hdr.hdr_len = pkt->hdr_len
+ + TCP_HEADER_DATA_OFFSET(&l4hdr) * sizeof(uint32_t);
pkt->virt_hdr.gso_size = gso_size;
break;
@@ -343,7 +344,7 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable,
case IP_PROTO_TCP:
pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
pkt->virt_hdr.csum_start = pkt->hdr_len;
- pkt->virt_hdr.csum_offset = offsetof(struct tcp_hdr, th_sum);
+ pkt->virt_hdr.csum_offset = offsetof(struct tcp_header, th_sum);
break;
case IP_PROTO_UDP:
pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 5/6] net/eth: Remove the unused tcp_hdr structure
2019-08-08 14:34 [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2019-08-08 14:34 ` [Qemu-devel] [RFC PATCH 4/6] hw/net/vmxnet3: " Philippe Mathieu-Daudé
@ 2019-08-08 14:34 ` 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é
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-08 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin, Jason Wang,
Zhang Chen, Philippe Mathieu-Daudé
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é <philmd@redhat.com>
---
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))
-#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
#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 */
};
-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
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 6/6] net/eth: Remove the single use of udp_hdr structure
2019-08-08 14:34 [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures Philippe Mathieu-Daudé
` (4 preceding siblings ...)
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 ` 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é
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-08 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin, Jason Wang,
Zhang Chen, Philippe Mathieu-Daudé
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é <philmd@redhat.com>
---
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, bool tso_enable,
case IP_PROTO_UDP:
pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
pkt->virt_hdr.csum_start = pkt->hdr_len;
- pkt->virt_hdr.csum_offset = offsetof(struct udp_hdr, uh_sum);
+ pkt->virt_hdr.csum_offset = offsetof(struct udp_header, uh_sum);
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;
};
-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
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures
2019-08-08 14:34 [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures Philippe Mathieu-Daudé
` (5 preceding siblings ...)
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 ` Dmitry Fleytman
2019-08-18 21:38 ` Philippe Mathieu-Daudé
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Fleytman @ 2019-08-12 8:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Zhang Chen, Jason Wang, qemu-devel, Li Zhijian, Michael S. Tsirkin
Reviewed-by: Dmitry Fleytman <dmitry.fleytman@gmail.com>
> On 8 Aug 2019, at 17:34, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> This is a preparatory cleanup series.
>
> Commit 75020a70215 introduced 4 very equivalent structures:
> - tcp_header and tcp_hdr,
> - udp_header and udp_hdr.
>
> Choose the most widely use in the codebase, which happens to
> provide convenient bitfields manipulation macros and is not
> endian-specific.
>
> Philippe Mathieu-Daudé (6):
> hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros
> net/colo-compare: Use the tcp_header structure
> net/filter-rewriter: Use the tcp_header structure
> hw/net/vmxnet3: Use the tcp_header structure
> net/eth: Remove the unused tcp_hdr structure
> net/eth: Remove the single use of udp_hdr structure
>
> hw/net/net_rx_pkt.c | 2 +-
> hw/net/net_tx_pkt.c | 9 +++++----
> hw/net/virtio-net.c | 9 ++-------
> include/net/eth.h | 47 ++++++++-----------------------------------
> net/colo-compare.c | 14 ++++++-------
> net/filter-rewriter.c | 37 +++++++++++++++++++---------------
> 6 files changed, 44 insertions(+), 74 deletions(-)
>
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures
2019-08-08 14:34 [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures Philippe Mathieu-Daudé
` (6 preceding siblings ...)
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
7 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-18 21:38 UTC (permalink / raw)
To: qemu-devel
Cc: Zhang Chen, Jason Wang, Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin
Hi Jason,
On 8/8/19 4:34 PM, Philippe Mathieu-Daudé wrote:
> This is a preparatory cleanup series.
>
> Commit 75020a70215 introduced 4 very equivalent structures:
> - tcp_header and tcp_hdr,
> - udp_header and udp_hdr.
>
> Choose the most widely use in the codebase, which happens to
> provide convenient bitfields manipulation macros and is not
> endian-specific.
>
> Philippe Mathieu-Daudé (6):
> hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros
> net/colo-compare: Use the tcp_header structure
> net/filter-rewriter: Use the tcp_header structure
> hw/net/vmxnet3: Use the tcp_header structure
> net/eth: Remove the unused tcp_hdr structure
> net/eth: Remove the single use of udp_hdr structure
Are you OK to take this series?
It got reviewed by Dmitry Fleytman.
Thanks,
Phil.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures
2019-08-18 21:38 ` Philippe Mathieu-Daudé
@ 2019-08-19 3:08 ` Jason Wang
0 siblings, 0 replies; 10+ messages in thread
From: Jason Wang @ 2019-08-19 3:08 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhang Chen, Dmitry Fleytman, Li Zhijian, Michael S. Tsirkin
On 2019/8/19 上午5:38, Philippe Mathieu-Daudé wrote:
> Hi Jason,
>
> On 8/8/19 4:34 PM, Philippe Mathieu-Daudé wrote:
>> This is a preparatory cleanup series.
>>
>> Commit 75020a70215 introduced 4 very equivalent structures:
>> - tcp_header and tcp_hdr,
>> - udp_header and udp_hdr.
>>
>> Choose the most widely use in the codebase, which happens to
>> provide convenient bitfields manipulation macros and is not
>> endian-specific.
>>
>> Philippe Mathieu-Daudé (6):
>> hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros
>> net/colo-compare: Use the tcp_header structure
>> net/filter-rewriter: Use the tcp_header structure
>> hw/net/vmxnet3: Use the tcp_header structure
>> net/eth: Remove the unused tcp_hdr structure
>> net/eth: Remove the single use of udp_hdr structure
> Are you OK to take this series?
>
> It got reviewed by Dmitry Fleytman.
>
> Thanks,
>
> Phil.
Yes. Applied.
Thanks
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-08-19 3:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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
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).