thebeanogamer / rpms / qemu-kvm

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