summaryrefslogtreecommitdiff
path: root/slirp/slirp.h
AgeCommit message (Collapse)AuthorFilesLines
2018-01-14slirp: remove unused headerPhilippe Mathieu-Daudé1-1/+0
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Tested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2017-09-24slirp: Fix intermittent send queue hangs on a socketKevin Cernekee1-1/+0
if_output() originally sent one mbuf per call and used the slirp->next_m variable to keep track of where it left off. But nowadays it tries to send all of the mbufs from the fastq, and one mbuf from each session on the batchq. The next_m variable is both redundant and harmful: there is a case[0] involving delayed packets in which next_m ends up pointing to &slirp->if_batchq when an active session still exists, and this blocks all traffic for that session until qemu is restarted. The test case was created to reproduce a problem that was seen on long-running Chromium OS VM tests[1] which rapidly create and destroy ssh connections through hostfwd. [0] https://pastebin.com/NNy6LreF [1] https://bugs.chromium.org/p/chromium/issues/detail?id=766323 Signed-off-by: Kevin Cernekee <cernekee@chromium.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2017-04-25slirp: add a fake NC-SI backendCédric Le Goater1-0/+3
NC-SI (Network Controller Sideband Interface) enables a BMC to manage a set of NICs on a system. This model takes the simplest approach and reverses the NC-SI packets to pretend a NIC is present and exercise the Linux driver. The NCSI header file <ncsi-pkt.h> comes from mainline Linux and was untabified. Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Jason Wang <jasowang@redhat.com>
2016-12-20slirp, disas: Replace min/max with MIN/MAX macrosYuval Shaia1-5/+0
Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2016-08-16slirp: Rename "struct arphdr" to "struct slirp_arphdr"Thomas Huth1-2/+2
struct arphdr is already used by the system headers on OpenBSD and thus QEMU does not compile here anymore. Fix it by renaming our struct to slirp_arphdr instead. Reported-by: Brad Smith Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-id: 1471249494-17392-1-git-send-email-thuth@redhat.com Buglink: https://bugs.launchpad.net/qemu/+bug/1613133 Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-12Clean up header guards that don't match their file nameMarkus Armbruster1-2/+2
Header guard symbols should match their file name to make guard collisions less likely. Offenders found with scripts/clean-header-guards.pl -vn. Cleaned up with scripts/clean-header-guards.pl, followed by some renaming of new guard symbols picked by the script to better ones. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
2016-06-07all: Remove unnecessary glib.h includesPeter Maydell1-1/+0
Remove glib.h includes, as it is provided by osdep.h. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2016-05-19qemu-common: stop including qemu/host-utils.h from qemu-common.hPaolo Bonzini1-0/+1
Move it to the actual users. There are some inclusions of qemu/host-utils.h in headers, but they are all necessary. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-05-16slirp: Remove some unused code from slirp.hThomas Huth1-22/+0
These hunks are apparently not used anymore, so let's delete them. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2016-05-16slirp: Remove obsolete backward-compatibility cruftThomas Huth1-28/+0
The slirp code does not use index() and gethostid() anymore, so these parts can be removed without problems. memmove() and strerror() should be available on each of the supported platforms nowadays, too, so these wrappers are also not needed anymore. And we certainly also do not support Ultrix anymore, so no need to keep the code for this platform anymore. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2016-04-15wxx: Fix broken TCP networking (regression)Stefan Weil1-5/+0
It is broken since commit c619644067f98098dcdbc951e2dda79e97560afa. Reported-by: Michael Fritscher <michael@fritscher.net> Tested-by: Michael Fritscher <michael@fritscher.net> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-04-01slirp: Allow disabling IPv4 or IPv6Samuel Thibault1-0/+2
Add ipv4 and ipv6 boolean options, so the user can setup IPv4-only and IPv6-only network environments. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Thomas Huth <thuth@redhat.com>
2016-03-23Avoid embedding struct mbuf in other structuresSamuel Thibault1-3/+5
struct mbuf uses a C99 open char array to allow inlining data. Inlining this in another structure is however a GNU extension. The inlines used so far in struct Slirp were actually only needed as head of struct mbuf lists. This replaces these inline with mere struct quehead, and use casts as appropriate. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2016-03-16slirp/slirp.h: Remove now-empty #ifdefsPeter Maydell1-24/+0
After automatic cleanup to remove unnecessary #includes of headers that osdep.h provides, slirp.h has a few now unnecessary #ifdef/#endif pairs; remove them. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-id: 1456237112-32662-2-git-send-email-peter.maydell@linaro.org
2016-03-15slirp: Adding IPv6 address for DNS relayGuillaume Subiron1-0/+1
This patch adds an IPv6 address to the DNS relay. in6_equal_dns() is developed using this Slirp attribute. sotranslate_in/out/accept() are also updated to manage the IPv6 case so the guest can be able to join the host using one of the Slirp addresses. For now this only points to localhost. Further development will be needed to automatically fetch the IPv6 address from resolv.conf, and announce this via RDNSS. Signed-off-by: Guillaume Subiron <maethor@subiron.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Thomas Huth <thuth@redhat.com>
2016-03-15slirp: Generalizing and neutralizing various TCP functions before adding ↵Guillaume Subiron1-2/+3
IPv6 stuff Basically, this patch adds some switch in various TCP functions to prepare them for the IPv6 case. To have something to "switch" in tcp_input() and tcp_respond(), a new argument is used to give them the sa_family of the addresses they are working on. This patch does not include the entailed reindentation, to make proofread easier. Reindentation is adressed in the following no-op patch. Signed-off-by: Guillaume Subiron <maethor@subiron.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Thomas Huth <thuth@redhat.com>
2016-03-15slirp: Adding IPv6, ICMPv6 Echo and NDP autoconfigurationGuillaume Subiron1-0/+37
This patch adds the functions needed to handle IPv6 packets. ICMPv6 and NDP headers are implemented. Slirp is now able to send NDP Router or Neighbor Advertisement when it receives Router or Neighbor Solicitation. Using a 64bit-sized IPv6 prefix, the guest is now able to perform stateless autoconfiguration (SLAAC) and to compute its IPv6 address. This patch adds an ndp_table, mainly inspired by arp_table, to keep an NDP cache and manage network address resolution. Slirp regularly sends NDP Neighbor Advertisement, as recommended by the RFC, to make the guest refresh its route. This also adds ip6_cksum() to compute ICMPv6 checksums using IPv6 pseudo-header. Some #define ETH_* are moved upper in slirp.h to make them accessible to other slirp/*.h Signed-off-by: Guillaume Subiron <maethor@subiron.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Thomas Huth <thuth@redhat.com>
2016-03-10osdep: add wrappers for socket functionsDaniel P. Berrange1-2/+0
The windows socket functions look identical to the normal POSIX sockets functions, but instead of setting errno, the caller needs to call WSAGetLastError(). QEMU has tried to deal with this incompatibility by defining a socket_error() method that callers must use that abstracts the difference between WSAGetLastError() and errno. This approach is somewhat error prone though - many callers of the sockets functions are just using errno directly because it is easy to forget the need use a QEMU specific wrapper. It is not always immediately obvious that a particular function will in fact call into Windows sockets functions, so the dev may not even realize they need to use socket_error(). This introduces an alternative approach to portability inspired by the way GNULIB fixes portability problems. We use a macro to redefine the original socket function names to refer to a QEMU wrapper function. The wrapper function calls the original Win32 sockets method and then sets errno from the WSAGetLastError() value. Thus all code can simply call the normal POSIX sockets APIs are have standard errno reporting on error, even on Windows. This makes the socket_error() method obsolete. We also bring closesocket & ioctlsocket into this approach. Even though they are non-standard Win32 names, we can't wrap the normal close/ioctl methods since there's no reliable way to distinguish between a file descriptor and HANDLE in Win32. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-02-23all: Clean up includesPeter Maydell1-18/+0
Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com>
2016-02-04slirp: Adding family argument to tcp_fconnect()Guillaume Subiron1-1/+1
This patch simply adds a unsigned short family argument to remove the hardcoded "AF_INET" in the call of qemu_socket(). This prepares for IPv6 support. Signed-off-by: Guillaume Subiron <maethor@subiron.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
2016-01-11ether/slirp: Avoid redefinition of the same constantsDr. David Alan Gilbert1-6/+1
eth.h and slirp.h both define ETH_ALEN and ETH_P_IP rtl8139.c and eth.h both define ETH_HLEN Move the related constant (ETH_P_ARP) from slirp.h to eth.h, and remove the duplicates; make slirp.h include eth.h Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Jason Wang <jasowang@redhat.com>
2014-04-25slirp: Remove default_mon usageCole Robinson1-2/+0
These errors don't seem user initiated, so forcibly printing to the monitor doesn't seem right. Just use error_report. Drop lprint since it's now unused. Cc: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-09-17slirp: make timeout localLiu Ping Fan1-0/+3
Each slirp has its own time to caculate timeout. Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2013-01-12slirp: remove unused field ttBlue Swirl1-1/+0
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-15slirp: Add domain-search option to slirp's DHCP serverKlaus Stengel1-0/+5
This patch will allow the user to include the domain-search option in replies from the built-in DHCP server. The domain suffixes can be specified by adding dnssearch= entries to the "-net user" parameter. [Jan: tiny style adjustments] Signed-off-by: Klaus Stengel <Klaus.Stengel@asamnet.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-04-15w32: Move defines for socket specific errors to qemu-os-win32.hStefan Weil1-12/+0
As those defines are only used for w32, they should be in the header file for w32. All files which include slirp.h or qemu_socket.h also include qemu-os-win32.h. Signed-off-by: Stefan Weil <sw@weilnetz.de>
2012-03-28w32/slirp: Undefine error constants before their redefinitionJan Kiszka1-0/+6
Less warnings for your console. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-03-28slirp: clean up conflicts with system headersPaolo Bonzini1-7/+1
Right now, slirp/slirp.h cannot include some system headers and, indirectly, qemu_socket.h. Clean this up, and remove a duplicate prototype that was introduced because of that. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-03-13slirp: Cleanup resources on instance removalJan Kiszka1-0/+2
Close & free sockets when shutting down a slirp instance, also release all buffers. CC: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-03-13slirp: Remove unneeded if_queuedJan Kiszka1-1/+0
There is now a trivial check on entry of if_start for pending packets, so we can drop the additional tracking via if_queued. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-03-13slirp: Prevent recursion of if_startJan Kiszka1-0/+1
if_start can be called recursively via if_encap. Avoid this as our scheme of dequeuing packets is not compatible with this. CC: Fabien Chouteau <chouteau@adacore.com> CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> CC: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2011-09-03Use new macro QEMU_PACKED for packed structuresStefan Weil1-1/+1
Most changes were made using these commands: git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/' git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/' git grep -la '__attribute__((__packed__))'|xargs perl -pi -e 's/__attribute__\(\(__packed__\)\)/QEMU_PACKED/' git grep -la '__attribute__ ((__packed__))'|xargs perl -pi -e 's/__attribute__ \(\(__packed__\)\)/QEMU_PACKED/' git grep -la '__attribute((packed))'|xargs perl -pi -e 's/__attribute\(\(packed\)\)/QEMU_PACKED/' Whitespace in linux-user/syscall_defs.h was fixed manually to avoid warnings from scripts/checkpatch.pl. Manual changes were also applied to hw/pc.c. I did not fix indentation with tabs in block/vvfat.c. The patch will show 4 errors with scripts/checkpatch.pl. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-05slirp: Fix types of IP address parametersJan Kiszka1-2/+2
Should be uint32_t for IPv4, not int. Also avoid in_addr_t without proper includes. Fixes build regression on mingw32. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2011-08-03Simple ARP tableFabien Chouteau1-3/+44
This patch adds a simple ARP table in Slirp and also adds handling of gratuitous ARP requests. Signed-off-by: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2011-07-23slirp: Forward ICMP echo requests via unprivileged socketsJan Kiszka1-0/+5
Linux 3.0 gained support for unprivileged ICMP ping sockets. Use this feature to forward guest pings to the outer world. The host admin has to set the ping_group_range in order to grant access to those sockets. To allow ping for the users group (GID 100): echo 100 100 > /proc/sys/net/ipv4/ping_group_range Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-01-23Delete useless 'extern' qualifiers for functionsBlue Swirl1-1/+1
'extern' qualifier is useless for function declarations. Delete them. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-11-21slirp: Remove unused code for bad sprintfStefan Weil1-14/+0
Neither DECLARE_SPRINTF nor BAD_SPRINTF are needed for QEMU. QEMU won't support systems with missing or bad declarations for sprintf. The unused code was detected while looking for functions with missing format checking. Instead of adding GCC_FMT_ATTR, the unused code was removed. Cc: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-10-03Use GCC_FMT_ATTR (format checking)Stefan Weil1-1/+1
Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-10-03slirp: Silence warning on HaikuAndreas Färber1-1/+3
Haiku has O_BINARY in fcntl.h. Signed-off-by: Andreas Färber <andreas.faerber@web.de> Cc: Jan Kiszka <jan.kiszka@web.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-25slirp: Remove declarations which are no longer neededStefan Weil1-33/+0
The previous patches replaced u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types from stdint.h, so we can now remove their declarations which are no longer needed. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-07-25slirp: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int typesStefan Weil1-3/+3
There is no need to have a second set of integral types. Replace them by the standard types from stdint.h. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-03Don't leak file descriptorsKevin Wolf1-0/+4
We're leaking file descriptors to child processes. Set FD_CLOEXEC on file descriptors that don't need to be passed to children to stop this misbehaviour. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-12Fix sys-queue.h conflict for goodBlue Swirl1-2/+2
Problem: Our file sys-queue.h is a copy of the BSD file, but there are some additions and it's not entirely compatible. Because of that, there have been conflicts with system headers on BSD systems. Some hacks have been introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-27slirp: Use monotonic clock if available (v2)Ed Swierk1-4/+0
Calling gettimeofday() to compute a time interval can cause problems if the system clock jumps forwards or backwards; replace updtime() with qemu_get_clock(rt_clock), which calls clock_gettime(CLOCK_MONOTONIC) if it is available. Also remove some useless macros. Signed-off-by: Ed Swierk <eswierk@aristanetworks.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-01Fix breakage by obsolete _P() for goodBlue Swirl1-44/+37
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-06-29slirp: Enable multiple instancesJan Kiszka1-0/+4
Once again this was a long journey to reach the destination: Allow to instantiate slirp multiple times. But as in the past, the journey was worthwhile, cleaning up, fixing and enhancing various parts of the user space network stack along the way. What is this particular change good for? Multiple slirps instances allow separated user space networks for guests with multiple NICs. This is already possible, but without any slirp support for the second network, ie. without a chance to talk to that network from the host via IP. We have a legacy guest system here that benefits from this slirp enhancement, allowing us to run both of its NICs purely over unprivileged user space IP stacks. Another benefit of this patch is that it simply removes an artificial restriction of the configuration space qemu is providing, avoiding another source of surprises that users may face when playing with possible setups. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Allocate/free stack instance dynamicallyJan Kiszka1-1/+1
Allocate the internal slirp state dynamically and provide and call slirp_cleanup to properly release it after use. This patch finally unbreaks slirp release and re-instantiation via host_net_* monitor commands. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Use internal state in interfaceJan Kiszka1-0/+1
This now also exports the internal state to the slirp users in qemu, returning it from slirp_init and expecting it along with service invocations. Additionally provide an opaque value interface for the callbacks from slirp into the qemu core. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Factor out internal state structureJan Kiszka1-6/+60
The essence of this patch is to stuff (almost) all global variables of the slirp stack into the structure Slirp. In this step, we still keep the structure as global variable, directly accessible by the whole stack. Changes to the external interface of slirp will be applied in the following patches. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>