From patchwork Thu Nov 9 18:01:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 836463 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yXrbn45bVz9sPm for ; Fri, 10 Nov 2017 05:02:29 +1100 (AEDT) Received: from localhost ([::1]:38192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCr9n-0005Kj-Mx for incoming@patchwork.ozlabs.org; Thu, 09 Nov 2017 13:02:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCr9E-0005J3-A5 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 13:01:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCr98-0002L0-FG for qemu-devel@nongnu.org; Thu, 09 Nov 2017 13:01:52 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:58938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCr98-0002KQ-91 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 13:01:46 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id A4380F690; Thu, 9 Nov 2017 19:01:46 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr 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 BpLIM72T0azL; Thu, 9 Nov 2017 19:01:45 +0100 (CET) Received: from var.youpi.perso.aquilenet.fr (unknown [81.18.188.212]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 1327AFCDA; Thu, 9 Nov 2017 19:01:45 +0100 (CET) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.89) (envelope-from ) id 1eCr94-0003dJ-Dq; Thu, 09 Nov 2017 19:01:42 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Thu, 9 Nov 2017 19:01:42 +0100 Message-Id: <20171109180142.13923-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171109180142.13923-1-samuel.thibault@ens-lyon.org> References: <20171109180142.13923-1-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 141.255.128.1 Subject: [Qemu-devel] [PULL 1/1] slirp: don't zero the whole ti_i when m == NULL 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: jan.kiszka@siemens.com, Samuel Thibault , stefanha@redhat.com, Tao Wu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Tao Wu 98c63057d2144fb81681580cd84c13c93794c96e ('slirp: Factorizing tcpiphdr structure with an union') introduced a memset call to clear possibly-undefined fields in ti. This however overwrites src/dst/pr which are used below. So let us clear only the unused fields. This should fix some rare cases (some RST cases, keep alive probes) where packets would be sent to 0.0.0.0. Signed-off-by: Tao Wu Signed-off-by: Samuel Thibault --- slirp/tcp_subr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index dc8b4bbb50..da0d53743f 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -148,7 +148,16 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m, m->m_data += IF_MAXLINKHDR; *mtod(m, struct tcpiphdr *) = *ti; ti = mtod(m, struct tcpiphdr *); - memset(&ti->ti, 0, sizeof(ti->ti)); + switch (af) { + case AF_INET: + ti->ti.ti_i4.ih_x1 = 0; + break; + case AF_INET6: + ti->ti.ti_i6.ih_x1 = 0; + break; + default: + g_assert_not_reached(); + } flags = TH_ACK; } else { /*