[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 36/65] slirp: add a callback to log guest errors
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PULL 36/65] slirp: add a callback to log guest errors |
Date: |
Mon, 14 Jan 2019 23:52:37 +0100 |
From: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>
---
net/slirp.c | 7 +++++++
slirp/dhcpv6.c | 6 +++---
slirp/ip6_icmp.c | 7 +++----
slirp/libslirp.h | 2 ++
4 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c
index 031c324f02..ea8b04e007 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/log.h"
#include "net/slirp.h"
@@ -140,8 +141,14 @@ static NetClientInfo net_slirp_info = {
.cleanup = net_slirp_cleanup,
};
+static void net_slirp_guest_error(const char *msg)
+{
+ qemu_log_mask(LOG_GUEST_ERROR, "%s", msg);
+}
+
static const SlirpCb slirp_cb = {
.output = net_slirp_output,
+ .guest_error = net_slirp_guest_error,
};
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 olen,
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 = odata[2] << 8 | odata[3];
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;
}
@@ -121,7 +121,7 @@ static void dhcpv6_info_request(Slirp *slirp, struct
sockaddr_in6 *srcsas,
struct mbuf *m;
uint8_t *resp;
- if (dhcpv6_parse_info_request(odata, olen, &ri) < 0) {
+ if (dhcpv6_parse_info_request(slirp, odata, olen, &ri) < 0) {
return;
}
diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c
index 595647b1b1..3f74d172f4 100644
--- a/slirp/ip6_icmp.c
+++ b/slirp/ip6_icmp.c
@@ -342,8 +342,7 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, struct
ip6 *ip,
case ICMP6_NDP_RA:
DEBUG_CALL(" type = 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;
case ICMP6_NDP_NS:
@@ -376,8 +375,8 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, struct
ip6 *ip,
case ICMP6_NDP_REDIRECT:
DEBUG_CALL(" type = 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;
}
}
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index a5d1b27b5e..3e0aa19f4b 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -13,6 +13,8 @@ typedef struct Slirp Slirp;
typedef struct SlirpCb {
/* Send an ethernet frame to the guest network. */
void (*output)(void *opaque, const uint8_t *pkt, int pkt_len);
+ /* Print a message for an error due to guest misbehavior. */
+ void (*guest_error)(const char *msg);
} SlirpCb;
--
2.20.1
- [Qemu-devel] [PULL 27/65] slirp: remove HAVE_SYS_FILIO_H, (continued)
- [Qemu-devel] [PULL 27/65] slirp: remove HAVE_SYS_FILIO_H, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 33/65] slirp: remove unused global slirp_instance, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 32/65] slirp: replace compile time DO_KEEPALIVE, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 31/65] slirp: replace SIZEOF_CHAR_P with glib equivalent, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 37/65] slirp: remove #if notdef dead code, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 40/65] slirp: remove dead TCP_ACK_HACK code, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 38/65] slirp: remove unused sbflush(), Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 43/65] glib-compat: add g_spawn_async_with_fds() fallback, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 46/65] slirp: Enable fork_exec support on Windows, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 48/65] slirp: rename exec_list, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 36/65] slirp: add a callback to log guest errors,
Samuel Thibault <=
- [Qemu-devel] [PULL 41/65] slirp: replace ARRAY_SIZE with G_N_ELEMENTS, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 51/65] slirp: replace some fprintf() with DEBUG_MISC, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 42/65] net: do not depend on slirp internals, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 45/65] slirp: replace error_report() with g_critical(), Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 49/65] slirp: use virtual time for packet expiration, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 55/65] slirp: introduce SLIRP_DEBUG environment variable, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 64/65] slirp: Mark debugging calls as unlikely, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 61/65] build-sys: use a separate slirp-obj-y && slirp.mo, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 62/65] slirp: set G_LOG_DOMAIN, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 39/65] slirp: NULL is defined by stddef.h, Samuel Thibault, 2019/01/14