summaryrefslogtreecommitdiffstats
path: root/slirp
Commit message (Collapse)AuthorAgeFilesLines
...
* slirp: add unregister_poll_fd() callbackMarc-André Lureau2019-02-075-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>
* slirp: replace qemu_set_nonblock()Marc-André Lureau2019-02-075-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>
* slirp: replace most qemu socket utilities with slirp own versionMarc-André Lureau2019-02-078-36/+274
| | | | | | | | qemu_set_nonblock() is slightly more problematic and will be dealt with in a separate patch. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace QEMU_PACKED with SLIRP_PACKEDMarc-André Lureau2019-02-074-10/+43
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace trace functions with DEBUG callsMarc-André Lureau2019-02-074-11/+15
| | | | | | | | Remove a dependency on QEMU. Use the existing logging facilities. Set SLIRP_DEBUG=tftp to get tftp log. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: add callbacks for timerMarc-André Lureau2019-02-073-13/+19
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: generalize guestfwd with a callback based approachMarc-André Lureau2019-02-076-28/+65
| | | | | | | | | Instead of calling into QEMU chardev directly, and mixing it with slirp_add_exec() handling, add a new function slirp_add_guestfwd() which takes a write callback. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: Don't mark struct ipq or struct ipasfrag as packedPeter Maydell2019-02-071-2/+5
| | | | | | | | | | | | | | | | | | | | There is no reason to mark the struct ipq and struct ipasfrag as packed: they are naturally aligned anyway, and are not representing any on-the-wire packet format. Indeed they vary in size depending on the size of pointers on the host system, because the 'struct qlink' members include 'void *' fields. Dropping the 'packed' annotation fixes clang -Waddress-of-packed-member warnings and probably lets the compiler generate better code too. The only thing we do care about in the layout of the struct is that the frag_link matches up with the ipf_link of the struct ipasfrag, as documented in the comment on that struct; assert at build time that this is the case. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: Avoid marking naturally packed structs as QEMU_PACKEDPeter Maydell2019-02-072-7/+25
| | | | | | | | | | | | | | Various ipv6 structs in the slirp headers are marked QEMU_PACKED, but they are actually naturally aligned and will have no padding in them. Instead of marking them with the 'packed' attribute, assert at compile time that they are the size we expect. This allows us to take the address of fields within the structs without risking undefined behaviour, and suppresses clang -Waddress-of-packed-member warnings. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: Avoid unaligned 16bit memory accessSamuel Thibault2019-02-071-1/+1
| | | | | | | | | pkt parameter may be unaligned, so we must access it byte-wise. This fixes sparc64 host SIGBUS during pxe boot. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* slirp: check data length while emulating ident functionPrasad J Pandit2019-01-141-0/+5
| | | | | | | | | | While emulating identification protocol, tcp_emu() does not check available space in the 'sc_rcv->sb_data' buffer. It could lead to heap buffer overflow issue. Add check to avoid it. Reported-by: Kira <864786842@qq.com> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: Mark debugging calls as unlikelySamuel Thibault2019-01-141-4/+4
| | | | | | | to get them out of the hot path. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* slirp: call into g_debug() for DEBUG macrosMarc-André Lureau2019-01-1411-53/+39Star
| | | | | | | | | | | | | Make slirp use GLib logging, instead of fprintf(), so that applications can filter log, process it etc. With recent versions of glib, G_MESSAGES_DEBUG must be set to "all" or "Slirp" to see slirp debug messages. Reformat DEBUG_MISC & DEBUG_ERROR calls to not need \n ending. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: set G_LOG_DOMAINMarc-André Lureau2019-01-141-0/+2
| | | | | | | | We are moving to g_log() facilities to log errors and probably debug messages too. Let's have the "Slirp" prefix on messages slirp produces. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* build-sys: use a separate slirp-obj-y && slirp.moMarc-André Lureau2019-01-141-5/+30
| | | | | | | | | | | | | This will allow to have cflags for the whole slirp.mo -objs. It makes it possible to build tests that links only with slirp-obj-y (and not the whole common-obj). It is also a step towards building slirp as a shared library, although this requires a bit more thoughts to build with net/slirp.o (CONFIG_SLIRP would need to be 'm') and other build issues. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: add clock_get_ns() callbackMarc-André Lureau2019-01-144-10/+10
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: factor out guestfwd addition checksMarc-André Lureau2019-01-142-9/+21
| | | | | | | This will allow reusing the function in a following patch. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace DEBUG_ARGS with DEBUG_ARGMarc-André Lureau2019-01-146-27/+25Star
| | | | | | | | There is no clear benefit in calling an alias DEBUG_ARGS(). Replace calls with DEBUG_ARG(), and fix the white-spacing while at it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove remaining DEBUG blocksMarc-André Lureau2019-01-143-11/+3Star
| | | | | | | | Instead, rely on slirp_debug flags, or compile unconditionally (the substraction in cksum is unlikely to affect any benchmark result). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: use %p for pointers formatMarc-André Lureau2019-01-144-7/+7
| | | | | | | This fixes some compilation warnings on mingw64. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: introduce SLIRP_DEBUG environment variableMarc-André Lureau2019-01-142-8/+15
| | | | | | | | Learn to read SLIRP_DEBUG=call,misc,error (all or help also handled) to set the slirp_debug flags. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: always build with debug statementsMarc-André Lureau2019-01-142-13/+8Star
| | | | | | | | | Make debug statements condiitonal only on slirp_debug flags, instead of the pre-processor DEBUG blocks, as it may introduce breakage easily, since the debug code isn't always compiled. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: no need to make DPRINTF conditional on DEBUGMarc-André Lureau2019-01-141-5/+2Star
| | | | | | | DEBUG_CALL is already handled conditionally. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace a DEBUG block with WITH_ICMP_ERROR_MSGMarc-André Lureau2019-01-141-3/+5
| | | | | | | | | icmp_send_error() doesnt actually log messages when DEBUG is enabled. Let's use a different define that describes better the tweaked behaviour of the function, and avoid uncompiled code. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace some fprintf() with DEBUG_MISCMarc-André Lureau2019-01-141-11/+6Star
| | | | | | | Remove some clutter, and avoids direct call to fprintf(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace a fprintf with g_critical()Marc-André Lureau2019-01-141-1/+1
| | | | | | | | Reduce dependency on QEMU. QEMU could use a custom glib log handler if it wants to redirect/filter it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: use virtual time for packet expirationMarc-André Lureau2019-01-142-4/+5
| | | | | | | | Make all packets expiration time based on virtual clock. 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>
* slirp: rename exec_listMarc-André Lureau2019-01-146-21/+21
| | | | | | | | | This list is not only used to handle command to execute on guest connection, it can also redirect to an arbitrary object, such as a chardev. Let's rename the struct and the field to "guestfwd". Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: drop <Vista compatibilityMarc-André Lureau2019-01-142-14/+10Star
| | | | | | | | | | | | | | | | Since commit 12f8def0e02232d7c6416ad9b66640f973c531d1 (v2.9), qemu requires Vista. Let's remove some conditional code. Note that this introduces a missing declaration warning with mingw. warning: implicit declaration of function 'inet_ntop' See also: https://sourceforge.net/p/mingw-w64/mailman/message/36473782/ We could workaround it by declaring it ourself depending on __MINGW64_VERSION_*: WINSOCK_API_LINKAGE INT WSAAPI inet_pton(int Family, PCTSTR pszAddrString, PVOID pAddrBuf); Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: Enable fork_exec support on WindowsSamuel Thibault2019-01-141-12/+2Star
| | | | | | | | | | | g_spawn_async_with_fds is portable on Windows, so we can now enable fork_exec support there. Thanks Daniel P. Berrangé for the notice! Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* slirp: replace error_report() with g_critical()Marc-André Lureau2019-01-141-1/+1
| | | | | | | | Reduce dependency on QEMU. QEMU could use a custom log handler if it wants to redirect/filter it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: simplify fork_exec()Marc-André Lureau2019-01-141-39/+36Star
| | | | | | | | | Use g_spawn_async_with_fds() to setup the child. GSpawn handles reaping the child, and closing parent file descriptors. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace ARRAY_SIZE with G_N_ELEMENTSMarc-André Lureau2019-01-142-3/+3
| | | | | | | | | Do not require QEMU macro. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove dead TCP_ACK_HACK codeMarc-André Lureau2019-01-141-22/+1Star
| | | | | | | | Untouched since original introduction in 2004. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: NULL is defined by stddef.hMarc-André Lureau2019-01-141-4/+0Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove unused sbflush()Marc-André Lureau2019-01-141-1/+0Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove #if notdef dead codeMarc-André Lureau2019-01-142-239/+0Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: add a callback to log guest errorsMarc-André Lureau2019-01-143-7/+8
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: improve a bit the debug macrosMarc-André Lureau2019-01-1416-85/+109
| | | | | | | | Let them accept multiple arguments. Simplify the inner argument handling of DEBUG_ARGS/DEBUG_MISC_DEBUG_ERROR. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace error_report() with g_critical()Marc-André Lureau2019-01-143-5/+5
| | | | | | | | Reduce dependency on QEMU. QEMU could use a custom log handler if it wants to redirect/filter it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove unused global slirp_instanceMarc-André Lureau2019-01-141-2/+0Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace compile time DO_KEEPALIVEMarc-André Lureau2019-01-145-17/+8Star
| | | | | | | Use a global variable instead (similar to slirp_debug) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace SIZEOF_CHAR_P with glib equivalentMarc-André Lureau2019-01-142-4/+1Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: replace HOST_WORDS_BIGENDIAN with glib equivalentMarc-André Lureau2019-01-145-11/+13
| | | | | | | | | One more step towards making the project independent from QEMU. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove unused HAVE_INET_ATONMarc-André Lureau2019-01-141-6/+0Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove unused DECLARE_IOVECMarc-André Lureau2019-01-141-6/+0Star
| | | | | | | | | | It's actually qemu configure CONFIG_IOVEC that is being used. slirp/ does not use it anyway Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove HAVE_SYS_FILIO_HMarc-André Lureau2019-01-142-7/+1Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove HAVE_SYS_IOCTL_HMarc-André Lureau2019-01-142-7/+1Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove unused HAVE_SYS_SELECT_HMarc-André Lureau2019-01-143-14/+0Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* slirp: remove unused HAVE_SYS_WAIT_HMarc-André Lureau2019-01-142-7/+0Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>