aboutsummaryrefslogtreecommitdiff
path: root/net.c
Commit message (Collapse)AuthorAgeFilesLines
* default devices: networkGerd Hoffmann2009-12-121-1/+4
| | | | | | | | | | Add a default_net variable which specified whenever a default network should be created. It is cleared in case any -net option is specified and it is also added to the new -nodefaults switch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit cb4522ccf67ba84d246291d9f75bd7f3df137d1a)
* net: print correct error for '-netdev ""'Mark McLoughlin2009-12-031-5/+11
| | | | | | Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add qemu_foreach_nic()Mark McLoughlin2009-12-031-0/+20
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: remove VLANClientState members now in NetClientInfoMark McLoughlin2009-12-031-25/+20
| | | | | | | | 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>
* net: remove qemu_new_vlan_client()Mark McLoughlin2009-12-031-44/+0
| | | | | | | | | ... and VLANClientState::opaque and qemu_find_vlan_client(). All of these are now unused Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: move parse_macaddr() to net/util.[ch]Mark McLoughlin2009-12-031-33/+2
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: introduce NICState and qemu_new_nic()Mark McLoughlin2009-12-031-0/+21
| | | | | | | | | | | | | Common state for all NICs. The opaque member will replace the opaque member in VLANClientState since only NICs need it. The conf member will allow us to iterate over NICs, access the MAC addr for the NIC and send a packet from each NIC in qemu_announce_self(). Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: introduce qemu_new_net_client()Mark McLoughlin2009-12-031-21/+49
| | | | | | | | A replacement for qemu_new_vlan_client(), using NetClientInfo to replace most arguments. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: clean up includes in net.cMark McLoughlin2009-12-031-70/+3
| | | | | | | | | | | | This is probably a little drastic, but the includes in this file are now totally out of control when compared with what includes are actually needed. This may break the build on e.g. *BSD, but it will be easily fixed by re-instating an include. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: move dump backend code from net.c to net/dump.cMark McLoughlin2009-12-031-126/+1
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: move socket backend code from net.c to net/socket.cMark McLoughlin2009-12-031-529/+1
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: move vde code from net.c to net/vde.cMark McLoughlin2009-12-031-101/+1
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: move slirp code from net.c to net/slirp.cMark McLoughlin2009-12-031-712/+6
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Add support for GNU/kFreeBSDAurelien Jarno2009-11-291-4/+1
| | | | Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* net: disable receiving if client returns zeroMark McLoughlin2009-11-091-11/+38
| | | | | | | | | | | | | If a receiver returns zero, that means its queue is full and it will notify us when room is available using qemu_flush_queued_packets(). Take note of that and disable that receiver until it flushes its queue. This is a first 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>
* net: move AIX code into net/tap-aix.cMark McLoughlin2009-10-301-2/+0
| | | | | | | | | 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>
* net: split all the tap code out into net/tap.cMark McLoughlin2009-10-301-691/+1
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: move tap-linux.h under net/Mark McLoughlin2009-10-301-1/+1
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: move more stuff into net/tap-win32.c, add net/tap.hMark McLoughlin2009-10-301-64/+11
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Enable UFO on virtio-net and tap devicesSridhar Samudrala2009-10-271-4/+32
| | | | | | | | | Enable UFO on the host tap device if supported and allow setting UFO on virtio-net in the guest. Signed-off-by: Sridhar Samudrala <sri@us.ibm.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add tap_set_offload()Mark McLoughlin2009-10-271-0/+24
| | | | | | | | | This API allows virtio-net to enable various offload features on a tap interface - e.g. to tell the host kernel it can pass up partial checksums to userspace. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: implement tap support for receive_raw()Mark McLoughlin2009-10-271-4/+19
| | | | | | | | | | | tap_receive_raw() always prepends a vnet header if IFF_VNET_HDR is enabled. tap_receive() only prepends when the a header is required but the NIC doesn't supply one. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add receive_raw parameter to qemu_new_vlan_client()Mark McLoughlin2009-10-271-6/+8
| | | | | | | | | | Trivial patch to allow supplying a receive_raw function. A future cleanup should combine this function pointer parameters into a table. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add an API for 'raw' packetsMark McLoughlin2009-10-271-8/+29
| | | | | | | | | | In the case where a NIC and backend agree on a packet header format, this API allows injecting packets which lack the agreed upon header. We need this for sending our gratuitous ARP. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add flags parameter to packet queue interfaceMark McLoughlin2009-10-271-2/+12
| | | | | | | | This allows for the addition of a raw flag, and leaves the way open for other flags too. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add tap_has_vnet_hdr() and tap_using_vnet_hdr() APIsMark McLoughlin2009-10-271-4/+35
| | | | | | | | | These lamely named functions allow virtio-net to query whether IFF_VNET_HDR is enabled on a tap interface and inform the tap code that virtio-net will supply packets with a vnet header. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add a client type codeMark McLoughlin2009-10-271-7/+15
| | | | | | | | | This is so as to allow APIs which operate on specific client types without having to add a function table entry which is only implemented by a single client type. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add a vnet_hdr=on|off parameterMark McLoughlin2009-10-271-10/+32
| | | | | | | | | | | | | This allows people to disable the IFF_VNET_HDR flag, e.g. for debugging purposes or if they know they may migrate the guest to a machine without IFF_VNET_HDR support. It also allows making the lack of IFF_VNET_HDR support an error condition, e.g. in the case where a guest is being migrated from a host which does support it. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: refactor tap initializationMark McLoughlin2009-10-271-45/+52
| | | | | | | | | | | | | Re-factor things so that there is only one call site for net_tap_fd_init(). Two concerns about the QemuOpts usage here - firstly, we set the script arguments to their default value and, secondly, we set the ifname value to the name allocated by the kernel if none is supplied. Are we okay with such things ending up in writeconfig output? Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: enable IFF_VNET_HDR on tap fds if availableMark McLoughlin2009-10-271-13/+70
| | | | | | | | | | | | For now, we just add an empty header before writing and strip the header after reading. We really only want IFF_VNET_HDR when virtio_net is using it, but it would significantly complicate matters to try and do that. There should be little or no performance impact with always adding headers. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: make tap_receive() re-use tap_receive_iov() codeMark McLoughlin2009-10-271-8/+15
| | | | | | | | | In future we will want to prepend a virtio_net header if the NIC didn't supply one but IFF_VNET_HDR is enabled on the interface. This is most easily achived by using writev() in all cases. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: import linux tap ioctl definitionsMark McLoughlin2009-10-271-10/+1
| | | | | | | | | | | | Making features dependent on the availability of newer versions if_tun.h is going to get seriously clumsy, so let's just import the definitions we need. It's only a small handful. If and when we're comfortable depending on 2.6.30 headers, we can remove this again. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: add netdev propertyGerd Hoffmann2009-10-271-1/+1
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add macaddr type.Gerd Hoffmann2009-10-271-0/+15
| | | | | | | | | | Add new type for mac addresses. Add function which sets the qemu default mac address if it finds the mac address uninitialized (i.e. all zeros). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: fix multiple NICs causing net opts process to stopMark McLoughlin2009-10-151-1/+3
| | | | | | | | | | | | | | | | | | For NICs, net_init_client() returns the index into the NICInfo table. qemu_opts_foreach() interprets non-zero as an error return an stops iterating over the options. So, if you have more than one '-net nic' on the command line, subsequent '-net' options do not get processed. Fix this by making net_client_init() only return non-zero if net_init_client() returns an error. Reported-by: Peter Lieven <pl@dlh.net> Patchworks-ID: 35736 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add queue for peer-to-peer packet forwardingMark McLoughlin2009-10-151-13/+98
| | | | | | | | | Now that we have re-factored the packet queue code, we can re-use it for peer-to-peer also. Patchworks-ID: 35520 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: refactor packet queueing codeMark McLoughlin2009-10-151-115/+23
| | | | | | | | | | The packet queue code is fairly standalone, has some complex details and easily reusable. It makes sense to split it out on its own. This patch doesn't contain any functional changes. Patchworks-ID: 35511 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: allow NICs to be connected to netdevsMark McLoughlin2009-10-151-10/+25
| | | | | | | | | | Introduce a 'peer' member to VLANClientState as an alternative to a vlan. The idea being that packets are transfered directly from peer clients rather than going through a vlan. Patchworks-ID: 35516 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add -net nic,netdev= optionMark McLoughlin2009-10-151-5/+36
| | | | | | Patchworks-ID: 35515 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: maintain a list of vlan-less clientsMark McLoughlin2009-10-151-2/+11
| | | | | | | | | | | Allows them to be cleaned up at shutdown. This is pretty lame, but will eventually go away as we make vlans the special case. Patchworks-ID: 35518 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: handle -netdevice optionsMark McLoughlin2009-10-151-36/+92
| | | | | | | | | | | | | Same as for -net except for: - only tap, user, vde and socket types are supported - the vlan parameter is not allowed - the name parameter is not allowed but the id parameter is required Patchworks-ID: 35517 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: add QemuOptsList arg to net_client_parse()Mark McLoughlin2009-10-151-3/+4
| | | | | | Patchworks-ID: 35505 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: allow clients not associated with a vlanMark McLoughlin2009-10-151-7/+23
| | | | | | | | | | | | | Allow net clients to be created which are not connected to any vlan. This is needed by Gerd in order to allow adding -device nic, where the absence of a vlan parameter will not imply vlan=0. Also needed to allow adding a -netdevice option which doesn't connect the backend to a vlan. Patchworks-ID: 35513 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: use qtailq for vlan and client listsMark McLoughlin2009-10-151-58/+58
| | | | | | Patchworks-ID: 35507 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: remove id field from NICInfoMark McLoughlin2009-10-151-4/+0
| | | | | | | | | | | Just use the name field instead since we now use the id paramater as the name, if supplied. Only implication with this change is that if id is not supplied, the value of the name paramater is used as an id. Patchworks-ID: 35512 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: handle id= parameter for -netMark McLoughlin2009-10-151-28/+20
| | | | | | | | | Use id= in the same was as the current name= parameter; if both are specified, id= is used. Patchworks-ID: 35514 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* net: pass monitor handle to client init functionsMark McLoughlin2009-10-151-1/+1
| | | | | | | | | Needed for e.g. looking up a file descriptor name using monitor_get_fd() in net_init_tap() Patchworks-ID: 35509 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* slirp: fix !CONFIG_SLIRP compilationJuan Quintela2009-10-121-1/+4
| | | | | | | | This moves the code that depens on slirp under CONFIG_SLIRP again. Patchworks-ID: 35372 Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Final net cleanup after conversion to QemuOptsMark McLoughlin2009-10-061-58/+58
| | | | | | | | | | | | | | | | Now that net_client_init() has no users, kill it off and rename net_client_init_from_opts(). There is no further need for the old code in net_client_parse() either. We use qemu_opts_parse() 'firstname' facitity for that. Instead, move the special handling of the 'vmchannel' type there. Simplify the vl.c code into merely call net_client_parse() for each -net command line option and then calling net_init_clients() later to iterate over the options and create the clients. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Port usb net to QemuOptsMark McLoughlin2009-10-061-1/+1
| | | | | | | We need net_client_init_from_opts() exported for this Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>