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
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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...
slirp: Fix guestfwd for incoming data
Unless a virtual server address was explicitly defined (which isimpossible with the legacy net channel format), guestfwd did notproperly forwarded host>guest packets. This patch fixes it.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
Fix breakage by obsolete _P() for good
slirp: tftp: Relax filename format check
[ Applies on top of my recently posted slirp series. ]
Allow tftp requests with filenames that do not start with a slash.
slirp: Enable multiple instances
Once again this was a long journey to reach the destination: Allow toinstantiate slirp multiple times. But as in the past, the journey wasworthwhile, cleaning up, fixing and enhancing various parts of the userspace network stack along the way....
slirp: Save/restore bootp client states
slirp: Clean up updtime
Drop redundant typecasts in both variants and remove the pointlessround-up in the UNIX version.
slirp: Kill slirp_is_inited
Avoid the need for slirp_is_inited by refactoring the protectedslirp_select_* functions. This also avoids the clearing of all fd setson select errors.
slirp: Clean up timeout handling around slirp_select_fill/poll
Again lot of dead code. Remove it.
slirp: Drop link_up checks from if_output and slirp_socket_can_recv
link_up is true once slirp is initialized, so these check are really notrequired.
slirp: Factor out internal state structure
The essence of this patch is to stuff (almost) all global variables ofthe slirp stack into the structure Slirp. In this step, we still keepthe structure as global variable, directly accessible by the wholestack. Changes to the external interface of slirp will be applied in...
slirp: Use internal state in interface
This now also exports the internal state to the slirp users in qemu,returning it from slirp_init and expecting it along with serviceinvocations. Additionally provide an opaque value interface for thecallbacks from slirp into the qemu core....
slirp: Allocate/free stack instance dynamically
Allocate the internal slirp state dynamically and provide and callslirp_cleanup to properly release it after use. This patch finallyunbreaks slirp release and re-instantiation via host_net_* monitorcommands....
slirp: Make IP packet ID consistent
Currently, ip_id is always initialized to 0 on slirp startup (despitethe broken attempt to derive it from the clock). This is good forreproducibility. But it is not preserved across save/restore. This patchtherefore drops the dead initialization code from ip_init and introduces...
slirp: Drop unused icmp_var.h
slirp: tftp: Cleanup tftp_prefix check
Perform check for set prefix early (if it's not given, tftp is disabled)and drop redundant second check.
slirp: tftp: Clean up tftp_send_error
The return code of tftp_send_error is not used, drop it. And also makesure to always terminate the session.
slirp: tftp: Refactor tftp_handle_rrq
Specifically make the filename extraction more readable, and alwaysreport errors back to the client.
slirp: tftp: Rework filename handling
This changes the filename handling from a static buffer in tftp_sessionfor the client-provided name + prefix to a dynamically allocated bufferthat keeps the combined path in one place.
slirp: Factor out one-time initialization
In order to prepare re-initialization and multi-instance slirp, factorout init code that is of global scope and (at least for now) only needto be run once.
This also fixes the potentially uninitialized use of our_addr in...
slirp: Do not allow to remove non-hostfwd sockets
Prevent that the users accidentally shoots down dynamic sockets. Thisallows to remove looping for removals as there can now only be onematch.
slirp: Mark sockets of incoming TCP connections
Required for pretty-printing.
slirp: Add info usernet for dumping connection states
Break out sockstats from the slirp statistics and present them under thenew info category "usernet". This patch also improves the current output/wrt proper reporting connection source and destination....
slirp: Drop dead code
After all its years inside the qemu tree, there is no point in keepingthe dead code paths of slirp. This patch is a first round of removingusually commented out code parts. More cleanups need to follow (andmaybe finally a proper reindention)....
slirp: Drop statistic code
As agreed on the mailing list, there is no interest in keeping theusually disabled slirp statistics in the tree. So this patch removesthem.
slirp: Cleanup and basic reanimation of debug code
slirp: Rework internal configuration
The user mode IP stack is currently only minimally configurable /wrt toits virtual IP addresses. This is unfortunate if some guest has a fixedidea of which IP addresses to use.
Therefore this patch prepares the stack for fully configurable IP...
slirp: Rework external configuration interface
With the internal IP configuration made more flexible, we can nowenhance the user interface. This patch adds a number of new options to"-net user": net (address and mask), host, dhcpstart, dns and smbserver....
slirp: Fix port comparision in slirp_remove_hostfwd
For UDP host forwardings, fport is not stable, every outgoing packet ofthe redirection can modify it. Use getsockname instead to look up theport that is actually used on the host side.
slirp: Bind support for host forwarding rules
Extend the hostfwd rule format so that the user can specify on whichhost interface qemu should listen for incoming connections. If omitted,binding will takes place against all interfaces.
slirp: Prepare for persistent socket state flags
This prepares for adding flags to socket.so_state that must not beremoved during the lifetime of a socket.
slirp: Explicitely mark host-forwarding sockets
Mark sockets that describe host forwardings. This is required for their(and only their) proper deletion and for pretty-printing.
slirp: Drop redundant lines from udp_input
The socket faddr/fport is already updated a few lines below, so theseare completely redundant.
slirp: Refactor tcp_ctl
Revert "User networking: Show active connections"
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
slirp: Move smb, redir, tftp and bootp parameters and -net channel
So far a couple of slirp-related parameters were expressed viastand-alone command line options. This it inconsistent and unintuitive.Moreover, it prevents both dynamically reconfigured (host_net_add/...
Fix mingw32 build warnings
Work around buffer and ioctlsocket argument type signedness problemsSuppress a prototype which is unused on mingw32Expand a macro to avoid warnings from some GCC versions
slirp: Reorder initialization
This patch reorders the initialization of slirp itself as well as itsassociated features smb and redirection. So far the first reference toslirp triggered the initialization, independent of the actual -net useroption which may carry additional parameters. Now we save any request to...
User networking: Show active connections
In case you're wondering what connections exactly you have openor maybe redir'ed in the past, you can't really find out from qemuright now.
This patch enables you to see all current connections the hostonly networking holds open, so you can kill them using the previous...
User Networking: Enable removal of redirections
Using the new host_net_redir command you can easily create redirectionson the fly while your VM is running.
While that's great, it's missing the removal of redirections, in case youwant to have a port closed again at a later point in time....
slirp: Reassign same address to same DHCP client
In case a client restarts a DHCP recovery without releasing its oldaddress, reassign the same address to prevent consuming free addressesand moving away from the standard client address.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Cast pointer arguments of get/setsockopt, send to void * to keep GCCfrom producing a warning about pointer type mismatches with Winsock
Replace gcc variadic macro extension with C99 version
slirp: Handle DHCP requests for specific IP (Jan Kiszka)
This adds proper handling of the ciaddr field as well as the "RequestedIP Address" option to slirp's DHCP server. If the client requests aninvalid or used IP, a NAK reply is sent, if it requests a specific but...
Use ANSI prototypes to please sparse
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7176 c046a42c-6fe2-441c-8c8c-71466251a162
Move bootp_filename to avoid a sparse warning
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7174 c046a42c-6fe2-441c-8c8c-71466251a162
Fix some win32 compile warnings
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6984 c046a42c-6fe2-441c-8c8c-71466251a162
Delete some unused macros detected with -Wp,-Wunused-macros use
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6856 c046a42c-6fe2-441c-8c8c-71466251a162
Fix windows build and clean up use of <windows.h>
We want to globally define WIN_LEAN_AND_MEAN and WINVER to particular values solet's do it in OS_CFLAGS.
Then, we can pepper in windows.h includes where using #includes that require it.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>...