diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2018-11-14 16:36:33 +0400 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-01-14 00:43:30 +0100 |
commit | 2addc8fb6dac59b7232c65d1d43ec4bdd0b73420 (patch) | |
tree | 5051e830ecee3e24a048fdcc4de818ed54da0f12 /slirp | |
parent | 2afbb788ff43c5cb5a91fb3da9cae6bd9a70731f (diff) |
slirp: add a callback to log guest errors
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/dhcpv6.c | 6 | ||||
-rw-r--r-- | slirp/ip6_icmp.c | 7 | ||||
-rw-r--r-- | slirp/libslirp.h | 2 |
3 files changed, 8 insertions, 7 deletions
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; |