qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL 2/4] net: L2TPv3 transport


From: Anton Ivanov (antivano)
Subject: Re: [Qemu-devel] [PULL 2/4] net: L2TPv3 transport
Date: Tue, 1 Jul 2014 15:23:27 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0

On 01/07/14 13:06, Jan Kiszka wrote:
> On 2014-06-27 16:24, Stefan Hajnoczi wrote:
>> From: Anton Ivanov <address@hidden>
>>
>> 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 <address@hidden>
>> Signed-off-by: Stefan Hajnoczi <address@hidden>
>> ---
>>  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 = 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
>> 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 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);
>> 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 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;
>> +    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
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]