From nobody Tue Nov 4 12:57:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503875175769824.3897959779727; Sun, 27 Aug 2017 16:06:15 -0700 (PDT) Received: from localhost ([::1]:35908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm6dB-00063u-V0 for importer@patchew.org; Sun, 27 Aug 2017 19:06:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm6cB-0005lI-1F for qemu-devel@nongnu.org; Sun, 27 Aug 2017 19:05:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dm6c9-0001VK-VW for qemu-devel@nongnu.org; Sun, 27 Aug 2017 19:05:10 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:43472) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dm6c9-0001UK-O9 for qemu-devel@nongnu.org; Sun, 27 Aug 2017 19:05:09 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id EE6C9D72C; Mon, 28 Aug 2017 01:05:08 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JEUh9MoYMv75; Mon, 28 Aug 2017 01:05:08 +0200 (CEST) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 00785E0B8; Mon, 28 Aug 2017 01:05:07 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.89) (envelope-from ) id 1dm6c6-0003JJ-Uk; Mon, 28 Aug 2017 01:05:06 +0200 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 01:05:06 +0200 Message-Id: <20170827230506.12683-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170827230506.12683-1-samuel.thibault@ens-lyon.org> References: <20170827230506.12683-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:474::1 Subject: [Qemu-devel] [PULL 1/1] slirp: fix clearing ifq_so from pending packets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The if_fastq and if_batchq contain not only packets, but queues of packets for the same socket. When sofree frees a socket, it thus has to clear ifq_so from all the packets from the queues, not only the first. Signed-off-by: Samuel Thibault Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- slirp/socket.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/slirp/socket.c b/slirp/socket.c index ecec0295a9..cb7b5b608d 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -59,6 +59,27 @@ socreate(Slirp *slirp) return(so); } =20 +/* + * Remove references to so from the given message queue. + */ +static void +soqfree(struct socket *so, struct quehead *qh) +{ + struct mbuf *ifq; + + for (ifq =3D (struct mbuf *) qh->qh_link; + (struct quehead *) ifq !=3D qh; + ifq =3D ifq->ifq_next) { + if (ifq->ifq_so =3D=3D so) { + struct mbuf *ifm; + ifq->ifq_so =3D NULL; + for (ifm =3D ifq->ifs_next; ifm !=3D ifq; ifm =3D ifm->ifs_nex= t) { + ifm->ifq_so =3D NULL; + } + } + } +} + /* * remque and free a socket, clobber cache */ @@ -66,23 +87,9 @@ void sofree(struct socket *so) { Slirp *slirp =3D so->slirp; - struct mbuf *ifm; =20 - for (ifm =3D (struct mbuf *) slirp->if_fastq.qh_link; - (struct quehead *) ifm !=3D &slirp->if_fastq; - ifm =3D ifm->ifq_next) { - if (ifm->ifq_so =3D=3D so) { - ifm->ifq_so =3D NULL; - } - } - - for (ifm =3D (struct mbuf *) slirp->if_batchq.qh_link; - (struct quehead *) ifm !=3D &slirp->if_batchq; - ifm =3D ifm->ifq_next) { - if (ifm->ifq_so =3D=3D so) { - ifm->ifq_so =3D NULL; - } - } + soqfree(so, &slirp->if_fastq); + soqfree(so, &slirp->if_batchq); =20 if (so->so_emu=3D=3DEMU_RSH && so->extra) { sofree(so->extra); --=20 2.14.1