[Slirp] [Git][slirp/libslirp][master] 2 commits: icmp: Handle ICMP packets as IPPROTO_IP on BSD

Samuel Thibault (@sthibaul) gitlab at gitlab.freedesktop.org
Mon Jun 19 11:30:53 UTC 2023



Samuel Thibault pushed to branch master at slirp / libslirp


Commits:
6fc8d283 by Seiya Nuta at 2023-06-19T11:30:50+00:00
icmp: Handle ICMP packets as IPPROTO_IP on BSD

In macOS, as already commented in this source file as well, packets from SOCK_DGRAM + IPPROTO_ICMP sockets include IP header while Linux doesn't not prepend the header.

Due to the discrepancy, in macOS, we need to handle received ICMP packets as if they are IP packets so that its IPv4 header gets stripped.

As pointed out in review comments, it appears CONFIG_BSD is no longer propagated from QEMU. This patch fixes the issue by detecting BSD (including macOS) by ourselves.

- - - - -
2533bf21 by Samuel Thibault at 2023-06-19T11:30:51+00:00
Merge branch 'strip-ip-header-from-icmp-packet-in-macos' into 'master'

icmp: Handle ICMP packets as IPPROTO_IP on BSD

See merge request slirp/libslirp!133
- - - - -


1 changed file:

- src/ip_icmp.c


Changes:

=====================================
src/ip_icmp.c
=====================================
@@ -34,6 +34,8 @@
 #include "slirp.h"
 #include "ip_icmp.h"
 
+#include <sys/param.h>
+
 #ifndef WITH_ICMP_ERROR_MSG
 #define WITH_ICMP_ERROR_MSG 0
 #endif
@@ -100,7 +102,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)
      * isn't possible to detect this difference at runtime, so we must use an
      * #ifdef to determine if we need to remove the IP header.
      */
-#ifdef CONFIG_BSD
+#if defined(BSD) && !defined(__GNU__)
     so->so_type = IPPROTO_IP;
 #else
     so->so_type = IPPROTO_ICMP;



View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/compare/26be815b86e8d49add8c9a8b320239b9594ff03d...2533bf21126a28f85e40fbfbbc9ba94fdb297530

-- 
View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/compare/26be815b86e8d49add8c9a8b320239b9594ff03d...2533bf21126a28f85e40fbfbbc9ba94fdb297530
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/slirp/attachments/20230619/0db46c09/attachment.htm>


More information about the Slirp mailing list