summaryrefslogtreecommitdiff
path: root/slirp
AgeCommit message (Collapse)AuthorFilesLines
2012-10-05cleanup useless return sentenceAmos Kong3-4/+0
This patch cleans up return sentences in the end of void functions. Reported-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-10-05slirp: Fix spelling in comment (enought -> enough, insure -> ensure)Stefan Weil1-2/+2
Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-09-14slirp: Implement TFTP Blocksize optionHervé Poussineau1-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>
2012-09-13slirp: Remove unused return value of tftp_send_next_blockJan Kiszka1-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>
2012-09-13slirp: Handle more than 65535 blocks in TFTP transfersHervé Poussineau2-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>
2012-09-13slirp: improve TFTP performanceHervé Poussineau2-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>
2012-09-13slirp: Fix error reported by static code analysisStefan Weil1-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>
2012-09-13slirp: Remove wrong type casts ins debug statementsStefan Weil1-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>
2012-08-06slirp: fix build on mingw32Anthony Liguori2-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>
2012-08-03slirp: Handle whole 127.0.0.0/8 network as local addresses.Anders Waldenborg3-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>
2012-08-01net: determine if packets can be sent before net queue deliver packetsZhi Yong Wu2-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>
2012-06-07build: move slirp/ objects to nested Makefile.objsPaolo Bonzini1-0/+3
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-05-28slirp: Avoid redefining MAX_TCPOPTLENAndreas Färber1-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>
2012-05-28slirp: Avoid statements without effect on Big Endian hostAndreas Färber1-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>
2012-05-28slirp: Untangle TCPOLEN_* from TCPOPT_*Andreas Färber1-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>
2012-04-26main_loop_wait: block indefinitelyStefano Stabellini2-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>
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-30slirp: Signal free input buffer space to io-threadJan Kiszka1-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>
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: use socket_set_nonblockPaolo Bonzini2-47/+3
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-03-28slirp: clean up conflicts with system headersPaolo Bonzini2-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>
2012-03-13slirp: Fix compiler warning for w64Stefan Weil1-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>
2012-03-13slirp: Cleanup resources on instance removalJan Kiszka10-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>
2012-03-13slirp: Remove unneeded if_queuedJan Kiszka3-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>
2012-03-13slirp: Fix queue walking in if_startJan Kiszka1-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>
2012-03-13slirp: Prevent recursion of if_startJan Kiszka2-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>
2012-03-13slirp: Keep next_m always validJan Kiszka1-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>
2012-02-27slirp: Fix assertion failure on rejected DHCP requestsDavid Gibson1-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>
2012-02-27slirp: Refactor if_startJan Kiszka1-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>
2012-02-27slirp: Fix requeuing of batchq packets in if_startJan Kiszka1-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>
2012-02-27slirp: Clean up ifs_initJan Kiszka3-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>
2012-02-24slirp/misc: fix gcc __warn_memset_zero_len warningsAlon Levy1-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>
2012-02-08slirp: Prevent sending ICMP error replies to source-only addressesJan Kiszka1-0/+5
This triggered the related assert in arp_table_search. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-02-08slirp: Remove unused variable and unused codeStefan Weil1-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>
2011-10-21main-loop: create main-loop.cPaolo Bonzini1-11/+0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-09-28slirp: Fix packet expirationThomas Huth1-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>
2011-09-28slirp: Fix use after release on tcp_inputJan Kiszka1-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>
2011-09-20Merge remote-tracking branch 'kiszka/queues/slirp' into stagingAnthony Liguori1-0/+1
2011-09-16Remove blanks before \n in output stringsStefan Weil2-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>
2011-09-16slirp: Fill TCP/IP header template after SYN receptionJan Kiszka1-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>
2011-09-09Fix include statements for qemu-common.hStefan Weil1-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>
2011-09-03Use new macro QEMU_PACKED for packed structuresStefan Weil2-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>
2011-08-22char: rename qemu_chr_write() -> qemu_chr_fe_write()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-21Merge branch 'queues/slirp' of git://git.kiszka.org/qemuBlue Swirl2-6/+6
* 'queues/slirp' of git://git.kiszka.org/qemu: slirp: Fix bit field types in IP header structs
2011-08-20Use glib memory allocation and free functionsAnthony Liguori3-10/+10
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-14slirp: Fix bit field types in IP header structsJan Kiszka2-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>
2011-08-05slirp: Only start packet expiration for delayed onesJan Kiszka2-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>
2011-08-05slirp: Read current time only once per if_start callJan Kiszka1-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>
2011-08-05slirp: Fix types of IP address parametersJan Kiszka2-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>
2011-08-03Delayed IP packetsFabien Chouteau5-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>