slirp: Remove unused return value of tftp_send_next_block
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 transfers
RFC 1350 does not mention block count roll-over. However, a lot of TFTP serversimplement 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....
slirp: Remove wrong type casts ins debug statements
The type casts of pointers to long are not allowedwhen sizeof(pointer) != sizeof(long).
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
slirp: Fix error reported by static code analysis
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.
slirp: improve TFTP performance
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 build on mingw32
in_addr_t isn't available on mingw32. Just use an unsigned long instead. Iconsidered typedef'ing in_addr_t on mingw32 but this would potentially bebrittle if mingw32 did introduce the type.
Cc: Jan Kiszka <jan.kiszka@siemens.com>...
slirp: Handle whole 127.0.0.0/8 network as local addresses.
Changes so translation of remote address to the host's ip address inthe virtual network happens for all addresses in the 127.0.0.0/8network, not just 127.0.0.1.
This fixes so that hostfwd bound to addresses such as 127.0.0.2 works....
net: determine if packets can be sent before net queue deliver packets
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.objs
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
slirp: Avoid redefining MAX_TCPOPTLEN
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....
slirp: Avoid statements without effect on Big Endian host
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...
slirp: Untangle TCPOLEN_* from TCPOPT_*
Commit b72210568ef0c0fb141a01cffb71a09c4efa0364 (slirp: clean upconflicts with system headers) enclosed TCPOLEN_MAXSEG with an #ifdefTCPOPT_EOL. This broke the build on illumos, which has TCPOPT_*but not TCPOLEN_*....
main_loop_wait: block indefinitely
- 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 maximumvalue;
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>...
w32: Move defines for socket specific errors to qemu-os-win32.h
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 alsoinclude qemu-os-win32.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
slirp: Signal free input buffer space to io-thread
This massively accelerates slirp reception speed: If data arrivesfaster than the guest can read it from the input buffer, the filedescriptor for the corresponding socket was taken out of the fdset forselect. However, the event of the guest reading enough data from the...
w32/slirp: Undefine error constants before their redefinition
Less warnings for your console.
slirp: use socket_set_nonblock
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
slirp: clean up conflicts with system headers
Right now, slirp/slirp.h cannot include some system headers and,indirectly, qemu_socket.h. Clean this up, and remove a duplicateprototype that was introduced because of that.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
slirp: Fix compiler warning for w64
Casting a pointer to an integer value must use uintptr_t or intptr_t(not long) for portable code. MinGW-w64 requires this becausesizeof(long) != sizeof(void *) for w64 hosts, so casting to longraises a compiler warning....
slirp: Remove unneeded if_queued
There is now a trivial check on entry of if_start for pending packets,so we can drop the additional tracking via if_queued.
slirp: Cleanup resources on instance removal
Close & free sockets when shutting down a slirp instance, also releaseall buffers.
CC: Michael S. Tsirkin <mst@redhat.com>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
slirp: Keep next_m always valid
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>...
slirp: Prevent recursion of if_start
if_start can be called recursively via if_encap. Avoid this as ourscheme of dequeuing packets is not compatible with this.
slirp: Fix queue walking in if_start
Another attempt to get this right: We need to carefully walk both thefastq and the batchq in if_start while trying to send packets topossibly not yet resolved hosts on the virtual network.
So far we just requeued a delayed packet where it was and then started...
slirp: Fix assertion failure on rejected DHCP requests
The guest network stack might DHCPREQUEST an address that the slirp builtin dhcp server can't let it have - for example if the guest has an oldleases file from another network configuration. In this case the dhcp...
slirp: Clean up ifs_init
Remove duplicate ifs_init macros, reimplement the logic as static inlinein 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: Fix requeuing of batchq packets in if_start
In case we requeued a packet that was the head of a longer sessionqueue, we failed to restore this ordering. Also, we did not properlydeal with changes to Slirp::next_m.
Instead of a cumbersome roll back, this fix simply avoids any changes...
slirp: Refactor if_start
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/misc: fix gcc __warn_memset_zero_len warnings
By removing memset altogether (Patch from Stefan Hajnoczi, testedcompile only by me).
Signed-off-by: Alon Levy <alevy@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
slirp: Remove unused variable and unused code
9634d9031c140b24c7ca0d8872632207f6ce7275 disabled unused code.This patch removes what was left.
If do_pty is 2, the function returns immediately, so any later checksfor do_pty == 2 will always fail and can be removed together with...
slirp: Prevent sending ICMP error replies to source-only addresses
This triggered the related assert in arp_table_search.
main-loop: create main-loop.c
slirp: Fix packet expiration
The two new variables "arp_requested" and "expiration_date" in the mbufstructure have been added after the variable-sized "m_dat_" array. Thevariables have to be added before the m_dat_ array instead.Without this patch, the expiration_date gets clobbered by code that...
slirp: Fix use after release on tcp_input
ti points into the m buffer. But the latter may already be releasedright after the dodata: label. Move the test before the potentialrelease.
Merge remote-tracking branch 'kiszka/queues/slirp' into staging
Remove blanks before \n in output strings
Those blanks violate the coding conventions, seescripts/checkpatch.pl.
Blanks missing after colons in the changed lines were added.
This patch does not try to fix tabs, long lines and otherproblems in the changed lines, therefore checkpatch.pl reports...
slirp: Fill TCP/IP header template after SYN reception
This ensures we can cleanly signal the drop in case the connection timerfires. 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....
Fix include statements for qemu-common.h
Use new macro QEMU_PACKED for packed structures
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/'...
char: rename qemu_chr_write() -> qemu_chr_fe_write()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Merge branch 'queues/slirp' of git://git.kiszka.org/qemu
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
slirp: Fix bit field types in IP header structs
-mms-bitfields prevents that the bitfields in current IP header structsare packed into a single byte as it is required. Fix this by usinguint8_t as backing type.
slirp: Only start packet expiration for delayed ones
The expiration timeout must only affect packets that are queued due topending ARP resolutions. The old version broke ping e.g.
slirp: Read current time only once per if_start call
No need to update the current time for each packet we send from thequeue. Processing time is comparably short.
slirp: Fix types of IP address parameters
Should be uint32_t for IPv4, not int. Also avoid in_addr_t withoutproper includes. Fixes build regression on mingw32.
Delayed IP packets
In the current implementation, if Slirp tries to send an IP packet to a clientwith an unknown hardware address, the packet is simply dropped and an ARPrequest is sent (if_encap in slirp/slirp.c).
With this patch, Slirp will send the ARP request, re-queue the packet and try...
Simple ARP table
This patch adds a simple ARP table in Slirp and also adds handling ofgratuitous 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 code
cppcheck detected two rather strange comments which were notcorrectly 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)....
Wrap recv to avoid warnings
Avoid warnings like these by wrapping recv(): CC slirp/ip_icmp.o/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror]...
slirp: Forward ICMP echo requests via unprivileged sockets
Linux 3.0 gained support for unprivileged ICMP ping sockets. Use thisfeature to forward guest pings to the outer world. The host admin has toset the ping_group_range in order to grant access to those sockets. To...
slirp: Fix restricted mode
This aligns the code to what the documentation claims: Allow everythingbut requests that would have to be routed outside of the virtual LAN.
So we need to drop the unneeded IP-level filter, allow TFTP requests,and add the missing protocol-level filter to ICMP....
slirp: Strictly associate DHCP/BOOTP and TFTP with virtual host
Instead of accepting every DHCP/BOOTP and TFTP packet, only invoke thebuilt-in servers if the target is the virtual host.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
slirp: Replace m_freem with m_free
Remove this pointless wrapping.
slirp: Put forked exec into separate process group
Recent smb daemons tend to terminate themselves via a process groupSIGTERM. If the daemon is still in qemu's group by that time, qemu willdie as well. Avoid this by always pushing fork_exec processes into a...
add a service to reap zombies, use it in SLIRP
SLIRP -smb support wants to fork a process and forget about reaping it.To please it, add a generic service to register a process id and letQEMU reap it. In the future it could be enhanced to pass a status,...
change all rt_clock references to use millisecond resolution accessors
This was done with:
sed -i '/get_clock\>.*rt_clock/s/get_clock\>/get_clock_ms/' \ $(git grep -l 'get_clock\>.*rt_clock' ) sed -i '/new_timer\>.*rt_clock/s/new_timer\>/new_timer_ms/' \...
net: fix trace when debug is activated in slirp
make the code compile correctly when DEBUG is activated.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
slirp: Remove some type casts caused by bad declaration of x.tp_buf
x.tp_buf was declared as a uint8_t array, but always used asa char array (which needed a lot of type casts).
The patch includes these changes:
Fix build from previous commit
I unfortunately got on an unnamed branch and pushed the wrong bits
PATCH] slirp: fix buffer overrun
Since the addition of the slirp member to struct mbuf, the value ofSLIRP_MSIZE and the initialization of m_size have not been correct,resulting in overrunning the end of the malloc'd buffer in some cases.
Signed-off-by: Bruce Rogers <brogers@novell.com>...
Delete useless 'extern' qualifiers for functions
'extern' qualifier is useless for function declarations. Deletethem.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
slirp: Use strcasecmp() to check tftp mode, tsize
According to RFC 1350 (TFTP Revision 2) the mode field can contain anycombination of upper and lower case; also RFC 2349 propagates that thetransfer size option ("tsize") is case in-sensitive too.
Current implementation of embedded TFTP server missed that what does...
slirp: fix unaligned access in bootp code
Slirp code tries to be smart an avoid data copy by using pointer tothe data. This solution leads to unaligned access, in this casepreq_addr, which is a 32-bit long structure. There is no real pointof avoiding data copy in a such case, as the value itself is smaller...
slirp: Remove unused code for bad sprintf
Neither DECLARE_SPRINTF nor BAD_SPRINTF are needed for QEMU.
QEMU won't support systems with missing or bad declarationsfor sprintf. The unused code was detected while looking forfunctions with missing format checking. Instead of adding...
Use GCC_FMT_ATTR (format checking)
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
slirp: Silence warning on Haiku
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>
Accept packets with TTL=1
Packets with TTL=1 may be directed to local network (DHCP/DNS servers for example), so don't discard themThis is required by old versions of NetBSD which send DHCP DISCOVER packets with TTL=1
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>...
Make ARP replies at least 64 bytes long
IEEE 802.3 standard requires Ethernet frames to be at least 64 bytes long.If it is not the case, they will be considered as runt frames, and may be ignored by netcard and/or OS
Change DPRINTF to do{}while(0) to avoid compiler warning
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
slirp: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types
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>
slirp: Remove declarations which are no longer needed
The previous patches replaced u_int8_t, u_int16_t, u_int32_t, u_int64_tby 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>...
savevm: Add DeviceState param
When available, we'd like to be able to access the DeviceStatewhen registering a savevm. For buses with a get_dev_path()function, this will allow us to create more unique savevmid strings.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>...
Remove dead assignments in various common files, spotted by clang analyzer
Value stored is never read.
slirp: fix structure initialization in tcp_listen()
A data structure of type sockaddr_in is allocated from stack but notproperly initialized. This may lead to a failure in the bind() calllater on. Fixed by filling the contents of the structure with zeroes...
slirp: fix unused return value, spotted by clang
Fix clang errors like: CC slirp/cksum.o/src/qemu/slirp/cksum.c:78:3: error: expression result unused [-Wunused-value] REDUCE;/src/qemu/slirp/cksum.c:45:66: note: instantiated from:
monitor: Separate "default monitor" and "current monitor" cleanly
Commits 376253ec..731b0364 introduced global variable cur_mon, whichpoints to the "default monitor" (if any), except during execution ofmonitor_read() or monitor_control_read() it points to the monitor from...
slirp: remove dead initialization, spotted by clang
Value stored during initialization is never read.
slirp: remove dead nested assignment, spotted by clang
Although the value stored to 'r' is used in the enclosing expression,the value is never actually read from 'r'.
slirp: remove dead increments, spotted by clang
slirp: remove dead assignments, spotted by clang
don't dereference NULL after failed strdup
Most of these are obvious NULL-deref bug fixes, for example,the ones in these files:
block/curl.c net.c slirp/misc.c
and the first one in block/vvfat.c.The others in block/vvfat.c may not lead to an immediate segfault, but I...
Do not use dprintf
dprintf is already claimed by POSIX1, and on at least one systemis implemented as a macro
[1] http://www.opengroup.org/onlinepubs/9699919799/functions/dprintf.html
Signed-off-by: malc <av1474@comtv.ru>
Qemu's internal TFTP server breaks lock-step-iness of TFTP
According to RFC 1350 and RFC 2347, TFTP server should answer RRQ byeither OACK or DATA packet. Qemu's internal TFTP server answers RRQ withadditional options by sending both OACK and DATA packet, thus breaking...
Handle TFTP ERROR from client
If a PXE client only wants to find out the size of a file, it willopen the file and then abort the transfer by sending a TFTP ERROR packet.
The ERROR packet should cause qemu to terminate the session. If not,the sessions will soon run out and cause timeouts in the client....
slirp/misc.c: fix warning with _FORTIFY_SOURCE
CC slirp/misc.occ1: warnings being treated as errorsslirp/misc.c: In function 'fork_exec':slirp/misc.c:209: error: ignoring return value of 'write', declared with attribute warn_unused_resultmake: *** [slirp/misc.o] Error 1...
fix networking on win32 host
At least under some mingw compilers slirp networking fails without declaringthese fields packed.
From: Juha Riihimäki <juha.riihimaki@nokia.com>Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>Signed-off-by: Riku Voipio <riku.voipio@nokia.com>...
Don't leak file descriptors
We're leaking file descriptors to child processes. Set FD_CLOEXEC on filedescriptors 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>
slirp: fix use-after-free
460fec67ee introduced a use-after free in slirp.
Cc: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
slirp: fix unmatched bracket in if 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 good
Problem: Our file sys-queue.h is a copy of the BSD file, but there aresome additions and it's not entirely compatible. Because of that, there havebeen conflicts with system headers on BSD systems. Some hacks have beenintroduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...
Fix Sparse warnings: add "static"
Fix compiler warnings
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...
slirp: Remove our_addr code
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, butthere's no guarantee that gethostbyname(gethostname()) actually does...
slirp: Read host DNS config on demand
Currently the qemu user-mode networking stack reads the host DNSconfiguration (/etc/resolv.conf or the Windows equivalent) only oncewhen qemu starts. This causes name lookups in the guest to fail if thehost is moved to a different network from which the original DNS servers...
Add missing "static"
More NULL pointer fixes
rename WORDS_BIGENDIAN to HOST_WORDS_BIGENDIAN
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
slirp: Remove UDP protocol emulation (talk, cuseeme)
The UDP emulation code for talk has been commented out since thebeginning of time, and unless someone who runs CU-SeeMe on qemu withuser-mode networking can vouch that the special magic (a) is necessary...
slirp: Use monotonic clock if available (v2)
Calling gettimeofday() to compute a time interval can cause problems ifthe system clock jumps forwards or backwards; replace updtime() withqemu_get_clock(rt_clock), which calls clock_gettime(CLOCK_MONOTONIC) if...