aboutsummaryrefslogtreecommitdiff
path: root/slirp
AgeCommit message (Collapse)AuthorFilesLines
2020-04-21slirp: update to fix CVE-2020-1983Marc-André Lureau1-0/+0
This is an update on the stable-4.2 branch of libslirp.git: git shortlog 55ab21c9a3..2faae0f778f81 Marc-André Lureau (1): Fix use-afte-free in ip_reass() (CVE-2020-1983) CVE-2020-1983 is actually a follow up fix for commit 126c04acbabd7ad32c2b018fe10dfac2a3bc1210 ("Fix heap overflow in ip_reass on big packet input") which was was included in qemu v4.1 (commit e1a4a24d262ba5ac74ea1795adb3ab1cd574c7fb "slirp: update with CVE-2019-14378 fix"). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20200421170227.843555-1-marcandre.lureau@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-03-22slirp: update submodule to v4.2.0+Marc-André Lureau1-0/+0
git shortlog 126c04acbabd7ad32c2b018fe10dfac2a3bc1210..55ab21c9a36852915b81f1b41ebaf3b6509dd8ba 5eraph (1): Use specific outbound IP address Akihiro Suda (8): remove confusing comment that exists from ancient slirp add slirp_new(SlirpConfig *, SlirpCb *, void *) allow custom MTU add disable_host_loopback (prohibit connections to 127.0.0.1) add SlirpConfig version emu: remove dead code emu: disable by default fix a typo in a comment Anders Waldenborg (1): state: fix loading of guestfwd state Giuseppe Scrivano (1): socket: avoid getpeername after shutdown(SHUT_WR) Jindrich Novy (1): Don't leak memory when reallocation fails. Jordi Pujol Palomer (1): fork_exec: correctly parse command lines that contain spaces Marc-André Lureau (60): Merge branch 'AkihiroSuda/libslirp-slirp4netns' Merge branch 'fix-typo' into 'master' meson: make it subproject friendly Merge branch 'meson' into 'master' misc: fix compilation warnings Merge branch 'fix-shutdown-wr' into 'master' sbuf: remove unused and undefined sbcopy() path sbuf: check more strictly sbcopy() bounds with offset sbuf: replace a comment with a runtime warning Replace remaining malloc/free user with glib tcp_attach() can no longer fail state: can't ENOMEM sbuf: use unsigned types sbuf: simplify sbreserve() dnssearch: use g_strv_length() vmstate: silence scan-build warning gitlab-ci: run scan-build Merge branch 'mem-cleanups' into 'master' libslirp.map: bind slirp_new to SLIRP_4.1 version meson: fix libtool versioning Release v4.1.0 Merge branch '4.1.0' into 'master' CHANGELOG: start unreleased section Merge branch 'add-unix' into 'master' util: add G_SIZEOF_MEMBER() macro Check bootp_filename is not going to be truncated bootp: remove extra cast bootp: replace simple snprintf() with strcpy() tftp: clarify what is actually OACK m_len tcp_emu: add more fixme/warnings comments util: add slirp_fmt() helpers dhcpv6: use slirp_fmt() misc: use slirp_fmt0() tftp: use slirp_fmt0() tcp_ctl: use slirp_fmt() tcp_emu: fix unsafe snprintf() usages misc: improve error report Use g_snprintf() util: add gnuc format function attribute to slirp_fmt* Merge branch 'aw-guestfwd-state' into 'master' Merge branch 'slirp-fmt' into 'master' socket: remove extra label and variable socket: factor out sotranslate ipv4/ipv6 handling socket: remove need for extra scope_id variable socket: do not fallback on host loopback if get_dns_addr() failed socket: do not fallback on loopback addr for addresses in our mask/prefix Prepare for v4.2.0 release Merge branch 'translate-fix' into 'master' Merge branch 'release-v4.2.0' into 'master' changelog: post-release changelog: fix link .gitlab-ci: add --werror, treat CI build warnings as errors Revert "socket: remove need for extra scope_id variable" Teach slirp_version_string() to return vcs version Merge branch 'mingw-fix' into 'master' Merge branch 'vcs-version' into 'master' meson: bump required version to 0.49 build-sys: fix NetBSD build regression Merge branch 'netbsd-fix' into 'master' build-sys: make libslirp-version.h depend on Makefile PanNengyuan (1): libslirp: fix NULL pointer dereference in tcp_sockclosed Philippe Mathieu-Daudé (1): Add a git-publish configuration file Prasad J Pandit (4): slirp: ncsi: compute checksum for valid data length slirp: use correct size while emulating IRC commands slirp: use correct size while emulating commands slirp: tftp: restrict relative path access Renzo Davoli (2): Add slirp_remove_guestfwd() Add slirp_add_unix() Samuel Thibault (14): ip_reass: explain why we should not always update the q pointer Merge branch 'comment' into 'master' Merge branch 'no-emu' into 'master' Fix bogus indent, no source change ip_reass: Fix use after free Merge branch 'reass2' into 'master' Make host receive broadcast packets arp: Allow 0.0.0.0 destination address Merge branch 'warnings' into 'master' Merge branch 'arp_0' into 'master' Merge branch 'broadcast' into 'master' tcp_emu: Fix oob access Merge branch 'oob' into 'master' Merge branch 'master' into 'master' Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-08-02slirp: update with CVE-2019-14378 fixMarc-André Lureau1-0/+0
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-05-09Update upstream slirpSamuel Thibault1-0/+0
Adds gitignore, README file, and fixes ident protocol parsing. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-05-04Update slirp submoduleSamuel Thibault1-0/+0
To fix Windows on ARM.
2019-05-03build-sys: move slirp as git submodule projectMarc-André Lureau59-15722/+0
The slirp project is now hosted on freedesktop at: https://gitlab.freedesktop.org/slirp. The libslirp source was extracted from qemu/slirp filtered through clang-format (available in project tree). The qemu slirp directory can be swapped by a git submodule. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190424110041.8175-3-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-04-15slirp: Gcc 9 -O3 fixDr. David Alan Gilbert1-1/+4
Gcc 9 needs some convincing that sopreprbuf really is going to fill in iov in the call from soreadbuf, even though the failure case shouldn't happen. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20190415121740.9881-1-dgilbert@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-22slirp: is not maintained by Kelly Price for a long timeMarc-André Lureau1-2/+0
slirp has been maintained by the QEMU maintainers and will be maintained under an independent project soon. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kelly Price <strredwolf@gmail.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-03-22slirp: remove reference to COPYRIGHT fileMarc-André Lureau16-48/+0
The slirp COPYRIGHT file is a BSD-3 license. Instead of referring to another project file, the SPDX license notice present in all source files states that unequivocally. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2019-03-22slirp: clarify license of slirp files using SPDX: implicit via unstatedMarc-André Lureau12-0/+12
Add SPDX license identifier to clarify the license of files without explicit license header. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com>
2019-03-22slirp: clarify license of slirp files using SPDX: implicit via COPYRIGHTMarc-André Lureau11-0/+11
Add SPDX license identifier to clarify the license of files with reference to BSD license from slirp COPYRIGHT file. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com>
2019-03-22slirp: clarify license of slirp files using SPDX: explicit MITMarc-André Lureau9-0/+9
Add SPDX license identifier to clarify the license of files with explicit MIT license header. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com>
2019-03-22slirp: clarify license of slirp files using SPDX: explicit BSDMarc-André Lureau24-0/+24
Add SPDX license identifier to clarify the license of files with explicit 3-clause BSD license header. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com>
2019-03-22slirp: relicense GPL files to BSD-3Marc-André Lureau6-35/+170
In order to make slirp a standalone project, the project must have a clear license, and be compatible with the GPL or LGPL. Since commit 2f5f89963186d42a7ded253bc6cf5b32abb45cec ("Remove the advertising clause from the slirp license"), slirp is BSD-3. But new files have been added under slirp/ with QEMU GPL license since then. The copyright holders have been asked to relicense files to BSD-3 and gave their permission: - slirp/dhcpv6.{c,h} Subject: Re: Clearing slirp/ license To: "Marc-André Lureau" <marcandre.lureau@gmail.com>, QEMU <qemu-devel@nongnu.org>, Thomas Huth <thuth@redhat.com> Cc: Peter Maydell <peter.maydell@linaro.org>, Samuel Thibault <samuel.thibault@ens-lyon.org> References: <CAJ+F1CKBRNdLPb_wOLhURdUJd-j1RHY2toKSTEhCBt_zs4Xk1w@mail.gmail.com> From: "Cédric Le Goater" <clg@kaod.org> Message-ID: <e942cdab-fe1b-fdf4-3b9f-da16a4afa953@kaod.org> Date: Mon, 11 Mar 2019 16:23:25 +0100 > Could you reply that you have no objection in relicensing those files > are 3-Clause BSD? Fine for me. You can change the license of slirp/ncsi.c and slirp/ncsi-pkt.hto a 3-Clause BSD. Thanks, C. Subject: Re: [Qemu-devel] Clearing slirp/ license To: Peter Maydell <peter.maydell@linaro.org>, Shan Gavin <shan.gavin@gmail.com> Cc: Alexey Kardashevskiy <aik@ozlabs.ru>, "Marc-André Lureau" <marcandre.lureau@gmail.com>, Gavin Shan <gwshan@linux.vnet.ibm.com>, Thomas Huth <thuth@redhat.com>, QEMU <qemu-devel@nongnu.org>, Samuel Thibault <samuel.thibault@ens-lyon.org> References: <CAJ+F1CKBRNdLPb_wOLhURdUJd-j1RHY2toKSTEhCBt_zs4Xk1w@mail.gmail.com> <e942cdab-fe1b-fdf4-3b9f-da16a4afa953@kaod.org> <CAJ+F1C+hFfsa5gcSdttTP5J+uyDvNdYJWrm9OJM26+Zc1ZQkew@mail.gmail.com> <cc62e1fd-c564-e1b7-d10c-30665b481352@ozlabs.ru> <CAOL5TwkQXhPjdPP9v7n7mxAVxbDCSo6MEaG+E-Xys=MoD_pg2g@mail.gmail.com> <CAFEAcA_g=L2LSo=B_5dpJhJJrqFiOb6sswMVohQwpVGiKi_A7w@mail.gmail.com> From: "Cédric Le Goater" <clg@kaod.org> Message-ID: <4ddf6031-0df1-b3b5-965e-a181266e42b0@kaod.org> Date: Tue, 12 Mar 2019 11:49:21 +0100 > Is the code in question copyright you personally, or copyright > IBM as your employer at the time ? If the latter, it is IBM that > would need to approve the relicensing. That was done. I had our legal team approve the change of license. Thanks, C. From: Shan Gavin <shan.gavin@gmail.com> Date: Tue, 12 Mar 2019 15:04:54 +0800 Message-ID: <CAOL5TwkQXhPjdPP9v7n7mxAVxbDCSo6MEaG+E-Xys=MoD_pg2g@mail.gmail.com> Subject: Re: [Qemu-devel] Clearing slirp/ license To: Alexey Kardashevskiy <aik@ozlabs.ru> Cc: "Marc-André Lureau" <marcandre.lureau@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, gwshan@linux.vnet.ibm.com, Peter Maydell <peter.maydell@linaro.org>, Thomas Huth <thuth@redhat.com>, QEMU <qemu-devel@nongnu.org>, Samuel Thibault <samuel.thibault@ens-lyon.org> > Gavin, could you reply that you have no objection in relicensing > ncsi-pkt.h as 3-Clause BSD? No objection. Please go ahead with the relicensing. Cheers, Gavin - ncsi.c, ncsi-pkt.h Subject: Re: Clearing slirp/ license To: "Marc-André Lureau" <marcandre.lureau@gmail.com>, QEMU <qemu-devel@nongnu.org>, "Cédric Le Goater" <clg@kaod.org> Cc: Peter Maydell <peter.maydell@linaro.org>, Samuel Thibault <samuel.thibault@ens-lyon.org> References: <CAJ+F1CKBRNdLPb_wOLhURdUJd-j1RHY2toKSTEhCBt_zs4Xk1w@mail.gmail.com> From: Thomas Huth <thuth@redhat.com> Message-ID: <ed5a9f55-f2e5-298d-58ac-414759e9b491@redhat.com> Date: Wed, 13 Feb 2019 12:30:32 +0100 > Could you reply that you have no objection in relicensing those files > are 3-Clause BSD? Ok, for the records: I'm fine if you change the license of dhcpv6.[ch] to either 3-Clause BSD or 2-Clause BSD. Thomas - vmstate.{c,h} From: Juan Quintela <quintela@redhat.com> To: "Marc-André Lureau" <marcandre.lureau@gmail.com> Cc: QEMU <qemu-devel@nongnu.org>, Peter Maydell <peter.maydell@linaro.org>, Samuel Thibault <samuel.thibault@ens-lyon.org> Subject: Re: Clearing slirp/ license Date: Tue, 12 Mar 2019 12:43:17 +0100 Message-ID: <87k1h4qpwq.fsf@trasno.org> > Juan, Could you reply that you have no objection in relicensing the > vmstate files as 3-Clause BSD? No problem at all on my side. Later, Juan. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [ for the NC-SI files ] Reviewed-by: Cédric Le Goater <clg@kaod.org> Acked-by: Thomas Huth <thuth@redhat.com>
2019-03-22slirp: update COPYRIGHT to use full 3-Clause BSD LicenseMarc-André Lureau1-0/+3
According to commit 2f5f89963186d42a7ded253bc6cf5b32abb45cec ("Remove the advertising clause from the slirp license"), Danny Gasparovski gave permission to license slirp code under 3-clause BSD license: Subject: RE: Slirp license Date: Thu, 8 Jan 2009 10:51:00 +1100 From: "Gasparovski, Daniel" <Daniel.Gasparovski@ato.gov.au> To: "Richard Fontana" <rfontana@redhat.com> I have no objection to having Slirp code in QEMU be licensed under the 3-clause BSD license. slirp/COPYRIGHT's initial version in 2004 (commit 5fafdf24) listed only 3 clauses BUT used the poisonous advertising clause for clause 3 which is the controversial clause of non-free 4-clause (that is, it appears that the BSD-4 license was copied, and then the WRONG clause was deleted, when creating COPYRIGHT. Perhaps explained as an easy mistake to make since 3-clause was created by removing clause 3 of the 4-clause, where you sometimes see the three-clause version with clauses 1, 2, 4; but more commonly see a renumbered version with clauses 1, 2, 3 to close the gap. If you pay attention only to clause numbers instead of content, it can be easy to confuse which clause to delete to go from 4-clause to 3-clause). Commit 2f5f89963 removed the poisonous wrong clause on the grounds of moving from 4-clause to 3-clause; but did not add the missing clause, which makes it LOOK like the 2-clause version. But I think we have a decent enough trail showing the intent for 3-clause. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com>
2019-03-13slirp: remove empty state.hMarc-André Lureau2-1/+0
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190313173949.2369-1-marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-07slirp: remove QEMU Makefile.objsMarc-André Lureau1-36/+0
QEMU no longer includes it, and treats slirp/ as a separate project. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212162524.31504-8-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-07slirp: add a standalone MakefileMarc-André Lureau1-0/+47
Add a simple Makefile to build libslirp.a, a static library version of libslirp, to be used by QEMU during a transition period, until a shared library is available. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212162524.31504-6-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-07slirp: move sources to src/ subdirectoryMarc-André Lureau58-30/+30
Prepare for making slirp/ a standalone project. Remove some useless includes while at it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212162524.31504-5-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-07slirp: use "slirp_" prefix for inet_aton() win32 implementationMarc-André Lureau3-5/+5
To avoid conflict with QEMU inet_aton() implementation, let's use the "slirp_" prefix. This allows to drop the WITH_QEMU, thus the source won't make a distinction when building with QEMU or not. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212162524.31504-4-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-07slirp: use libslirp migration codeMarc-André Lureau4-47/+31
slirp migration code uses QEMU vmstate so far, when building WITH_QEMU. Introduce slirp_state_{load,save,version}() functions to move the state saving handling to libslirp side. So far, the bitstream compatibility should remain equal with current QEMU, as this is effectively using the same code, with the same format etc. When libslirp is made standalone, we will need some mechanism to ensure bitstream compatibility regardless of the libslirp version installed. See the FIXME note in the code. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212162524.31504-3-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-07slirp: adapt a subset of QEMU vmstate codeMarc-André Lureau6-0/+966
Add vmstate serialization code adapted from QEMU. Keep only the bits that are required for libslirp. Introduce a IStream/OStream interface to replace QEMU QFile abstraction. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212162524.31504-2-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-06slirp: Mark pieces missing IPv6 supportSamuel Thibault6-0/+14
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-06slirp: fix big/little endian conversion in ident protocolSamuel Thibault1-1/+3
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- Based-on: <1551476756-25749-1-git-send-email-will@wbowling.info>
2019-03-06slirp: check sscanf result when emulating identWilliam Bowling1-5/+5
When emulating ident in tcp_emu, if the strchr checks passed but the sscanf check failed, two uninitialized variables would be copied and sent in the reply, so move this code inside the if(sscanf()) clause. Signed-off-by: William Bowling <will@wbowling.info> Cc: qemu-stable@nongnu.org Cc: secalert@redhat.com Message-Id: <1551476756-25749-1-git-send-email-will@wbowling.info> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2019-03-06slirp: check for ioctlsocket error and 0-length udp payload.Vic Lee1-1/+9
Sometimes sorecvfrom() is called from slirp.c because revents == G_IO_IN, but there is 0 bytes available and recvfrom could be blocking indefinitely. This is likely due to 0-length udp payload. This also adds an error checking for ioctlsocket. Signed-off-by: Vic Lee <llyzs.vic@gmail.com> Message-Id: <20190301064809.3074-1-llyzs.vic@gmail.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-03-06slirp: Fix build with gcc 9Greg Kurz1-1/+1
Build fails with gcc 9: CC slirp/ndp_table.o slirp/ndp_table.c: In function ‘ndp_table_add’: slirp/ndp_table.c:31:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 31 | if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ slirp/ndp_table.c: In function ‘ndp_table_search’: slirp/ndp_table.c:75:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 75 | if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors The ndpentry structure isn't used to model on-the-wire data or anything else that would care for the struct layout. It doesn't need to be packed actually. Just drop SLIRP_PACKED. Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <155143315831.102868.17515265400523392682.stgit@bahia.lan> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-12slirp: wrap the remaining socket functionsMarc-André Lureau2-11/+209
QEMU wraps the socket functions in os-win32.h, but in commit a9d8b3ec4385793815d71217857304, the header inclusion was dropped, breaking libslirp on Windows. Wrap the missing functions. Rename the wrapped function with "slirp_" prefix and "_wrap" suffix, for consistency and to avoid a clash with existing function (such as "slirp_socket"). Fixes: a9d8b3ec ("slirp: replace remaining qemu headers dependency") Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212160953.29051-3-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Tested-by: Howard Spoelstra
2019-02-12slirp: remove slirp_ prefix for socket wrappersMarc-André Lureau7-34/+43
QEMU wraps the socket functions in os-win32.h, but in commit a9d8b3ec4385793815d71217857304, the header inclusion was dropped, breaking libslirp on Windows. There are already a few socket functions that are wrapped in libslirp, with "slirp_" prefix, but many of them are missing, and we are going to wrap the missing functions in a second patch. Using "slirp_" prefix avoids the conflict with socket function #define wrappers in QEMU os-win32.h, but they are quite intrusive. In the end, the functions should behave the same as original one, but with errno being set. To avoid the churn, and potential confusion, remove the "slirp_" prefix. A series of #undef is necessary until libslirp is made standalone to prevent the #define conflict with QEMU. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212160953.29051-2-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: API is extern CMarc-André Lureau1-1/+8
Make it possible to use headers easily with C++ projects. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: pass opaque to all callbacksMarc-André Lureau10-31/+33
This is friendlier for FFI bindings. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: use polling callbacks, drop glib requirementMarc-André Lureau2-49/+40
It would be legitimate to use libslirp without glib. Let's add_poll/get_revents pair of callbacks to provide the same functionality. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: remove slirp_instances listMarc-André Lureau1-5/+0
Now that polling is done per-instance, we don't need a global list of slirp instances. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: replace global polling with per-instance & notifierMarc-André Lureau2-289/+270
Remove hard-coded dependency on slirp in main-loop, and use a "poll" notifier instead. The notifier is registered per slirp instance. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: improve send_packet() callbackMarc-André Lureau4-8/+25
Use a more descriptive name for the callback. Reuse the SlirpWriteCb type. Wrap it to check that all data has been written. Return a ssize_t for potential error handling and data-loss reporting. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: prefer c99 types over BSD kindMarc-André Lureau16-70/+68
Replace: - u_char -> uint8_t - u_short -> uint16_t - u_long -> uint32_t - u_int -> unsigned - caddr_t -> char * Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: replace remaining qemu headers dependencyMarc-André Lureau28-33/+28
Except for the migration code which is gated by WITH_QEMU, only include our own headers, so libslirp can be built standalone. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/Samuel Thibault1-0/+62
Only slirp actually needs it, and will need it along in libslirp. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-02-07slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERTSamuel Thibault3-9/+9
to remove another dependency on qemu. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
2019-02-07slirp: replace qemu qtailq with slirp own copyMarc-André Lureau2-2/+194
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: replace net/eth.h inclusion with own definesMarc-André Lureau3-2/+10
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: remove now useless QEMU headers inclusionsMarc-André Lureau8-14/+0
Some of those could have been squashed earlier, but it is easier to do it all here. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: remove qemu timer.h dependencyMarc-André Lureau4-3/+2
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: add slirp own version of pstrcpyMarc-André Lureau4-3/+22
Remove a dependency on qemu util. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: improve windows headers inclusionMarc-André Lureau1-11/+11
Our API usage requires Vista, set WIN32_LEAN_AND_MEAN to fix a number of issues (winsock2.h include order for ex, which is better to include first for legacy reasons). While at it, group redundants #ifndef _WIN32 blocks. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: do not include qemu headers in libslirp.h public API headerMarc-André Lureau1-1/+11
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: move QEMU state saving to a separate unitMarc-André Lureau5-361/+418
Make state saving optional: this will allow to build SLIRP without QEMU. (eventually, the vmstate helpers will be extracted, so an external project & process could save its state) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: replace qemu_notify_event() with a callbackMarc-André Lureau6-6/+18
Introduce a SlirpCb callback to kick the main io-thread. Add an intermediary sodrop() function that will call SlirpCb.notify callback when sbdrop() returns true. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: add unregister_poll_fd() callbackMarc-André Lureau5-1/+8
Add a counter-part to register_poll_fd() for completeness. (so far, register_poll_fd() is called only on struct socket fd) Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-02-07slirp: replace qemu_set_nonblock()Marc-André Lureau5-3/+23
Replace qemu_set_nonblock() with slirp_set_nonblock() qemu_set_nonblock() does some event registration with the main loop. Add a new callback register_poll_fd() for that reason. Always build the fd-register stub, to avoid #if WIN32. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>