aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2024-04-24 18:42:34 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2024-04-24 18:43:24 +0200
commit0ad461c225cfcc263ea1c2dd5cbb6093d146b093 (patch)
tree01c614ab6d76aa99df1b3af192ef1d9b4084d0b1 /src
parentb39edde03fdcd676a07c169ad845312dc5f54e28 (diff)
downloadslirp-0ad461c225cfcc263ea1c2dd5cbb6093d146b093.zip
slirp-0ad461c225cfcc263ea1c2dd5cbb6093d146b093.tar.gz
slirp-0ad461c225cfcc263ea1c2dd5cbb6093d146b093.tar.bz2
icmp: Fix msg duplication for debugging
In case of socket error, we are not consuming the package. So duplicate it after socket operations, once we are sure that we will consume the packet.
Diffstat (limited to 'src')
-rw-r--r--src/ip_icmp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ip_icmp.c b/src/ip_icmp.c
index 044f633..74524fd 100644
--- a/src/ip_icmp.c
+++ b/src/ip_icmp.c
@@ -91,9 +91,7 @@ void icmp_cleanup(Slirp *slirp)
static int icmp_send(struct socket *so, struct mbuf *m, int hlen)
{
Slirp *slirp = m->slirp;
- M_DUP_DEBUG(slirp, m, 0, 0);
- struct ip *ip = mtod(m, struct ip *);
struct sockaddr_in addr;
/*
@@ -133,6 +131,9 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)
return -1;
}
+ M_DUP_DEBUG(slirp, m, 0, 0);
+ struct ip *ip = mtod(m, struct ip *);
+
so->so_m = m;
so->so_faddr = ip->ip_dst;
so->so_laddr = ip->ip_src;