Blame SOURCES/kvm-slirp-fix-clearing-ifq_so-from-pending-packets.patch

4a2fec
From fab160fce838f609b3a395fcef40e4efce5c0fa7 Mon Sep 17 00:00:00 2001
4a2fec
From: Xiao Wang <jasowang@redhat.com>
4a2fec
Date: Tue, 28 Nov 2017 03:43:20 +0100
4a2fec
Subject: [PATCH 14/21] slirp: fix clearing ifq_so from pending packets
4a2fec
MIME-Version: 1.0
4a2fec
Content-Type: text/plain; charset=UTF-8
4a2fec
Content-Transfer-Encoding: 8bit
4a2fec
4a2fec
RH-Author: Xiao Wang <jasowang@redhat.com>
4a2fec
Message-id: <1511840600-52375-1-git-send-email-jasowang@redhat.com>
4a2fec
Patchwork-id: 77930
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH] slirp: fix clearing ifq_so from pending packets
4a2fec
Bugzilla: 1508750
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: wexu@redhat.com
4a2fec
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
4a2fec
4a2fec
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
4a2fec
4a2fec
The if_fastq and if_batchq contain not only packets, but queues of packets
4a2fec
for the same socket. When sofree frees a socket, it thus has to clear ifq_so
4a2fec
from all the packets from the queues, not only the first.
4a2fec
4a2fec
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
4a2fec
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4a2fec
Cc: qemu-stable@nongnu.org
4a2fec
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4a2fec
(cherry picked from commit 1201d308519f1e915866d7583d5136d03cc1d384)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 slirp/socket.c | 39 +++++++++++++++++++++++----------------
4a2fec
 1 file changed, 23 insertions(+), 16 deletions(-)
4a2fec
4a2fec
diff --git a/slirp/socket.c b/slirp/socket.c
4a2fec
index ecec029..cb7b5b6 100644
4a2fec
--- a/slirp/socket.c
4a2fec
+++ b/slirp/socket.c
4a2fec
@@ -60,29 +60,36 @@ socreate(Slirp *slirp)
4a2fec
 }
4a2fec
 
4a2fec
 /*
4a2fec
+ * Remove references to so from the given message queue.
4a2fec
+ */
4a2fec
+static void
4a2fec
+soqfree(struct socket *so, struct quehead *qh)
4a2fec
+{
4a2fec
+    struct mbuf *ifq;
4a2fec
+
4a2fec
+    for (ifq = (struct mbuf *) qh->qh_link;
4a2fec
+             (struct quehead *) ifq != qh;
4a2fec
+             ifq = ifq->ifq_next) {
4a2fec
+        if (ifq->ifq_so == so) {
4a2fec
+            struct mbuf *ifm;
4a2fec
+            ifq->ifq_so = NULL;
4a2fec
+            for (ifm = ifq->ifs_next; ifm != ifq; ifm = ifm->ifs_next) {
4a2fec
+                ifm->ifq_so = NULL;
4a2fec
+            }
4a2fec
+        }
4a2fec
+    }
4a2fec
+}
4a2fec
+
4a2fec
+/*
4a2fec
  * remque and free a socket, clobber cache
4a2fec
  */
4a2fec
 void
4a2fec
 sofree(struct socket *so)
4a2fec
 {
4a2fec
   Slirp *slirp = so->slirp;
4a2fec
-  struct mbuf *ifm;
4a2fec
 
4a2fec
-  for (ifm = (struct mbuf *) slirp->if_fastq.qh_link;
4a2fec
-       (struct quehead *) ifm != &slirp->if_fastq;
4a2fec
-       ifm = ifm->ifq_next) {
4a2fec
-    if (ifm->ifq_so == so) {
4a2fec
-      ifm->ifq_so = NULL;
4a2fec
-    }
4a2fec
-  }
4a2fec
-
4a2fec
-  for (ifm = (struct mbuf *) slirp->if_batchq.qh_link;
4a2fec
-       (struct quehead *) ifm != &slirp->if_batchq;
4a2fec
-       ifm = ifm->ifq_next) {
4a2fec
-    if (ifm->ifq_so == so) {
4a2fec
-      ifm->ifq_so = NULL;
4a2fec
-    }
4a2fec
-  }
4a2fec
+  soqfree(so, &slirp->if_fastq);
4a2fec
+  soqfree(so, &slirp->if_batchq);
4a2fec
 
4a2fec
   if (so->so_emu==EMU_RSH && so->extra) {
4a2fec
 	sofree(so->extra);
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec