Commit Graph

890 Commits

Author SHA1 Message Date
Kevin Wolf 40ff6d7e8d Don't leak file descriptors
We're leaking file descriptors to child processes. Set FD_CLOEXEC on file
descriptors 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>
2009-12-03 11:45:50 -06:00
Mark McLoughlin f5c5e38179 net: fix vnet_hdr handling in solaris tap code
Print an error if the user specifies vnet_hdr=1 on the cmdline.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:35 -06:00
Mark McLoughlin df6c2a0fb2 net: initialize vnet_hdr in net_init_tap()
net_tap_init() always sets vnet_hdr using qemu_opt_get_bool(), but
initialize it in net_init_tap() just to reduce confusion.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:35 -06:00
Pierre Riteau 2e50326c44 net: check for TUNSETOFFLOAD support before trying to enable offload features
This avoids the "TUNSETOFFLOAD ioctl() failed: Invalid argument" message
on kernels without TUNSETOFFLOAD support.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:35 -06:00
Pierre Riteau 6720b35b81 net: fix TAP networking on host kernels without IFF_VNET_HDR support
vnet_hdr is initialized at 1 by default. We need to reset it to 0 if
the kernel doesn't support IFF_VNET_HDR.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:35 -06:00
Mark McLoughlin 665a3b071d net: remove VLANClientState members now in NetClientInfo
Add a NetClientInfo pointer to VLANClientState and use that
for the typecode and function pointers.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:34 -06:00
Mark McLoughlin f1d078c341 net: move parse_macaddr() to net/util.[ch]
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:34 -06:00
Mark McLoughlin 731d5856cb net: convert dump to NetClientInfo
aliguori: fix uninitialized use of pcap_len

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:30 -06:00
Mark McLoughlin 564f63e3fc net: convert socket to NetClientInfo
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:30 -06:00
Mark McLoughlin b4e859c6a1 net: convert vde to NetClientInfo
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:30 -06:00
Mark McLoughlin ce20b5be50 net: convert slirp to NetClientInfo
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:30 -06:00
Mark McLoughlin dca91811bc net: convert tap-win32 to NetClientInfo
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:29 -06:00
Mark McLoughlin 3e35ba93ec net: convert tap to NetClientInfo
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:29 -06:00
Mark McLoughlin 1abecf77d8 net: move dump backend code from net.c to net/dump.c
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:28 -06:00
Mark McLoughlin 42281ac9a3 net: move socket backend code from net.c to net/socket.c
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:28 -06:00
Mark McLoughlin 5c361cc322 net: move vde code from net.c to net/vde.c
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:28 -06:00
Mark McLoughlin 68ac40d2c6 net: move slirp code from net.c to net/slirp.c
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:27 -06:00
Aurelien Jarno a167ba5085 Add support for GNU/kFreeBSD
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-11-29 18:00:41 +01:00
Juergen Lock 929fe49721 Avoid segfault on net_tap_init() failure
Check for fd == -1 there.

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-21 09:32:15 +00:00
Juergen Lock 2f859a3c10 tap-bsd: handle ifname on FreeBSD hosts
Handle ifname on FreeBSD hosts; if no ifname is given, always start
the search from tap0.  (Simplified/cleaned up version of what has been
in the FreeBSD ports for a long time.)

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-21 09:32:08 +00:00
Juergen Lock 39ca4c0832 Fix tap breakage on BSD hosts (no IFF_VNET_HDR)
net/tap-bsd.c was assuming IFF_VNET_HDR was always available, which
I think isn't true on any BSD.

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-21 09:32:02 +00:00
Mark McLoughlin 5819c91806 tap: drain queue in tap_send()
Okay, let's try re-enabling the drain-entire-queue behaviour, with a
difference - before each subsequent packet, use qemu_can_send_packet()
to check that we can send it. This is similar to how we check before
polling the tap fd and avoids having to drop a packet if the receiver
cannot handle it.

This patch should be a performance improvement since we no longer have
to go through the mainloop for each packet.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:02 -06:00
Mark McLoughlin 839f368f2b net/queue: queue packets even if sender doesn't supply a callback
Now that we disable any receiver whose queue is full, we do not require
senders to handle a zero return by supplying a sent callback.

