summaryrefslogtreecommitdiff
path: root/net.c
AgeCommit message (Collapse)AuthorFilesLines
2009-06-13Win32: Don't remove const attribute in type casts.Stefan Weil1-1/+1
Type casts removing the const attribute are bad because they hide the fact that the argument remains const. They also result in a compiler warning (at least with MS-C). Signed-off-by: Stefan Weil <weil@mail.berlios.de>
2009-06-13Fix mingw32 build warningsBlue Swirl1-3/+5
Work around buffer and ioctlsocket argument type signedness problems Suppress a prototype which is unused on mingw32 Expand a macro to avoid warnings from some GCC versions Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-06-10Fix build breakage when using VDE introduced by 4f1c942Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-09net: make use of async packet sending API in tap clientMark McLoughlin1-4/+20
If a packet is queued by qemu_send_packet(), remove I/O handler for the tap fd until we get notification that the packet has been sent. A not insignificant side effect of this is we can now drain the tap send queue in one go without fear of packets being dropped. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: add qemu_send_packet_async()Mark McLoughlin1-21/+62
Add a qemu_send_packet() variant which will queue up the packet if it cannot be sent when all client queues are full. It later invokes the supplied callback when the packet has been sent. If qemu_send_packet_async() returns zero, the caller is expected to not send any more packets until the queued packet has been sent. Packets are queued iff a receive() handler returns zero (indicating queue full) and the caller has provided a sent notification callback (indicating it will stop and start its own queue). We need the packet sending API to support queueing because: - a sending client should process all available packets in one go (e.g. virtio-net emptying its tx ring) - a receiving client may not be able to handle the packet (e.g. -EAGAIN from write() to tapfd) - the sending client could detect this condition in advance (e.g. by select() for writable on tapfd) - that's too much overhead (e.g. a select() call per packet) - therefore the sending client must handle the condition by dropping the packet or queueing it - dropping packets is poor form; we should queue. However, we don't want queueing to be completely transparent. We want the sending client to stop sending packets as soon as a packet is queued. This allows the sending client to be throttled by the receiver. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: split out packet queueing and flushing into separate functionsMark McLoughlin1-57/+98
We'll be doing more packet queueing in later commits. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: return status from qemu_deliver_packet()Mark McLoughlin1-3/+17
Will allow qemu_send_packet() handle queue full condition. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: add return value to packet receive handlerMark McLoughlin1-26/+28
This allows us to handle queue full conditions rather than dropping the packet on the floor. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: pass VLANClientState* as first arg to receive handlersMark McLoughlin1-18/+18
Give static type checking a chance to catch errors. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: re-name vc->fd_read() to vc->receive()Mark McLoughlin1-18/+18
VLANClientState's fd_read() handler doesn't read from file descriptors, it adds a buffer to the client's receive queue. Re-name the handlers to make things a little less confusing. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: add fd_readv() handler to qemu_new_vlan_client() argsMark McLoughlin1-10/+11
This, apparently, is the style we prefer - all VLANClientState should be an argument to qemu_new_vlan_client(). Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: only read from tapfd when we can sendMark McLoughlin1-1/+8
Reduce the number of packets dropped under heavy network traffic by only reading a packet from the tapfd when a client can actually handle it. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: vlan clients with no fd_can_read() can always receiveMark McLoughlin1-6/+10
If a vlan client has no fd_can_read(), that means it can always receive packets. The current code assumes it can *never* receive packets. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: move the tap buffer into TAPStateMark McLoughlin1-3/+3
KVM uses a 64k buffer for reading from tapfd (for GSO support) and allocates the buffer with TAPState rather than on the stack. Not allocating it on the stack probably makes sense for qemu anyway, so merge it in advance of GSO support. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: factor tap_read_packet() out of tap_send()Mark McLoughlin1-9/+19
Move portability clutter out into its own function. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09slirp: Reorder initializationJan Kiszka1-41/+98
This patch reorders the initialization of slirp itself as well as its associated features smb and redirection. So far the first reference to slirp triggered the initialization, independent of the actual -net user option which may carry additional parameters. Now we save any request to add a smb export or some redirections until the actual initialization of the stack. This also allows to move a few parameters that were passed via global variable into the argument list of net_slirp_init. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: Improve parameter error reportingJan Kiszka1-62/+69
As host network devices can also be instantiated via the monitor, errors should then be reported to the related monitor instead of stderr. This requires larger refactoring, so this patch starts small with introducing a helper to catch both cases and convert net_client_init as well as net_slirp_redir. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: fix error reporting for some net parameter checksMark McLoughlin1-6/+6
A small bit of confusion between buffers is causing errors like: qemu: invalid parameter '10' in 'script=/etc/qemu-ifup,fd=10' instead of: qemu: invalid parameter 'script' in 'script=/etc/qemu-ifup,fd=10' Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: Real fix for check_params usersJan Kiszka1-11/+12
OK, last try: 8e4416af45 broke -net socket, ffad4116b9 tried to fix it but broke error reporting of invalid parameters. So this patch widely reverts ffad4116b9 again and intead fixes those callers of check_params that originally suffered from overwritten buffers by using separate ones. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09Revert "Fix output of uninitialized strings"Mark McLoughlin1-10/+20
This reverts commit 8cf07dcbe7691dbe4f47563058659dba6ef66b05. This is a sorry saga. This commit: 8e4416af45 net: Add parameter checks for VLAN clients broken '-net socket' and this commit: ffad4116b9 net: Fix -net socket parameter checks fixed the problem but introduced another problem which this commit: 8cf07dcbe7 Fix output of uninitialized strings fixed that final problem, but causing us to lose some error reporting information in the process. Meanwhile Jan posted a patch to mostly re-do ffad4116b9 in a way that fixes the original issue, but without losing the error reporting information. So, let's revert 8cf07dcbe7 and apply Jan's patch. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09slirp: Avoid zombie processes after fork_execJan Kiszka1-26/+34
Slirp uses fork_exec for spawning service processes, and QEMU uses this for running smbd. As SIGCHLD is not handled, these processes become zombies on termination. Fix this by installing a proper signal handler, but also make sure we disable the signal while waiting on forked network setup/shutdown scripts. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: Fix and improved ordered packet deliveryJan Kiszka1-15/+42
Fix a race in qemu_send_packet when delivering deferred packets and add proper deferring also to qemu_sendv_packet. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: Don't deliver to disabled interfaces in qemu_sendv_packetJan Kiszka1-1/+1
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-05-28User networking: Show active connectionsAlexander Graf1-0/+44
In case you're wondering what connections exactly you have open or maybe redir'ed in the past, you can't really find out from qemu right now. This patch enables you to see all current connections the host only networking holds open, so you can kill them using the previous patch. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-27User Networking: Enable removal of redirectionsAlexander Graf1-1/+42
Using the new host_net_redir command you can easily create redirections on the fly while your VM is running. While that's great, it's missing the removal of redirections, in case you want to have a port closed again at a later point in time. This patch adds support for removal of redirections. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-27Fix output of uninitialized stringsKevin Wolf1-20/+10
Commit ffad4116b96e29e0fbe892806f97c0a6c903d30d removed the "scratch buffer" from check_params, but didn't care for the error messages which actually included this string to tell the user which option was wrong. Now this string is uninitialized, so this patch removes it from the message. This means that the user is only told the whole parameter string and has to pick the wrong option by himself as the callers of check_params can't know this value any more. An alternative approach would be to revert that commit and do whatever is needed to fix the original problem without changing check_params. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-22net: Fix dump time stampsJan Kiszka1-2/+2
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2009-05-03Suppress type mismatch warnings in VDE code.Paul Brook1-3/+3
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-01net: Fix -net socket parameter checksJan Kiszka1-10/+10
My commit ea053add700d8abe203cd79a9ffb082aee4eabc0 broke -net socket by overwriting an intermediate buffer in the added check_param. Fix this by switching check_param to automatic buffer allocation and release, ie. callers no longer have to worry about providing a scratch buffer. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-01net: Avoid gcc'ism in net_host_device_addJan Kiszka1-1/+1
>> + if (net_client_init(device, opts ? : "") < 0) { > > Is this a gcc extension? Do we want to introduce this construct to the > code base. Valid remark, fix below. Thanks, Jan --------> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-04-27fix net.c compile warningRobert Reif1-1/+1
Fix net.c compile warning: CC net.o net.c: In function ‘net_slirp_redir’: net.c:623: warning: format not a string literal and no format arguments Signed-off-by: Robert Reif <reif@earthlink.net>
2009-04-21net: Prevent multiple slirp instances (Jan Kiszka)aliguori1-1/+13
The slirp stack is full of global variables which prevents instantiating it more than once. Catch this during net_slirp_init to prevent more harm later on. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7208 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21slirp: Enhance host-guest redirection setup (Jan Kiszka)aliguori1-14/+21
Allow to establish a TCP/UDP connection redirection also via a monitor command 'host_net_redir'. Moreover, assume TCP as connection type if that parameter is omitted. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7204 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21net: Untangle nested qemu_send_packet (Jan Kiszka)aliguori1-6/+30
Queue packets that are send during an ongoing packet delivery. This ensures that packets will always arrive in their logical order at each client of a VLAN. Currently, slirp generates such immediate relies, and e.g. packet-sniffing clients on the same VLAN may get confused. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7203 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21monitor: Improve host_net_add (Jan Kiszka)aliguori1-1/+3
Fix the documentation of the host_net_add monitor command and allow the user to pass no options at all. Moreover, inform the user on the monitor terminal if a request failed. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7201 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21net: Add support for capturing VLANs (Jan Kiszka)aliguori1-2/+113
This patch is derived from Tristan Gingold's patch. It adds a new VLAN client type that writes all traffic on the VLAN it is attached to into a pcap file. Such a file can then be analyzed offline with Wireshark or tcpdump. Besides rebasing and some minor cleanups, the major differences to the original version are: - support for enabling/disabling via the monitor (host_net_add/remove) - no special ordering of VLAN client list, qemu_send_packet now takes care of properly ordered packets - 64k default capturing limit (I hate tcpdump's default) Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7200 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21net: Add parameter checks for VLAN clients (Jan Kiszka)aliguori1-0/+83
This aims at helping the user to find typos or other mistakes in parameter lists passed for VLAN client initialization. The existing parsing infrastructure does not allow a leaner approach, but this is better than nothing IMHO. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7197 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21net: Fix -net socket,listen (Jan Kiszka)aliguori1-1/+1
In case no symbolic name is provided when requesting VLAN connection via listening TCP socket ('-net socket,listen=...'), qemu crashes. This fixes the cause. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7196 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21net: Check device passed to host_net_remove (Jan Kiszka)aliguori1-2/+8
Make sure that we do not delete guest NICs via host_net_remove. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7195 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17Free VLANClientState using qemu_free() (Mark McLoughlin)aliguori1-1/+1
It's allocated using qemu_mallocz(), so ... The name and model strings are strdup() allocated, so free() is still appropriate for them. Reported-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7151 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17Introduce VLANClientState::cleanup() (Mark McLoughlin)aliguori1-21/+50
We're currently leaking memory and file descriptors on device hot-unplug. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7150 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17Remove some useless malloc() checking (Mark McLoughlin)aliguori1-13/+3
Now that we abort() on malloc, neither qemu_find_vlan() nor net_tap_fd_init() can fail. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7146 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17Fix error handling in net_client_init() (Mark McLoughlin)aliguori1-10/+16
We weren't freeing the name string everywhere. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7144 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17struct iovec is now universally available (Mark McLoughlin)aliguori1-4/+0
struct iovec is now defined in qemu-common.h if needed, so we don't need the tap code to handle !defined(HAVE_IOVEC). Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7143 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-13Fix OpenSolaris gcc4 warnings: iovec type mismatches, missing 'static'blueswir11-3/+3
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7103 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-05Fix some win32 compile warningsblueswir11-1/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6984 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-28host_device_remove: remove incorrect check for device name (Eduardo Habkost)aliguori1-5/+0
There is no need to check for valid prefixes on the the device name when removing it. If the device name is found on the vlan client list, it can be removed, regardless of the prefix used on its name. To reproduce the bug, just run this on the monitor: (qemu) host_net_add user name=foobar (qemu) host_net_remove 0 foobar invalid host network device foobar (qemu) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6891 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-08Fix windows build and clean up use of <windows.h>aliguori1-0/+1
We want to globally define WIN_LEAN_AND_MEAN and WINVER to particular values so let'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> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6783 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-08Rename _BSD to HOST_BSD so that it's more obvious that it's defined by configureblueswir11-3/+3
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6775 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-07Support for DragonFly BSD (Hasso Tepper)blueswir11-1/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6746 c046a42c-6fe2-441c-8c8c-71466251a162