|
|
9ae3a8 |
From aac430f476746c628665b96d2ef520a4fc88ca67 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Xiao Wang <jasowang@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 30 Jul 2018 06:31:56 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 7/8] slirp: remove mbuf(m_hdr, m_dat) indirection
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Xiao Wang <jasowang@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1532932317-6100-2-git-send-email-jasowang@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 81542
|
|
|
9ae3a8 |
O-Subject: [RHEL7.6/7.5.z qemu-kvm PATCH 1/2] slirp: remove mbuf(m_hdr, m_dat) indirection
|
|
|
9ae3a8 |
Bugzilla: 1586253
|
|
|
9ae3a8 |
RH-Acked-by: wexu@redhat.com
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Michael Tokarev <mjt@tls.msk.ru>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
(cherry picked from commit 0e44486cdccb4c1f9e5fad390cfd7186850c7204)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
slirp/mbuf.h | 51 ++++++++++++++++++---------------------------------
|
|
|
9ae3a8 |
slirp/tcp_subr.c | 12 ++++++------
|
|
|
9ae3a8 |
2 files changed, 24 insertions(+), 39 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/slirp/mbuf.h b/slirp/mbuf.h
|
|
|
9ae3a8 |
index 3f3ab09..b144f1c 100644
|
|
|
9ae3a8 |
--- a/slirp/mbuf.h
|
|
|
9ae3a8 |
+++ b/slirp/mbuf.h
|
|
|
9ae3a8 |
@@ -49,22 +49,6 @@
|
|
|
9ae3a8 |
* free the m_ext. This is inefficient memory-wise, but who cares.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-/* XXX should union some of these! */
|
|
|
9ae3a8 |
-/* header at beginning of each mbuf: */
|
|
|
9ae3a8 |
-struct m_hdr {
|
|
|
9ae3a8 |
- struct mbuf *mh_next; /* Linked list of mbufs */
|
|
|
9ae3a8 |
- struct mbuf *mh_prev;
|
|
|
9ae3a8 |
- struct mbuf *mh_nextpkt; /* Next packet in queue/record */
|
|
|
9ae3a8 |
- struct mbuf *mh_prevpkt; /* Flags aren't used in the output queue */
|
|
|
9ae3a8 |
- int mh_flags; /* Misc flags */
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- int mh_size; /* Size of data */
|
|
|
9ae3a8 |
- struct socket *mh_so;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- caddr_t mh_data; /* Location of data */
|
|
|
9ae3a8 |
- int mh_len; /* Amount of data in this mbuf */
|
|
|
9ae3a8 |
-};
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* How much room is in the mbuf, from m_data to the end of the mbuf
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
@@ -80,29 +64,30 @@ struct m_hdr {
|
|
|
9ae3a8 |
#define M_TRAILINGSPACE M_FREEROOM
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
struct mbuf {
|
|
|
9ae3a8 |
- struct m_hdr m_hdr;
|
|
|
9ae3a8 |
+ /* XXX should union some of these! */
|
|
|
9ae3a8 |
+ /* header at beginning of each mbuf: */
|
|
|
9ae3a8 |
+ struct mbuf *m_next; /* Linked list of mbufs */
|
|
|
9ae3a8 |
+ struct mbuf *m_prev;
|
|
|
9ae3a8 |
+ struct mbuf *m_nextpkt; /* Next packet in queue/record */
|
|
|
9ae3a8 |
+ struct mbuf *m_prevpkt; /* Flags aren't used in the output queue */
|
|
|
9ae3a8 |
+ int m_flags; /* Misc flags */
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ int m_size; /* Size of data */
|
|
|
9ae3a8 |
+ struct socket *m_so;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ caddr_t m_data; /* Location of data */
|
|
|
9ae3a8 |
+ int m_len; /* Amount of data in this mbuf */
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
Slirp *slirp;
|
|
|
9ae3a8 |
bool arp_requested;
|
|
|
9ae3a8 |
uint64_t expiration_date;
|
|
|
9ae3a8 |
/* start of dynamic buffer area, must be last element */
|
|
|
9ae3a8 |
- union M_dat {
|
|
|
9ae3a8 |
- char m_dat_[1]; /* ANSI don't like 0 sized arrays */
|
|
|
9ae3a8 |
- char *m_ext_;
|
|
|
9ae3a8 |
- } M_dat;
|
|
|
9ae3a8 |
+ union {
|
|
|
9ae3a8 |
+ char m_dat[1]; /* ANSI don't like 0 sized arrays */
|
|
|
9ae3a8 |
+ char *m_ext;
|
|
|
9ae3a8 |
+ };
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#define m_next m_hdr.mh_next
|
|
|
9ae3a8 |
-#define m_prev m_hdr.mh_prev
|
|
|
9ae3a8 |
-#define m_nextpkt m_hdr.mh_nextpkt
|
|
|
9ae3a8 |
-#define m_prevpkt m_hdr.mh_prevpkt
|
|
|
9ae3a8 |
-#define m_flags m_hdr.mh_flags
|
|
|
9ae3a8 |
-#define m_len m_hdr.mh_len
|
|
|
9ae3a8 |
-#define m_data m_hdr.mh_data
|
|
|
9ae3a8 |
-#define m_size m_hdr.mh_size
|
|
|
9ae3a8 |
-#define m_dat M_dat.m_dat_
|
|
|
9ae3a8 |
-#define m_ext M_dat.m_ext_
|
|
|
9ae3a8 |
-#define m_so m_hdr.mh_so
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
#define ifq_prev m_prev
|
|
|
9ae3a8 |
#define ifq_next m_next
|
|
|
9ae3a8 |
#define ifs_prev m_prevpkt
|
|
|
9ae3a8 |
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
|
|
|
9ae3a8 |
index e98ce1a..043f28f 100644
|
|
|
9ae3a8 |
--- a/slirp/tcp_subr.c
|
|
|
9ae3a8 |
+++ b/slirp/tcp_subr.c
|
|
|
9ae3a8 |
@@ -647,7 +647,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
n4 = (laddr & 0xff);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
m->m_len = bptr - m->m_data; /* Adjust length */
|
|
|
9ae3a8 |
- m->m_len += snprintf(bptr, m->m_hdr.mh_size - m->m_len,
|
|
|
9ae3a8 |
+ m->m_len += snprintf(bptr, m->m_size - m->m_len,
|
|
|
9ae3a8 |
"ORT %d,%d,%d,%d,%d,%d\r\n%s",
|
|
|
9ae3a8 |
n1, n2, n3, n4, n5, n6, x==7?buff:"");
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
@@ -680,7 +680,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
n4 = (laddr & 0xff);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
m->m_len = bptr - m->m_data; /* Adjust length */
|
|
|
9ae3a8 |
- m->m_len += snprintf(bptr, m->m_hdr.mh_size - m->m_len,
|
|
|
9ae3a8 |
+ m->m_len += snprintf(bptr, m->m_size - m->m_len,
|
|
|
9ae3a8 |
"27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n%s",
|
|
|
9ae3a8 |
n1, n2, n3, n4, n5, n6, x==7?buff:"");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -706,7 +706,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
if (m->m_data[m->m_len-1] == '\0' && lport != 0 &&
|
|
|
9ae3a8 |
(so = tcp_listen(slirp, INADDR_ANY, 0, so->so_laddr.s_addr,
|
|
|
9ae3a8 |
htons(lport), SS_FACCEPTONCE)) != NULL)
|
|
|
9ae3a8 |
- m->m_len = snprintf(m->m_data, m->m_hdr.mh_size, "%d",
|
|
|
9ae3a8 |
+ m->m_len = snprintf(m->m_data, m->m_size, "%d",
|
|
|
9ae3a8 |
ntohs(so->so_fport)) + 1;
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -726,7 +726,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
m->m_len = bptr - m->m_data; /* Adjust length */
|
|
|
9ae3a8 |
- m->m_len += snprintf(bptr, m->m_hdr.mh_size,
|
|
|
9ae3a8 |
+ m->m_len += snprintf(bptr, m->m_size,
|
|
|
9ae3a8 |
"DCC CHAT chat %lu %u%c\n",
|
|
|
9ae3a8 |
(unsigned long)ntohl(so->so_faddr.s_addr),
|
|
|
9ae3a8 |
ntohs(so->so_fport), 1);
|
|
|
9ae3a8 |
@@ -737,7 +737,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
m->m_len = bptr - m->m_data; /* Adjust length */
|
|
|
9ae3a8 |
- m->m_len += snprintf(bptr, m->m_hdr.mh_size,
|
|
|
9ae3a8 |
+ m->m_len += snprintf(bptr, m->m_size,
|
|
|
9ae3a8 |
"DCC SEND %s %lu %u %u%c\n", buff,
|
|
|
9ae3a8 |
(unsigned long)ntohl(so->so_faddr.s_addr),
|
|
|
9ae3a8 |
ntohs(so->so_fport), n1, 1);
|
|
|
9ae3a8 |
@@ -748,7 +748,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
m->m_len = bptr - m->m_data; /* Adjust length */
|
|
|
9ae3a8 |
- m->m_len += snprintf(bptr, m->m_hdr.mh_size,
|
|
|
9ae3a8 |
+ m->m_len += snprintf(bptr, m->m_size,
|
|
|
9ae3a8 |
"DCC MOVE %s %lu %u %u%c\n", buff,
|
|
|
9ae3a8 |
(unsigned long)ntohl(so->so_faddr.s_addr),
|
|
|
9ae3a8 |
ntohs(so->so_fport), n1, 1);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|