summaryrefslogtreecommitdiffstats
path: root/slirp
Commit message (Collapse)AuthorAgeFilesLines
* slirp: Implement TFTP Blocksize optionHervé Poussineau2012-09-141-9/+33
| | | | | | | | | | | | | | | | | | | This option is described in RFC 1783. As this is only an optional field, we may ignore it in some situations and handle it in some others. However, MS Windows 2003 PXE boot client requests a block size of the MTU (most of the times 1472 bytes), and doesn't work if the option is not acknowledged (with whatever value). According to the RFC 1783, we cannot acknowledge the option with a bigger value than the requested one. As current implementation is using 512 bytes by block, accept the option with a value of 512 if the option was specified, and don't acknowledge it if it is not present or less than 512 bytes. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Remove unused return value of tftp_send_next_blockJan Kiszka2012-09-131-9/+5
| | | | | | No caller actually makes use of this value, so let's simplify the code. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Handle more than 65535 blocks in TFTP transfersHervé Poussineau2012-09-132-14/+11
| | | | | | | | | | RFC 1350 does not mention block count roll-over. However, a lot of TFTP servers implement it to be able to transmit big files, so do it also. Current block size is 512 bytes, so TFTP files were limited to 32 MB. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: improve TFTP performanceHervé Poussineau2012-09-132-14/+19
| | | | | | | | | When transferring a file, keep it open during the whole transfer, instead of opening/closing it for each block. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Fix error reported by static code analysisStefan Weil2012-09-131-1/+1
| | | | | | | | | | | | Report from smatch: slirp/tcp_subr.c:127 tcp_respond(17) error: we previously assumed 'tp' could be null (see line 124) Return if 'tp' is NULL. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Remove wrong type casts ins debug statementsStefan Weil2012-09-131-3/+3
| | | | | | | | The type casts of pointers to long are not allowed when sizeof(pointer) != sizeof(long). Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: fix build on mingw32Anthony Liguori2012-08-062-2/+2
| | | | | | | | | in_addr_t isn't available on mingw32. Just use an unsigned long instead. I considered typedef'ing in_addr_t on mingw32 but this would potentially be brittle if mingw32 did introduce the type. Cc: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Handle whole 127.0.0.0/8 network as local addresses.Anders Waldenborg2012-08-033-2/+9
| | | | | | | | | | | Changes so translation of remote address to the host's ip address in the virtual network happens for all addresses in the 127.0.0.0/8 network, not just 127.0.0.1. This fixes so that hostfwd bound to addresses such as 127.0.0.2 works. Signed-off-by: Anders Waldenborg <anders@0x63.nu> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* net: determine if packets can be sent before net queue deliver packetsZhi Yong Wu2012-08-012-6/+0
| | | | | | | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* build: move slirp/ objects to nested Makefile.objsPaolo Bonzini2012-06-071-0/+3
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* slirp: Avoid redefining MAX_TCPOPTLENAndreas Färber2012-05-281-0/+1
| | | | | | | | | | | | | MAX_TCPOPTLEN is being defined as 32. Darwin already has it as 40, causing a warning. The value is only used to declare an array, into which currently 4 bytes are written at most. Therefore always override MAX_TCPOPTLEN for now. Suggested-by: Jan Kiszka <jan.kiszka@web.de> Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Avoid statements without effect on Big Endian hostAndreas Färber2012-05-281-12/+8
| | | | | | | | | | | | Darwin has HTON*/NTOH* macros that on BE simply return the argument. This is incompatible with SLIRP's use of these macros as a statement. Undefine the macros in the HOST_WORDS_BIGENDIAN code path to redefine these macros as no-op, as already done when they were undefined. Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Untangle TCPOLEN_* from TCPOPT_*Andreas Färber2012-05-281-5/+8
| | | | | | | | | | | | | Commit b72210568ef0c0fb141a01cffb71a09c4efa0364 (slirp: clean up conflicts with system headers) enclosed TCPOLEN_MAXSEG with an #ifdef TCPOPT_EOL. This broke the build on illumos, which has TCPOPT_* but not TCPOLEN_*. Move them to their own #ifdef TCPOLEN_MAXSEG section to remedy this. Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* main_loop_wait: block indefinitelyStefano Stabellini2012-04-262-0/+8
| | | | | | | | | | | | | | | - remove qemu_calculate_timeout; - explicitly size timeout to uint32_t; - introduce slirp_update_timeout; - pass NULL as timeout argument to select in case timeout is the maximum value; Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Paul Brook <paul@codesourcery.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* w32: Move defines for socket specific errors to qemu-os-win32.hStefan Weil2012-04-151-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>
* slirp: Signal free input buffer space to io-threadJan Kiszka2012-03-301-0/+6
| | | | | | | | | | | | This massively accelerates slirp reception speed: If data arrives faster than the guest can read it from the input buffer, the file descriptor for the corresponding socket was taken out of the fdset for select. However, the event of the guest reading enough data from the buffer was not signaled. Thus, the io-thread only noticed this change on the next time-driven poll. Fix this by kicking the io-thread as required. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* w32/slirp: Undefine error constants before their redefinitionJan Kiszka2012-03-281-0/+6
| | | | | | Less warnings for your console. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: use socket_set_nonblockPaolo Bonzini2012-03-282-47/+3
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: clean up conflicts with system headersPaolo Bonzini2012-03-282-13/+16
| | | | | | | | | 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>
* slirp: Fix compiler warning for w64Stefan Weil2012-03-131-1/+1
| | | | | | | | | | | | | | | Casting a pointer to an integer value must use uintptr_t or intptr_t (not long) for portable code. MinGW-w64 requires this because sizeof(long) != sizeof(void *) for w64 hosts, so casting to long raises a compiler warning. I use uintptr_t instead of intptr_t because changing the sign does not matter here and casting pointers to unsigned values seems more reasonable (the unsigned value is a non negative offset. Cc: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Cleanup resources on instance removalJan Kiszka2012-03-1310-0/+58
| | | | | | | | 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>
* slirp: Remove unneeded if_queuedJan Kiszka2012-03-133-17/+2
| | | | | | | 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>
* slirp: Fix queue walking in if_startJan Kiszka2012-03-131-21/+39
| | | | | | | | | | | | | | | | | | | Another attempt to get this right: We need to carefully walk both the fastq and the batchq in if_start while trying to send packets to possibly not yet resolved hosts on the virtual network. So far we just requeued a delayed packet where it was and then started walking the queues from the top again - that couldn't work. Now we pre- calculate the next packet in the queue so that the current one can safely be removed if it was sent successfully. We also need to take into account that the next packet can be from the same session if the current one was sent and there are no other sessions. CC: Fabien Chouteau <chouteau@adacore.com> CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> CC: Stefan Weil <sw@weilnetz.de> Tested-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Prevent recursion of if_startJan Kiszka2012-03-132-1/+11
| | | | | | | | | | 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>
* slirp: Keep next_m always validJan Kiszka2012-03-131-8/+14
| | | | | | | | | | Make sure that next_m always points to a packet if batchq is non-empty. This will simplify walking the queues in if_start. 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>
* slirp: Fix assertion failure on rejected DHCP requestsDavid Gibson2012-02-271-1/+2
| | | | | | | | | | | | | | | | | | | | | The guest network stack might DHCPREQUEST an address that the slirp built in dhcp server can't let it have - for example if the guest has an old leases file from another network configuration. In this case the dhcp server should and does reject the request and prepares to send a DHCPNAK to the client. However, in this case the daddr variable in bootp_reply() is set to 0.0.0.0. Shortly afterwards, it unconditionally attempts to pre-insert the new client address into the ARP table. This causes an assertion failure in arp_address_add() because of the 0.0.0.0 address. According to RFC2131, DHCPNAK messages for clients on the same subnet must be sent to the broadcast address (S3.2, subpoint 2). Cc: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Refactor if_startJan Kiszka2012-02-271-42/+36
| | | | | | | | Replace gotos with a while loop, fix coding style. CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> CC: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Fix requeuing of batchq packets in if_startJan Kiszka2012-02-271-16/+19
| | | | | | | | | | | | | | | | In case we requeued a packet that was the head of a longer session queue, we failed to restore this ordering. Also, we did not properly deal with changes to Slirp::next_m. Instead of a cumbersome roll back, this fix simply avoids any changes until we know if the packet was actually sent. Both fixes crashes due to inconsistent queues and simplifies the logic. Thanks to Zhi Yong Wu who found the reason for these crashes. CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> CC: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Clean up ifs_initJan Kiszka2012-02-273-4/+5
| | | | | | | | | Remove duplicate ifs_init macros, reimplement the logic as static inline in mbuf.h. CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> CC: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp/misc: fix gcc __warn_memset_zero_len warningsAlon Levy2012-02-241-14/+7
| | | | | | | | By removing memset altogether (Patch from Stefan Hajnoczi, tested compile only by me). Signed-off-by: Alon Levy <alevy@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* slirp: Prevent sending ICMP error replies to source-only addressesJan Kiszka2012-02-081-0/+5
| | | | | | This triggered the related assert in arp_table_search. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Remove unused variable and unused codeStefan Weil2012-02-081-41/+26
| | | | | | | | | | | | | | | | 9634d9031c140b24c7ca0d8872632207f6ce7275 disabled unused code. This patch removes what was left. If do_pty is 2, the function returns immediately, so any later checks for do_pty == 2 will always fail and can be removed together with the code which is never executed. Then variable master is unused and can be removed, too. This issue was detected by coverity. Cc: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* main-loop: create main-loop.cPaolo Bonzini2011-10-211-11/+0
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* slirp: Fix packet expirationThomas Huth2011-09-281-2/+3
| | | | | | | | | | | | | | | | | | | | | The two new variables "arp_requested" and "expiration_date" in the mbuf structure have been added after the variable-sized "m_dat_" array. The variables have to be added before the m_dat_ array instead. Without this patch, the expiration_date gets clobbered by code that accesses the m_dat_ array. I experienced this problem with the code in slirp/tftp.c: The tftp_send_data() function created a new packet with the m_get() function (which fills-in a default expiration_date value). Then the TFTP code cleared the data section of the packet, which accidentially also cleared the expiration_date. This zeroed expiration_date then finally causes the packet to be discarded during if_start(), so that TFTP packets were not transmitted anymore. [Jan: added comment as suggested by Fabien ] CC: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Fix use after release on tcp_inputJan Kiszka2011-09-281-12/+10
| | | | | | | | ti points into the m buffer. But the latter may already be released right after the dodata: label. Move the test before the potential release. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* Merge remote-tracking branch 'kiszka/queues/slirp' into stagingAnthony Liguori2011-09-201-0/+1
|\
| * slirp: Fill TCP/IP header template after SYN receptionJan Kiszka2011-09-161-0/+1
| | | | | | | | | | | | | | | | | | This ensures we can cleanly signal the drop in case the connection timer fires. So far we sent those frames to nowhere (target IP 0.0.0.0). Found by the new assertion on invalid IPs in arp_table_search. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* | Remove blanks before \n in output stringsStefan Weil2011-09-162-5/+5
|/ | | | | | | | | | | | | | Those blanks violate the coding conventions, see scripts/checkpatch.pl. Blanks missing after colons in the changed lines were added. This patch does not try to fix tabs, long lines and other problems in the changed lines, therefore checkpatch.pl reports many violations. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix include statements for qemu-common.hStefan Weil2011-09-091-1/+1
| | | | | | | | | | | | | | * qemu-common.h is not a system include file, so it should be included with "" instead of <>. Otherwise incremental builds might fail because only local include files are checked for changes. * linux-user/syscall.c included the file twice. Cc: Riku Voipio <riku.voipio@iki.fi> Cc: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* Use new macro QEMU_PACKED for packed structuresStefan Weil2011-09-032-9/+9
| | | | | | | | | | | | | | | | | | | | | 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>
* char: rename qemu_chr_write() -> qemu_chr_fe_write()Anthony Liguori2011-08-221-1/+1
| | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Merge branch 'queues/slirp' of git://git.kiszka.org/qemuBlue Swirl2011-08-212-6/+6
|\ | | | | | | | | * 'queues/slirp' of git://git.kiszka.org/qemu: slirp: Fix bit field types in IP header structs
| * slirp: Fix bit field types in IP header structsJan Kiszka2011-08-142-6/+6
| | | | | | | | | | | | | | | | -mms-bitfields prevents that the bitfields in current IP header structs are packed into a single byte as it is required. Fix this by using uint8_t as backing type. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* | Use glib memory allocation and free functionsAnthony Liguori2011-08-203-10/+10
|/ | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: Only start packet expiration for delayed onesJan Kiszka2011-08-052-3/+3
| | | | | | | The expiration timeout must only affect packets that are queued due to pending ARP resolutions. The old version broke ping e.g. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Read current time only once per if_start callJan Kiszka2011-08-051-4/+1
| | | | | | | No need to update the current time for each packet we send from the queue. Processing time is comparably short. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* slirp: Fix types of IP address parametersJan Kiszka2011-08-052-10/+10
| | | | | | | 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>
* Delayed IP packetsFabien Chouteau2011-08-035-37/+69
| | | | | | | | | | | | | In the current implementation, if Slirp tries to send an IP packet to a client with an unknown hardware address, the packet is simply dropped and an ARP request is sent (if_encap in slirp/slirp.c). With this patch, Slirp will send the ARP request, re-queue the packet and try to send it later. The packet is dropped after one second if the ARP reply is not received. Signed-off-by: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* Simple ARP tableFabien Chouteau2011-08-034-58/+168
| | | | | | | | 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>
* slirp: Fix unusual "comments" in unused codeStefan Weil2011-07-271-2/+2
| | | | | | | | | | | | | cppcheck detected two rather strange comments which were not correctly written as C comments. They did not cause any harm because they were framed by #ifdef notdef ... #endif, so they were never compiled. Fix them nevertheless (we could also remove the unused code). Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
OpenPOWER on IntegriCloud