misc: Spelling and grammar fixes in comments
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Don Koch <dkoch@verizon.com>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
slirp: call socket_set_fast_reuse instead of setting SO_REUSEADDR
SO_REUSEADDR should be avoided on Windows but is desired on other operatingsystems. So instead of setting it we call socket_set_fast_reuse that will resultin the appropriate behaviour on all operating systems....
slirp: set mainloop timeout with more precise value
If slirp needs to emulate tcp timeout, then the timeout valuefor mainloop should be more precise, which is determined byslirp's fasttimo or slowtimo. Achieve this by swap the logicsequence of slirp_pollfds_fill and slirp_update_timeout....
slirp: clean up slirp_update_timeout
No need to write out the timeout early, keep it local until we are done.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
slirp: make timeout local
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>
slirp: define timeout as macro
slirp/arp_table.c: Avoid shifting into sign bit of signed integers
"0xf << 28" shifts right into the sign bit, since 0xf is a signedinteger. Use the 'U' suffix to force an unsigned shift to avoidthis undefined behaviour and a clang sanitizer warning.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
slirp: Port redirection option behave differently on Linux and Windows
port redirection code uses SO_REUSEADDR socket option before binding tohost port. Behavior of SO_REUSEADDR is different on Windows and Linux.Relaunching QEMU with same host and guest port redirection values on Linux...
aio / timers: Switch entire codebase to the new timer API
This is an autogenerated patch using scripts/switch-timer-api.
Switch the entire code base to using the new timer API.
Note this patch may introduce some line length issues.
Signed-off-by: Alex Bligh <alex@alex.org.uk>...
aio / timers: Untangle include files
include/qemu/timer.h has no need to include main-loop.h anddoing so causes an issue for the next patch. Unfortunatelyvarious files assume including timers.h will pull in main-loop.h.Untangle this mess.
slirp: remove mbuf(m_hdr,m_dat) indirection
make user networking hostfwd work with restrict=y
This patch allows the hostfwd option to override the restrict=y setting inthe user network stack, as explicitly stated in the documentation on therestrict option:
restrict=on|off If this option is enabled, the guest will be isolated, i.e. it...
slirp: cleanup leftovers from misc.h
There are quite a few leftover declarations in slirp/misc.h.Remove them.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
remove some double-includes
Some source files #include the same header more thanonce for no good reason. Remove second #includes insuch cases.
sysemu: avoid proliferation of include/ subdirectories
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
The fcntl(fd, F_SETFL, O_NONBLOCK) flag is not specific to sockets.Rename to qemu_set_nonblock() just like qemu_set_cloexec().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
MinGW: Replace setsockopt by qemu_setsocketopt
Instead of adding missing type casts which are needed by MinGW for the4th argument, the patch uses qemu_setsockopt which was invented for thispurpose.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
slirp/tcp_subr.c: fix coding style in tcp_connect
Fix coding style in tcp_connect before the next patch.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
move socket_set_nodelay to osdep.c
slirp: Properly initialize pollfds_idx of new sockets
Otherwise we may start processing sockets in slirp_pollfds_poll thatwere created past slirp_pollfds_fill.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
slirp: switch to GPollFD
Slirp uses rfds/wfds/xfds more extensively than other QEMU components.
The rarely-used out-of-band TCP data feature is used. That means weneed the full table of select(2) to g_poll(3) events:
rfds -> G_IO_IN | G_IO_HUP | G_IO_ERR...
slirp: slirp/slirp.c coding style cleanup
The slirp glue code uses tabs in some places. Since the next patch willmodify the file, convert tabs to spaces and fix checkpatch.pl issues.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>...
g_strdup(NULL) returns NULL; simplify
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
slirp: remove unused field tt
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
softmmu: move remaining include files to include/ subdirectories
misc: move include files to include/qemu/
monitor: move include files to include/monitor/
janitor: add guards to headers
Fix comments (adress -> address, layed -> laid, wierd -> weird)
Remove also a duplicated 'the'.
slirp: Don't crash on packets from 0.0.0.0/8.
LWIP can generate packets with a source of 0.0.0.0, which triggers anassertion failure in arp_table_add(). Instead of crashing, simply returnto avoid adding an invalid ARP table entry.
Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>...
slirp: Add domain-search option to slirp's DHCP server
This patch will allow the user to include the domain-search option inreplies from the built-in DHCP server. The domain suffixes can bespecified by adding dnssearch= entries to the "-net user" parameter....
slirp: remove unused function u_sleep
cleanup useless return sentence
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>
slirp: Fix spelling in comment (enought -> enough, insure -> ensure)
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
slirp: Implement TFTP Blocksize option
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...
slirp: Remove unused return value of tftp_send_next_block
No caller actually makes use of this value, so let's simplify the code.
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
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.
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...