aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-08-13Avoid including <sys/param.h> on windowsHEADmasterSamuel Thibault1-0/+2
Fixes #72
2023-07-25Document functionsSamuel Thibault25-115/+315
2023-06-19Merge branch 'strip-ip-header-from-icmp-packet-in-macos' into 'master'Samuel Thibault1-1/+3
icmp: Handle ICMP packets as IPPROTO_IP on BSD See merge request slirp/libslirp!133
2023-06-19icmp: Handle ICMP packets as IPPROTO_IP on BSDSeiya Nuta1-1/+3
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.
2023-05-16ip: Enforce strict aliasingAkihiko Odaki2-100/+90
Sometimes ipq were casted to ipasfrag, and the original and casted pointer were used simultaneously in ip_reass(). GCC 12.1.0 assumes these pointers are not aliases, and therefore incorrectly the pointed data will not be modified when it is actually modified with another pointer. To fix this problem, introduce a new type "ipas", which is a universal type denoting an entry in the assembly queue and contains union for specialization as queue head (frequently referred as "q" or "ipq" in the source code) or IP fragment ("f" or "ipf"). This bug was found by Alexander Bulekov when fuzzing QEMU: https://patchew.org/QEMU/20230129053316.1071513-1-alxndr@bu.edu/ The fixed test case is: fuzz/crash_449dd4ad72212627fe3245c875f79a7033cc5382 Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-23Fix including BaseTsd.h on mingwSamuel Thibault1-1/+1
While windows does not care for case, mingw does, and has all its header lower case.
2023-04-23Use SSIZE_T from BaseTsd.h on windowsSamuel Thibault1-1/+2
It is defined by BaseTsd.h as LONG_PTR, which is 32bit size on win32, and 64bit size on win64. It seems that mingw rather uses int for the 32bit case, but better stick to the MS definition, and int/LONG_PTR will be abi-compatible on 32bit. Fixes #68
2023-02-16Merge branch 'qianwww-master-patch-52726' into 'master'Samuel Thibault1-29/+37
Detach UDP socket if errno is ENOTCONN (Socket is not connected) Closes #65 See merge request slirp/libslirp!132
2023-02-16Detach UDP socket if errno is ENOTCONN (Socket is not connected)Qian Wu1-29/+37
2022-12-03Merge branch 'master' into 'master'Samuel Thibault1-33/+62
slirp: use localhost as dns when /etc/resolv.conf empty Closes #25 See merge request slirp/libslirp!130
2022-12-03slirp: use localhost as dns when /etc/resolv.conf emptyJiri Slaby1-33/+62
2022-11-11missing semicolonpgajdos on gitlab.freedesktop.org1-1/+1
Fixes #64
2022-08-29Drop unused UDP_UDPDATALEN macroSamuel Thibault1-1/+0
2022-08-29Reject domain-search when any entry ends with ".."Samuel Thibault1-6/+6
rather than rejecting only when all of them are bogus. Reported-by: Michael T <michael.gr220@gmail.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2022-08-07Merge branch 'icmp6-na-use-target' into 'master'Samuel Thibault1-1/+1
Use target address from Neighbor Advertisement See merge request slirp/libslirp!129
2022-08-07Use target address from Neighbor AdvertisementBastian Blank1-1/+1
The IPv6 support in libslirp fails to work with any NDP proxy. The code used to interpret the NA packets uses the wrong address to insert into it's neighbor table, the address of the source of the packet, aka the proxy itself. However the NA packet got the real target address readily available. Just use it directly instead. Signed-off-by: Bastian Blank <waldi@debian.org>
2022-06-22Merge branch 'vmstate' into 'master'Samuel Thibault2-25/+7
Fix vmstate regression See merge request slirp/libslirp!127
2022-06-22Fix vmstate regressionMarc-André Lureau2-19/+0
Commit e7362700b ("msvc: enable vmstate code on !gnuc") forgot to remove HAVE_VMSTATE condition... Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-06-22msvc: use char* for pointer arithmeticMarc-André Lureau1-6/+7
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-06-18Align outgoing packetsSamuel Thibault2-18/+18
Fixes #62
2022-06-18Bump incoming packet alignment to 8 bytesSamuel Thibault1-2/+2
Fixes #63
2022-05-30Merge branch 'msvc' into 'master'Samuel Thibault2-6/+11
msvc: enable vmstate code on !gnuc See merge request slirp/libslirp!126
2022-05-30msvc: fix some gcc-specific pragma warningsMarc-André Lureau1-0/+4
2022-05-30msvc: enable vmstate code on !gnucMarc-André Lureau1-6/+7
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-30Merge branch 'msvc' into 'master'Marc-André Lureau24-126/+255
msvc fixes Closes #60 See merge request slirp/libslirp!124
2022-05-30vmstate: only enable when building under GNU CSamuel Thibault4-3/+29
To be able to use typeof. Fixes #60
2022-05-30ncsitest: Fix build with msvcSamuel Thibault1-7/+9
2022-05-28Avoid running git-version-gen when building with MS VCSamuel Thibault1-9/+14
The toolchain usually used there would typically completely fail to run it.
2022-05-28windows: export symbolsSamuel Thibault2-0/+30
2022-05-28win32: replace strcasecmp with g_ascii_strcasecmpSamuel Thibault1-3/+3
2022-05-28Drop spurious inlineSamuel Thibault1-2/+2
2022-05-28Avoid returning voidSamuel Thibault1-2/+3
2022-05-28Fix arithmetic on void *Samuel Thibault1-1/+1
2022-05-28Avoid using ##__VA_ARGS__ gcc extensionSamuel Thibault3-14/+21
2022-05-28Fix bitfields order for MSVCSamuel Thibault5-17/+21
It uses a saner strictly "from low to high bit" rule.
2022-05-28Separate out SLIRP_PACKED to SLIRP_PACKED_BEGIN/ENDSamuel Thibault7-47/+98
Since msvc provides the support through push/pop pragmas.
2022-05-28Do not use ssize_t on WindowsSamuel Thibault7-15/+20
It doesn't have it.
2022-05-28Do not include unistd.h on windows, it does not have itSamuel Thibault1-2/+1
2022-05-28Accept build-aux/git-version-gen failing to runSamuel Thibault1-4/+6
and just revert to meson.project_version()
2022-05-28container_of: avoid using __extension__Samuel Thibault1-5/+2
We can just write the macro on one line.
2022-05-28Merge branch 'master' into 'master'Samuel Thibault7-9/+367
ncsi: Add Mellanox Get MAC Address handler See merge request slirp/libslirp!125
2022-05-18ncsi: Add Mellanox Get Mac Address handlerPeter Delevoryas3-1/+121
Attempted to mirror the upstream Linux driver[1] as closely as reasonably possible. [1] https://github.com/torvalds/linux/blob/42226c989789d8da4af1de0c31070c96726d990c/net/ncsi/ncsi-rsp.c#L614-L638 Signed-off-by: Peter Delevoryas <pdel@fb.com>
2022-05-18slirp: Add out-of-band ethernet addressPeter Delevoryas3-0/+8
If a network card supports NC-SI, then it redirects all traffic with the out-of-band (OOB) management controller's (MC) ethernet address to the out-of-band management controller, usually over some sideband RMII interface, not like the PCIe connection to the main host. It's also pretty common for the network card to provision the out-of-band management controller's ethernet address. At startup, the OOB MC asks the network card what its MAC address is through OEM NC-SI commands. This protocol is so common that it's going to be standardized soon in NC-SI 1.2.0 [1] as "Get MC MAC Address". Note: At some point, the network card may provision *multiple* OOB ethernet addresses, but right now everything just uses one. [1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.2.0WIP80.pdf Signed-off-by: Peter Delevoryas <pdel@fb.com>
2022-05-18ncsi: Add OEM command handlerPeter Delevoryas3-3/+147
This commit just sets up the OEM command handler to respond with "unsupported" for now, as verified in the test. Signed-off-by: Peter Delevoryas <pdel@fb.com>
2022-05-18ncsi: Add basic test for Get Version ID responsePeter Delevoryas2-0/+82
Signed-off-by: Peter Delevoryas <pdel@fb.com>
2022-05-18ncsi: Use response header for payload lengthPeter Delevoryas1-1/+1
In the Linux NC-SI driver[1], each response's length is validated with a statically declared payload length, _unless_ it's an OEM command or some more complicated NC-SI packet that you can't determine the length of just from the "type" field, in which case it just uses the length provided by the response's header. To support OEM response handlers without requiring too many modifications we can make the default payload length use the value specified in the handler table, and then allow OEM handlers to override the length by modifying the "length" in the response header within the handler implementation. [1] https://github.com/torvalds/linux/blob/ec7f49619d8ee13e108740c82f942cd401b989e9/net/ncsi/ncsi-rsp.c#L1215-L1220 Signed-off-by: Peter Delevoryas <pdel@fb.com>
2022-05-18ncsi: Pass command header to response handlersPeter Delevoryas1-7/+11
This change passes the command header as an additional read-only parameter to each response handler so that they can make more response handling descisions based on the command header fields. This is especially useful for handling OEM NC-SI commands, or any protocol that's encapsulated in an NC-SI header. Signed-off-by: Peter Delevoryas <pdel@fb.com>
2022-05-17src/slirp.h: Bump the minimum Windows version to Windows 7Thomas Huth1-1/+1
Windows Vista is not supported by its vendor anymore. Additionally, glib uses 0x0601 as setting for _WIN32_WINNT since version 2.53.6 already, so unless libslirp is used with a very old version of glib, we are depending on Windows 7 anyway. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Message-Id: <20220516090410.39727-1-thuth@redhat.com>
2022-05-11Merge branch 'iana' into 'master'Samuel Thibault4-7/+30
ncsi: Add basic Get Version ID response See merge request slirp/libslirp!122
2022-05-11ncsi: Add Get Version ID commandPeter Delevoryas1-1/+12
Get Version ID is one of the first commands used in NC-SI, because BMC's use a lot of OEM NC-SI extensions, and you need to query the device's manufacturer through Get Version ID before you can decide which OEM NC-SI extensions to use. The response format is documented in the NC-SI spec[1]. We're just setting the NC-SI version supported to 1.0.0 (BCD-encoded[2]) and returning the manufacturer's ID in network byte-order. [1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.0.0.pdf [2] https://en.wikipedia.org/wiki/Binary-coded_decimal Signed-off-by: Peter Delevoryas <pdel@fb.com>