From nobody Thu Nov 6 16:22:45 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542200303059888.0631072372494; Wed, 14 Nov 2018 04:58:23 -0800 (PST) Received: from localhost ([::1]:59901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMukP-0008Rl-PY for importer@patchew.org; Wed, 14 Nov 2018 07:58:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMuVO-000475-QN for qemu-devel@nongnu.org; Wed, 14 Nov 2018 07:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMuVK-00040Z-NI for qemu-devel@nongnu.org; Wed, 14 Nov 2018 07:42:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28983) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMuVI-0003xa-VH for qemu-devel@nongnu.org; Wed, 14 Nov 2018 07:42:45 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B21B3164666; Wed, 14 Nov 2018 12:42:39 +0000 (UTC) Received: from localhost (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A86A5D985; Wed, 14 Nov 2018 12:42:31 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 14 Nov 2018 16:36:33 +0400 Message-Id: <20181114123643.24091-32-marcandre.lureau@redhat.com> In-Reply-To: <20181114123643.24091-1-marcandre.lureau@redhat.com> References: <20181114123643.24091-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 14 Nov 2018 12:42:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 31/41] slirp: add a callback to log guest errors 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@ens-lyon.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , rjones@redhat.com, stefanha@redhat.com, renzo@cs.unibo.it Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- slirp/libslirp.h | 1 + net/slirp.c | 7 +++++++ slirp/dhcpv6.c | 6 +++--- slirp/ip6_icmp.c | 7 +++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/slirp/libslirp.h b/slirp/libslirp.h index f2e7f94ebb..c7582e6516 100644 --- a/slirp/libslirp.h +++ b/slirp/libslirp.h @@ -21,6 +21,7 @@ typedef struct SlirpCb { void (*timer_free)(void *timer); void (*timer_mod)(void *timer, int64_t expire_timer); void (*set_nonblock)(int fd); + void (*guest_error)(const char *msg); } SlirpCb; =20 =20 diff --git a/net/slirp.c b/net/slirp.c index 5ea8c255f6..b36092c948 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/log.h" #include "net/slirp.h" =20 =20 @@ -183,6 +184,11 @@ static void net_slirp_timer_mod(void *timer, int64_t e= xpire_timer) timer_mod(timer, expire_timer); } =20 +static void net_slirp_guest_error(const char *msg) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s", msg); +} + static SlirpCb slirp_cb =3D { .output =3D net_slirp_output, .chr_write_all =3D net_slirp_chr_write_all, @@ -191,6 +197,7 @@ static SlirpCb slirp_cb =3D { .timer_free =3D net_slirp_timer_free, .timer_mod =3D net_slirp_timer_mod, .set_nonblock =3D qemu_set_nonblock, + .guest_error =3D net_slirp_guest_error, }; =20 static int net_slirp_init(NetClientState *peer, const char *model, diff --git a/slirp/dhcpv6.c b/slirp/dhcpv6.c index 943a13bca8..5d703e8ae6 100644 --- a/slirp/dhcpv6.c +++ b/slirp/dhcpv6.c @@ -50,7 +50,7 @@ struct requested_infos { * the odata region, thus the caller must keep odata valid as long as it * needs to access the requested_infos struct. */ -static int dhcpv6_parse_info_request(uint8_t *odata, int olen, +static int dhcpv6_parse_info_request(Slirp *slirp, uint8_t *odata, int ole= n, struct requested_infos *ri) { int i, req_opt; @@ -61,7 +61,7 @@ static int dhcpv6_parse_info_request(uint8_t *odata, int = olen, int len =3D odata[2] << 8 | odata[3]; =20 if (len + 4 > olen) { - qemu_log_mask(LOG_GUEST_ERROR, "Guest sent bad DHCPv6 packet!\= n"); + slirp->cb->guest_error("Guest sent bad DHCPv6 packet!"); return -E2BIG; } =20 @@ -121,7 +121,7 @@ static void dhcpv6_info_request(Slirp *slirp, struct so= ckaddr_in6 *srcsas, struct mbuf *m; uint8_t *resp; =20 - if (dhcpv6_parse_info_request(odata, olen, &ri) < 0) { + if (dhcpv6_parse_info_request(slirp, odata, olen, &ri) < 0) { return; } =20 diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c index 6f20190a0a..d523852a1f 100644 --- a/slirp/ip6_icmp.c +++ b/slirp/ip6_icmp.c @@ -343,8 +343,7 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, str= uct ip6 *ip, =20 case ICMP6_NDP_RA: DEBUG_CALL(" type =3D Router Advertisement"); - qemu_log_mask(LOG_GUEST_ERROR, - "Warning: guest sent NDP RA, but shouldn't"); + slirp->cb->guest_error("Warning: guest sent NDP RA, but shouldn't"= ); break; =20 case ICMP6_NDP_NS: @@ -377,8 +376,8 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, str= uct ip6 *ip, =20 case ICMP6_NDP_REDIRECT: DEBUG_CALL(" type =3D Redirect"); - qemu_log_mask(LOG_GUEST_ERROR, - "Warning: guest sent NDP REDIRECT, but shouldn't"); + slirp->cb->guest_error( + "Warning: guest sent NDP REDIRECT, but shouldn't"); break; } } --=20 2.19.1.708.g4ede3d42df