This is a second step towards allowing can_receive() handlers to return
true even if no buffer space is available.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:02 -06:00
Mark McLoughlin be1636b3ab tap: disable draining queue in one go
If qemu_send_packet_async() returns zero, it means the packet has been
queued and the sent callback will be invoked once it has been flushed.

This is only possible where the NIC's receive() handler returns zero
and promises to notify the networking core that room is available in its
queue again.

In the case where the receive handler does not have this capability
(and its queue fills up) it returns -1 and the networking core does not
queue up the packet. This condition is indicated by a -1 return from
qemu_send_packet_async().

Currently, tap handles this condition simply by dropping the packet. It
should do its best to avoid getting into this situation by checking such
NIC's have room for a packet before copying the packet from the tap
interface.

tap_send() used to achieve this by only reading a single packet before
returning to the mainloop. That way, tap_can_send() is called before
reading each packet.

tap_send() was changed to completely drain the tap interface queue
without taking into account the situation where the NIC returns an
error and the packet is not queued. Let's start fixing this by
reverting to the previous behaviour of reading one packet at a time.

Reported-by: Scott Tsai <scottt.tw@gmail.com>
Tested-by: Sven Rudolph <Sven_Rudolph@drewag.de>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:02 -06:00
Anthony Liguori ed7193ec1d Unbreak Linux build
commit 71f4effce7
  Author: Alexander Graf <agraf@suse.de>
  Date:   Fri Oct 30 22:27:00 2009 +0100

      Unbreak tap compilation on OS X

Broke the build on Linux due to a bad #if guard

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 16:45:20 -05:00
Alexander Graf 71f4effce7 Unbreak tap compilation on OS X
Currently compiling the tap sources breaks on Mac OS X. This is because of:

  1) tap-linux.h requiring Linux includes
  2) typos
  3) missing #includes

This patch adds what's necessary to compile tap happily on Mac OS X.
I haven't tested if using tap actually works, but I don't think that's a
major issue as that code was probably seriously untested before already.

I didn't split the patch, because it's only a few lines of code and
splitting is probably not worth the effort here.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 16:38:15 -05:00
Mark McLoughlin 9c282718aa net: move UFO support detection to tap-linux.c
Only supported on Linux

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:29 -05:00
Mark McLoughlin 1faac1f7d4 net: move tap_set_offload() code into tap-linux.c
TUNSETOFFLOAD is only available on Linux

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:28 -05:00
Mark McLoughlin dc69004c7d net: move tap_probe_vnet_hdr() to tap-linux.c
Only Linux has support for IFF_VNET_HDR

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:28 -05:00
Mark McLoughlin 15ac913bfe net: move tap_set_sndbuf() to tap-linux.c
TUNSETSNDBUF is only available on linux

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:28 -05:00
Mark McLoughlin c28b1c1007 net: move linux code into net/tap-linux.c
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:28 -05:00
Mark McLoughlin 88b3ec02b2 net: move AIX code into net/tap-aix.c
Okay, this makes the tap options available on AIX even though there's
no support, but if we want to do it right we should have not compile
the tap code at all on AIX using e.g. CONFIG_TAP.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:28 -05:00
Mark McLoughlin 966ea5ec4f net: move solaris code to net/tap-solaris.c
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:27 -05:00
Mark McLoughlin e7e92325d9 net: split BSD tap_open() out into net/tap-bsd.c
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:27 -05:00
Mark McLoughlin 5281d757ef net: split all the tap code out into net/tap.c
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:27 -05:00
Mark McLoughlin f54c7bdc48 net: move tap-linux.h under net/
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:27 -05:00
Mark McLoughlin a8ed73f73d net: move more stuff into net/tap-win32.c, add net/tap.h
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:27 -05:00
Mark McLoughlin 33ad161a04 net: move tap-win32.c under net/
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:27 -05:00
Mark McLoughlin 7200ac3c7c net: move net-checksum.c under net/
Also add a new net/checksum.h header

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:26 -05:00
Mark McLoughlin e1144d006d net: move net-queue.[ch] under net/
[v2: handle building in a separate dir]

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:26 -05:00