From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1zuG-0003Gg-D0 for qemu-devel@nongnu.org; Tue, 01 Jul 2014 11:23:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1zu6-0006nk-4X for qemu-devel@nongnu.org; Tue, 01 Jul 2014 11:23:40 -0400 Received: from rcdn-iport-8.cisco.com ([173.37.86.79]:23331) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1zu5-0006na-RC for qemu-devel@nongnu.org; Tue, 01 Jul 2014 11:23:30 -0400 From: "Anton Ivanov (antivano)" Date: Tue, 1 Jul 2014 15:23:27 +0000 Message-ID: <53B2D26D.6090108@cisco.com> References: <1403879093-786-1-git-send-email-stefanha@redhat.com> <1403879093-786-3-git-send-email-stefanha@redhat.com> <53B2A440.6010706@siemens.com> In-Reply-To: <53B2A440.6010706@siemens.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-15" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PULL 2/4] net: L2TPv3 transport List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka , Stefan Hajnoczi , "qemu-devel@nongnu.org" Cc: Peter Maydell On 01/07/14 13:06, Jan Kiszka wrote: > On 2014-06-27 16:24, Stefan Hajnoczi wrote: >> From: Anton Ivanov >> >> 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 >> Signed-off-by: Stefan Hajnoczi >> --- >> 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 >> >> diff --git a/net/Makefile.objs b/net/Makefile.objs >> index 301f6b6..a06ba59 100644 >> --- a/net/Makefile.objs >> +++ b/net/Makefile.objs >> @@ -2,6 +2,7 @@ common-obj-y =3D net.o queue.o checksum.o util.o hub.o >> common-obj-y +=3D socket.o >> common-obj-y +=3D dump.o >> common-obj-y +=3D eth.o >> +common-obj-$(CONFIG_LINUX) +=3D l2tpv3.o >> common-obj-$(CONFIG_POSIX) +=3D tap.o vhost-user.o >> common-obj-$(CONFIG_LINUX) +=3D tap-linux.o >> common-obj-$(CONFIG_WIN32) +=3D tap-win32.o >> diff --git a/net/clients.h b/net/clients.h >> index 7f3d4ae..2e8feda 100644 >> --- a/net/clients.h >> +++ b/net/clients.h >> @@ -47,6 +47,8 @@ int net_init_tap(const NetClientOptions *opts, const c= har *name, >> int net_init_bridge(const NetClientOptions *opts, const char *name, >> NetClientState *peer); >> =20 >> +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); >> diff --git a/net/l2tpv3.c b/net/l2tpv3.c >> new file mode 100644 >> index 0000000..528d95b >> --- /dev/null >> +++ b/net/l2tpv3.c >> @@ -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 obtainin= g a copy >> + * of this software and associated documentation files (the "Software")= , to deal >> + * in the Software without restriction, including without limitation th= e rights >> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or= sell >> + * copies of the Software, and to permit persons to whom the Software i= s >> + * furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be inclu= ded in >> + * all copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPR= ESS OR >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL= ITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SH= ALL >> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR= OTHER >> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARIS= ING FROM, >> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALIN= GS IN >> + * THE SOFTWARE. >> + */ >> + >> +#include >> +#include >> +#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; >> + 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. > Please check if it's there and otherwise disable L2TPv3 (or provide the > struct yourself). > > Thanks, > Jan >