Net patches
The following changes since commit ff4873cb8c81db89668d8b56e19e57b852edb5f5:
coroutine-win32.c: Add noinline attribute to work around gcc bug (2014-06-26 14:08:14 +0100)
are available in the git repository at:
git://github.com/stefanha/qemu.git tags/net-pull-request
for you to fetch changes up to 5e80dd223ded254b1802bdd6417ef118456eadce:
hw/net/eepro100: Implement read-only bits in MDI registers (2014-06-27 12:23:45 +0200)
----------------------------------------------------------------
Net patches
----------------------------------------------------------------
Anton Ivanov (1):
net: L2TPv3 transport
Gonglei (1):
qemu-bridge-helper: Fix fd leak in main()
Jiri Pirko (1):
net: move queue number into NICPeers
Peter Maydell (1):
hw/net/eepro100: Implement read-only bits in MDI registers
hw/core/qdev-properties-system.c | 3 +- hw/net/eepro100.c | 4 +- hw/net/virtio-net.c | 2 +- include/net/net.h | 2 +- net/Makefile.objs | 1 + net/clients.h | 2 + net/l2tpv3.c | 757 +++++++++++++++++++++++++++++++++++++++ net/net.c | 10 +- qapi-schema.json | 60 ++++ qemu-bridge-helper.c | 9 +- qemu-options.hx | 82 +++++ 11 files changed, 922 insertions(+), 10 deletions(-) create mode 100644 net/l2tpv3.c
Signature · 1 line
1.9.3
[Qemu-devel] [PULL 1/4] qemu-bridge-helper: Fix fd leak in main()
From: Gonglei <[email protected]>
initialize fd and ctlfd, and close them at the end
--- qemu-bridge-helper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
qemu-bridge-helper.c +7 -2
@@ -229,7 +229,7 @@ int main(int argc, char **argv)unsigned long ifargs[4 ];#endif int ifindex; -int fd, ctlfd, unixfd =-1 ; +int fd =-1 , ctlfd =-1 , unixfd =-1 ;int use_vnet =0 ;int mtu;const char *bridge =NULL ;
@@ -436,7 +436,12 @@ int main(int argc, char **argv)/* profit! */ cleanup: - +if (fd >=0 ) { +close (fd); + } +if (ctlfd >=0 ) { +close (ctlfd); + }while ((acl_rule =QSIMPLEQ_FIRST (&acl_list)) !=NULL ) {QSIMPLEQ_REMOVE_HEAD (&acl_list, entry);g_free (acl_rule);
Signature · 1 line
1.9.3
[Qemu-devel] [PULL 2/4] net: L2TPv3 transport
In reply to Stefan HajnocziFrom: Anton Ivanov <[email protected]>
This transport allows to connect a QEMU nic to a static Ethernet over L2TPv3 tunnel. The transport supports all options present in the Linux kernel implementation. It allows QEMU to connect to any Linux host running kernel 3.3+, most routers and network devices as well as other QEMU instances.
[Fixed up net_client_init1() switch statement to support -netdev --Stefan]
--- net/Makefile.objs | 1 + net/clients.h | 2 + net/l2tpv3.c | 757 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 6 + qapi-schema.json | 60 +++++ qemu-options.hx | 82 ++++++ 6 files changed, 908 insertions(+) create mode 100644 net/l2tpv3.c
net/Makefile.objs +1 -0
@@ -2,6 +2,7 @@ common-obj-y = net.o queue.o checksum.o util.o hub.o common-obj-y += socket.o common-obj-y += dump.o common-obj-y += eth.o +common-obj-$(CONFIG_LINUX) += l2tpv3.o common-obj-$(CONFIG_POSIX) += tap.o vhost-user.o common-obj-$(CONFIG_LINUX) += tap-linux.o common-obj-$(CONFIG_WIN32) += tap-win32.o
net/clients.h +2 -0
@@ -47,6 +47,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,int net_init_bridge (const NetClientOptions *opts,const char *name,NetClientState *peer); +int net_init_l2tpv3 (const NetClientOptions *opts,const char *name, +NetClientState *peer);#ifdef CONFIG_VDE int net_init_vde (const NetClientOptions *opts,const char *name,NetClientState *peer);
net/l2tpv3.c new file +757 -0
757 lines not on this page · raw message
net/net.c +6 -0
@@ -806,6 +806,9 @@ static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( #ifdef CONFIG_VHOST_NET_USED [NET_CLIENT_OPTIONS_KIND_VHOST_USER ] = net_init_vhost_user, #endif +#ifdef CONFIG_LINUX + [NET_CLIENT_OPTIONS_KIND_L2TPV3] = net_init_l2tpv3, +#endif };
@@ -842,6 +845,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)#ifdef CONFIG_VHOST_NET_USED case NET_CLIENT_OPTIONS_KIND_VHOST_USER :#endif +#ifdef CONFIG_LINUX +case NET_CLIENT_OPTIONS_KIND_L2TPV3 : +#endif break ;default :
qapi-schema.json +60 -0
78 lines not on this page · raw message
qemu-options.hx +82 -0
94 lines not on this page · raw message
Signature · 1 line
1.9.3
[Qemu-devel] [PULL 4/4] hw/net/eepro100: Implement read-only bits in MDI registers
In reply to Stefan HajnocziFrom: Peter Maydell <[email protected]>
Although we defined an eepro100_mdi_mask[] array indicating which bits in the registers are read-only, we weren't actually doing anything with it. Make the MDI register-write code use it rather than manually making register 1 read-only and leaving the rest as reads-as-written. (The special-case handling of register 0 remains as before since its mask is all-zeros and the special casing happens before we apply the masking.)
Message-id: [email protected]
--- hw/net/eepro100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/eepro100.c +2 -2
@@ -1217,7 +1217,6 @@ static void eepro100_write_mdi(EEPRO100State *s)break ;case 1 :/* Status Register */ missing ("not writable" ); - data = s->mdimem[reg];break ;case 2 :/* PHY Identification Register (Word 1) */ case 3 :/* PHY Identification Register (Word 2) */
@@ -1230,7 +1229,8 @@ static void eepro100_write_mdi(EEPRO100State *s)default :missing ("not implemented" ); } - s->mdimem[reg] = data; + s->mdimem[reg] &= eepro100_mdi_mask[reg]; + s->mdimem[reg] |= data & ~eepro100_mdi_mask[reg]; }else if (opcode ==2 ) {/* MDI read */ switch (reg) {
Signature · 1 line
1.9.3
[Qemu-devel] [PULL 3/4] net: move queue number into NICPeers
In reply to Stefan HajnocziFrom: Jiri Pirko <[email protected]>
It indicates the number of elements in ncs field and makes sense to have int inside NICPeers. Also in parse_netdev we do not need to access container and work with NICPeers only.
--- hw/core/qdev-properties-system.c | 3 +-- hw/net/virtio-net.c | 2 +- include/net/net.h | 2 +- net/net.c | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-)
hw/core/qdev-properties-system.c +1 -2
@@ -180,7 +180,6 @@ PropertyInfo qdev_prop_chr = {static int parse_netdev (DeviceState *dev,const char *str,void **ptr) {NICPeers *peers_ptr = (NICPeers *)ptr; -NICConf *conf =container_of (peers_ptr, NICConf, peers);NetClientState **ncs = peers_ptr->ncs;NetClientState *peers[MAX_QUEUE_NUM ];int queues, i =0 ;
@@ -219,7 +218,7 @@ static int parse_netdev(DeviceState *dev, const char *str, void **ptr) ncs[i]->queue_index = i; } - conf->queues = queues; + peers_ptr->queues = queues;return 0 ;
hw/net/virtio-net.c +1 -1
@@ -1542,7 +1542,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)virtio_init (vdev,"virtio-net" ,VIRTIO_ID_NET , n->config_size); - n->max_queues =MAX (n->nic_conf.queues,1 ); + n->max_queues =MAX (n->nic_conf.peers.queues,1 ); n->vqs =g_malloc0 (sizeof (VirtIONetQueue) * n->max_queues); n->vqs[0 ].rx_vq =virtio_add_queue (vdev,256 , virtio_net_handle_rx); n->curr_queues =1 ;
include/net/net.h +1 -1
@@ -24,13 +24,13 @@ struct MACAddr {typedef struct NICPeers {NetClientState *ncs[MAX_QUEUE_NUM ]; +int32_t queues; }NICPeers ;typedef struct NICConf {MACAddr macaddr;NICPeers peers;int32_t bootindex; -int32_t queues; }NICConf ;#define DEFINE_NIC_PROPERTIES (_state, _conf) \
net/net.c +2 -2
@@ -250,7 +250,7 @@ NICState *qemu_new_nic(NetClientInfo *info, {NetClientState **peers = conf->peers.ncs;NICState *nic; -int i, queues =MAX (1 , conf->queues); +int i, queues =MAX (1 , conf->peers.queues);assert (info->type ==NET_CLIENT_OPTIONS_KIND_NIC );assert (info->size >=sizeof (NICState));
@@ -363,7 +363,7 @@ void qemu_del_net_client(NetClientState *nc)void qemu_del_nic (NICState *nic) { -int i, queues =MAX (nic->conf->queues,1 ); +int i, queues =MAX (nic->conf->peers.queues,1 );/* If this is a peer NIC and peer has already been deleted, free it now. */ if (nic->peer_deleted) {
Signature · 1 line
1.9.3
Peter Maydell
AppliedQuoted 8 lines · Stefan Hajnoczi
The following changes since commit
ff4873cb8c81db89668d8b56e19e57b852edb5f5:
coroutine-win32.c: Add noinline attribute to work around gcc bug (2014-06-26 14:08:14 +0100)are available in the git repository at:
git://github.com/stefanha/qemu.gittags/net-pull-request
Quoted 8 lines
for you to fetch changes up to
5e80dd223ded254b1802bdd6417ef118456eadce:hw/net/eepro100: Implement read-only bits in MDI registers (2014-06-27 12:23:45 +0200)
----------------------------------------------------------------
Net patches----------------------------------------------------------------
Applied, thanks.
-- PMM
Re: [Qemu-devel] [PULL 2/4] net: L2TPv3 transport
In reply to Stefan HajnocziQuoted 121 lines · Stefan Hajnoczi
From: Anton Ivanov <[email protected]>
This transport allows to connect a QEMU nic to a static Ethernet over L2TPv3 tunnel. The transport supports all options present in the Linux kernel implementation. It allows QEMU to connect to any Linux host running kernel 3.3+, most routers and network devices as well as other QEMU instances.
[Fixed up
net_client_init1()switch statement to support -netdev --Stefan]Signed-off-by Anton Ivanov <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- net/Makefile.objs | 1 + net/clients.h | 2 + net/l2tpv3.c | 757 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 6 + qapi-schema.json | 60 +++++ qemu-options.hx | 82 ++++++ 6 files changed, 908 insertions(+) create mode 100644 net/l2tpv3.cnet/Makefile.objs +1
-0@@ -2,6 +2,7 @@ common-obj-y = net.o queue.o checksum.o util.o hub.o common-obj-y += socket.o common-obj-y += dump.o common-obj-y += eth.o +common-obj-$(CONFIG_LINUX) += l2tpv3.o common-obj-$(CONFIG_POSIX) += tap.o vhost-user.o common-obj-$(CONFIG_LINUX) += tap-linux.o common-obj-$(CONFIG_WIN32) += tap-win32.onet/clients.h +2
-0@@ -47,6 +47,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,int net_init_bridge (const NetClientOptions *opts,const char *name,NetClientState *peer); +int net_init_l2tpv3 (const NetClientOptions *opts,const char *name, +NetClientState *peer);#ifdef CONFIG_VDE int net_init_vde (const NetClientOptions *opts,const char *name,NetClientState *peer);net/l2tpv3.c new file +67
-0@@ -0,0 +1,757 @@ +/* +* QEMU System Emulator +* +* Copyright (c) 2003-2008 Fabrice Bellard +* Copyright (c) 2012-2014 Cisco Systems +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <linux/ip.h> +#include <netdb.h> +#include "config-host.h" +#include "net/net.h" +#include "clients.h" +#include "monitor/monitor.h" +#include "qemu-common.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" +#include "qemu/main-loop.h" + + +/* The buffer size needs to be investigated for optimum numbers and +* optimum means of paging in on different systems. This size is +* chosen to be sufficient to accommodate one packet with some headers +*/ + +#define BUFFER_ALIGN sysconf(_SC_PAGESIZE) +#define BUFFER_SIZE 2048 +#define IOVSIZE 2 +#define MAX_L2TPV3_MSGCNT 64 +#define MAX_L2TPV3_IOVCNT (MAX_L2TPV3_MSGCNT * IOVSIZE) + +/* Header set to 0x30000 signifies a data packet */ + +#define L2TPV3_DATA_PACKET 0x30000 + +/* IANA-assigned IP protocol ID for L2TPv3 */ + +#ifndef IPPROTO_L2TP +#define IPPROTO_L2TP 0x73 +#endif + +typedef struct NetL2TPV3State { + NetClientState nc; + int fd; + + /* + * these are used for xmit - that happens packet a time + * and for first sign of life packet (easier to parse that once)
net/l2tpv3.c line 77
Quoted 10 lines
net/l2tpv3.c new file +10
-0+*/ + +uint8_t *header_buf; +struct iovec *vec; + +/* +* these are used for receive - try to "eat" up to 32 packets at a time +*/ + +struct mmsghdr *msgvec;
struct mmsghdr is only available with recent distro kernel headers. Please check if it's there and otherwise disable L2TPv3 (or provide the struct yourself).
Thanks,
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PULL 2/4] net: L2TPv3 transport
Quoted 125 lines · Jan Kiszka
Quoted 124 lines · Stefan Hajnoczi
From: Anton Ivanov <[email protected]>
This transport allows to connect a QEMU nic to a static Ethernet over L2TPv3 tunnel. The transport supports all options present in the Linux kernel implementation. It allows QEMU to connect to any Linux host running kernel 3.3+, most routers and network devices as well as other QEMU instances.
[Fixed up
net_client_init1()switch statement to support -netdev --Stefan]Signed-off-by Anton Ivanov <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- net/Makefile.objs | 1 + net/clients.h | 2 + net/l2tpv3.c | 757 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 6 + qapi-schema.json | 60 +++++ qemu-options.hx | 82 ++++++ 6 files changed, 908 insertions(+) create mode 100644 net/l2tpv3.cnet/Makefile.objs +1
-0@@ -2,6 +2,7 @@ common-obj-y = net.o queue.o checksum.o util.o hub.o common-obj-y += socket.o common-obj-y += dump.o common-obj-y += eth.o +common-obj-$(CONFIG_LINUX) += l2tpv3.o common-obj-$(CONFIG_POSIX) += tap.o vhost-user.o common-obj-$(CONFIG_LINUX) += tap-linux.o common-obj-$(CONFIG_WIN32) += tap-win32.onet/clients.h +2
-0@@ -47,6 +47,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,int net_init_bridge (const NetClientOptions *opts,const char *name,NetClientState *peer); +int net_init_l2tpv3 (const NetClientOptions *opts,const char *name, +NetClientState *peer);#ifdef CONFIG_VDE int net_init_vde (const NetClientOptions *opts,const char *name,NetClientState *peer);net/l2tpv3.c new file +70
-0@@ -0,0 +1,757 @@ +/* +* QEMU System Emulator +* +* Copyright (c) 2003-2008 Fabrice Bellard +* Copyright (c) 2012-2014 Cisco Systems +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <linux/ip.h> +#include <netdb.h> +#include "config-host.h" +#include "net/net.h" +#include "clients.h" +#include "monitor/monitor.h" +#include "qemu-common.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" +#include "qemu/main-loop.h" + + +/* The buffer size needs to be investigated for optimum numbers and +* optimum means of paging in on different systems. This size is +* chosen to be sufficient to accommodate one packet with some headers +*/ + +#define BUFFER_ALIGN sysconf(_SC_PAGESIZE) +#define BUFFER_SIZE 2048 +#define IOVSIZE 2 +#define MAX_L2TPV3_MSGCNT 64 +#define MAX_L2TPV3_IOVCNT (MAX_L2TPV3_MSGCNT * IOVSIZE) + +/* Header set to 0x30000 signifies a data packet */ + +#define L2TPV3_DATA_PACKET 0x30000 + +/* IANA-assigned IP protocol ID for L2TPv3 */ + +#ifndef IPPROTO_L2TP +#define IPPROTO_L2TP 0x73 +#endif + +typedef struct NetL2TPV3State { + NetClientState nc; + int fd; + + /* + * these are used for xmit - that happens packet a time + * and for first sign of life packet (easier to parse that once) + */ + + uint8_t *header_buf;
Quoted 8 lines
net/l2tpv3.c line 77
Quoted 7 lines
net/l2tpv3.c new file +7
-0+struct iovec *vec; + +/* +* these are used for receive - try to "eat" up to 32 packets at a time +*/ + +struct mmsghdr *msgvec;struct mmsghdr is only available with recent distro kernel headers.
Agree - it needs a check.
Recent - not so much. It was introduced in 2.6.32. So if you are building vs kernel headers it takes something really really really old for it not to build.
Userspace and glibc - I believe it appeared for the first time in Ubuntu LTS 12.0 and in one of RHEL updates which are now more than 2 years old:
$ grep mmsghdr /usr/include/x86_64-linux-gnu/bits/socket.h struct mmsghdr extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
So on an up-to date distro you should have no problems with it. Even RHEL 6.0 has that function (though it may lack the headers for it).
In any case, I agree we need a check and disable recvmmsg probably in favor of a wrapper that emulates it by invoking recvmsg multiple times if it is not present.
A.
Quoted 6 lines
Please check if it's there and otherwise disable L2TPv3 (or provide the struct yourself).
Thanks,
Jan