aboutsummaryrefslogtreecommitdiff
path: root/slirp
Commit message (Collapse)AuthorAgeFilesLines
* slirp: fix unmatched bracket in if 0Michael S. Tsirkin2009-09-301-2/+0
| | | | | | | Fix unmatched bracket in commented out code Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix sys-queue.h conflict for goodBlue Swirl2009-09-122-10/+10
| | | | | | | | | | | | | | | 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>
* Fix Sparse warnings: add "static"Blue Swirl2009-09-051-1/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix compiler warningsStefan Weil2009-08-311-2/+2
| | | | | | | | | | | | | | | | | | | | Starting with commit df7a86ed735eafefbd046c8cad7134652fe3f600, mingw32 builds result in a compiler warning for dns_addr: CC slirp/slirp.o /home/stefan/src/qemu/savannah/qemu/slirp/slirp.c:50: warning: missing braces around initializer /home/stefan/src/qemu/savannah/qemu/slirp/slirp.c:50: warning: (near initialization for ‘dns_addr.S_un’) Removing the assignment fixes the warning without the need of special code for mingw32 (and also saves some bytes in the resulting binary). To fix another potential compiler warning, the missing 'static' attribute was added. The same changes were applied to dns_addr_time. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* slirp: Read host DNS config on demandEd Swierk2009-08-276-14/+44
| | | | | | | | | | | | | | | | | Currently the qemu user-mode networking stack reads the host DNS configuration (/etc/resolv.conf or the Windows equivalent) only once when qemu starts. This causes name lookups in the guest to fail if the host is moved to a different network from which the original DNS servers are unreachable, a common occurrence when the host is a laptop. This patch changes the slirp code to read the host DNS configuration on demand, caching the results for at most 1 second to avoid unnecessary overhead if name lookups occur in rapid succession. On non-Windows hosts, /etc/resolv.conf is re-read only if the file has been replaced or if its size or mtime has changed. Signed-off-by: Ed Swierk <eswierk@aristanetworks.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Remove our_addr codeEd Swierk2009-08-272-18/+0
| | | | | | | | | | | | | | | | | | | | | Three problems with our_addr: - It's determined only once when qemu starts, but the address can change (just like the DNS configuration can). - It's supposed to be the IP address of a host network interface, but there's no guarantee that gethostbyname(gethostname()) actually does that: the host might be a laptop that has only a loopback interface up, or the hostname might be localhost.localdomain, etc. - It's useless at best: get_dns_addr() calls it, there's no reason to send DNS requests to a different IP address if you're running a DNS server on the host and resolv.conf points to 127.0.0.1. These problems are easily solved by removing the code. Signed-off-by: Ed Swierk <eswierk@aristanetworks.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Add missing "static"Blue Swirl2009-08-011-1/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* More NULL pointer fixesBlue Swirl2009-08-011-4/+6
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* rename WORDS_BIGENDIAN to HOST_WORDS_BIGENDIANJuan Quintela2009-07-273-5/+5
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Use monotonic clock if available (v2)Ed Swierk2009-07-273-32/+2
| | | | | | | | | | | | 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>
* slirp: Remove UDP protocol emulation (talk, cuseeme)Ed Swierk2009-07-273-272/+2
| | | | | | | | | | The UDP emulation code for talk has been commented out since the beginning of time, and unless someone who runs CU-SeeMe on qemu with user-mode networking can vouch that the special magic (a) is necessary and (b) works, let's get rid of the code. Signed-off-by: Ed Swierk <eswierk@aristanetworks.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Fix guestfwd for incoming dataJan Kiszka2009-07-272-8/+8
| | | | | | | | | Unless a virtual server address was explicitly defined (which is impossible with the legacy -net channel format), guestfwd did not properly forwarded host->guest packets. This patch fixes it. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix breakage by obsolete _P() for goodBlue Swirl2009-07-018-99/+92
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* slirp: tftp: Relax filename format checkJan Kiszka2009-06-291-3/+5
| | | | | | | | | [ Applies on top of my recently posted slirp series. ] Allow tftp requests with filenames that do not start with a slash. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Save/restore bootp client statesJan Kiszka2009-06-291-1/+27
| | | | | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Enable multiple instancesJan Kiszka2009-06-292-9/+18
| | | | | | | | | | | | | | | | | | | | | | | 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>
* slirp: Allocate/free stack instance dynamicallyJan Kiszka2009-06-294-15/+21
| | | | | | | | | | 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>
* slirp: Use internal state in interfaceJan Kiszka2009-06-295-43/+44
| | | | | | | | | | 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>
* slirp: Factor out internal state structureJan Kiszka2009-06-2929-408/+479
| | | | | | | | | | | 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>
* slirp: Drop link_up checks from if_output and slirp_socket_can_recvJan Kiszka2009-06-292-7/+1
| | | | | | | | link_up is true once slirp is initialized, so these check are really not required. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Clean up timeout handling around slirp_select_fill/pollJan Kiszka2009-06-293-39/+4
| | | | | | | Again lot of dead code. Remove it. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Kill slirp_is_initedJan Kiszka2009-06-292-8/+26
| | | | | | | | | Avoid the need for slirp_is_inited by refactoring the protected slirp_select_* functions. This also avoids the clearing of all fd sets on select errors. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Clean up updtimeJan Kiszka2009-06-292-9/+5
| | | | | | | | Drop redundant typecasts in both variants and remove the pointless round-up in the UNIX version. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Make IP packet ID consistentJan Kiszka2009-06-292-2/+7
| | | | | | | | | | | Currently, ip_id is always initialized to 0 on slirp startup (despite the broken attempt to derive it from the clock). This is good for reproducibility. But it is not preserved across save/restore. This patch therefore drops the dead initialization code from ip_init and introduces ip_id to the persistent slirp state. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Factor out one-time initializationJan Kiszka2009-06-293-37/+41
| | | | | | | | | | | | In order to prepare re-initialization and multi-instance slirp, factor out init code that is of global scope and (at least for now) only need to be run once. This also fixes the potentially uninitialized use of our_addr in get_dns_addr. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: tftp: Rework filename handlingJan Kiszka2009-06-291-22/+16
| | | | | | | | | This changes the filename handling from a static buffer in tftp_session for the client-provided name + prefix to a dynamically allocated buffer that keeps the combined path in one place. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: tftp: Refactor tftp_handle_rrqJan Kiszka2009-06-291-28/+21
| | | | | | | | Specifically make the filename extraction more readable, and always report errors back to the client. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: tftp: Clean up tftp_send_errorJan Kiszka2009-06-291-8/+5
| | | | | | | | The return code of tftp_send_error is not used, drop it. And also make sure to always terminate the session. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: tftp: Cleanup tftp_prefix checkJan Kiszka2009-06-291-8/+7
| | | | | | | | Perform check for set prefix early (if it's not given, tftp is disabled) and drop redundant second check. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Drop unused icmp_var.hJan Kiszka2009-06-292-50/+0
| | | | | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Cleanup and basic reanimation of debug codeJan Kiszka2009-06-296-25/+13
| | | | | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Drop statistic codeJan Kiszka2009-06-2918-476/+6
| | | | | | | | | As agreed on the mailing list, there is no interest in keeping the usually disabled slirp statistics in the tree. So this patch removes them. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Drop dead codeJan Kiszka2009-06-2926-1650/+22
| | | | | | | | | | After all its years inside the qemu tree, there is no point in keeping the dead code paths of slirp. This patch is a first round of removing usually commented out code parts. More cleanups need to follow (and maybe finally a proper reindention). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Add info usernet for dumping connection statesJan Kiszka2009-06-295-55/+90
| | | | | | | | | Break out sockstats from the slirp statistics and present them under the new info category "usernet". This patch also improves the current output /wrt proper reporting connection source and destination. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Mark sockets of incoming TCP connectionsJan Kiszka2009-06-292-0/+2
| | | | | | | Required for pretty-printing. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Do not allow to remove non-hostfwd socketsJan Kiszka2009-06-291-9/+5
| | | | | | | | | Prevent that the users accidentally shoots down dynamic sockets. This allows to remove looping for removals as there can now only be one match. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Explicitely mark host-forwarding socketsJan Kiszka2009-06-293-3/+4
| | | | | | | | Mark sockets that describe host forwardings. This is required for their (and only their) proper deletion and for pretty-printing. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Prepare for persistent socket state flagsJan Kiszka2009-06-295-13/+26
| | | | | | | | This prepares for adding flags to socket.so_state that must not be removed during the lifetime of a socket. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Bind support for host forwarding rulesJan Kiszka2009-06-297-25/+27
| | | | | | | | | Extend the hostfwd rule format so that the user can specify on which host interface qemu should listen for incoming connections. If omitted, binding will takes place against all interfaces. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Fix port comparision in slirp_remove_hostfwdJan Kiszka2009-06-291-2/+6
| | | | | | | | | For UDP host forwardings, fport is not stable, every outgoing packet of the redirection can modify it. Use getsockname instead to look up the port that is actually used on the host side. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Rework external configuration interfaceJan Kiszka2009-06-293-39/+38
| | | | | | | | | | | | | With the internal IP configuration made more flexible, we can now enhance the user interface. This patch adds a number of new options to "-net user": net (address and mask), host, dhcpstart, dns and smbserver. It also renames "redir" to "hostfwd" and "channel" to "guestfwd" in order to (hopefully) clarify their meanings. The format of guestfwd is extended so that the user can define not only the port but also the virtual server's IP address the forwarding starts from. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Rework internal configurationJan Kiszka2009-06-2913-142/+149
| | | | | | | | | | | | | The user mode IP stack is currently only minimally configurable /wrt to its virtual IP addresses. This is unfortunate if some guest has a fixed idea of which IP addresses to use. Therefore this patch prepares the stack for fully configurable IP addresses and masks. The user interface and default addresses remain untouched in this step, they will be enhanced in the following patch. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Move smb, redir, tftp and bootp parameters and -net channelJan Kiszka2009-06-295-6/+19
| | | | | | | | | | | | | | | | | So far a couple of slirp-related parameters were expressed via stand-alone command line options. This it inconsistent and unintuitive. Moreover, it prevents both dynamically reconfigured (host_net_add/ delete) and multi-instance slirp. This patch refactors the configuration by turning -smb, -redir, -tftp and -bootp as well as -net channel into options of "-net user". The old stand-alone command line options are still processed, but no longer advertised. This allows smooth migration of management applications to to the new syntax and also the extension of that syntax later in this series. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Revert "User networking: Show active connections"Jan Kiszka2009-06-292-28/+0
| | | | | | | | | | | | | | | This reverts commit 1c6ed9f3379faac83da0ed3e95cbd49003ac0dd1. It's redundant to slirp statistics, which are going to be split up / reworked later on. Conflicts: monitor.c net.c Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Refactor tcp_ctlJan Kiszka2009-06-291-79/+30
| | | | | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Drop redundant lines from udp_inputJan Kiszka2009-06-291-2/+0
| | | | | | | | The socket faddr/fport is already updated a few lines below, so these are completely redundant. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix mingw32 build warningsBlue Swirl2009-06-132-2/+11
| | | | | | | | Work around buffer and ioctlsocket argument type signedness problems Suppress a prototype which is unused on mingw32 Expand a macro to avoid warnings from some GCC versions Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* slirp: Reorder initializationJan Kiszka2009-06-092-2/+2
| | | | | | | | | | | | | This patch reorders the initialization of slirp itself as well as its associated features smb and redirection. So far the first reference to slirp triggered the initialization, independent of the actual -net user option which may carry additional parameters. Now we save any request to add a smb export or some redirections until the actual initialization of the stack. This also allows to move a few parameters that were passed via global variable into the argument list of net_slirp_init. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
* User networking: Show active connectionsAlexander Graf2009-05-282-0/+28
| | | | | | | | | | | | | In case you're wondering what connections exactly you have open or maybe redir'ed in the past, you can't really find out from qemu right now. This patch enables you to see all current connections the host only networking holds open, so you can kill them using the previous patch. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* User Networking: Enable removal of redirectionsAlexander Graf2009-05-272-0/+24
| | | | | | | | | | | | | Using the new host_net_redir command you can easily create redirections on the fly while your VM is running. While that's great, it's missing the removal of redirections, in case you want to have a port closed again at a later point in time. This patch adds support for removal of redirections. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>