qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Anton Ivanov (antivano)" <antivano@cisco.com>
To: Jan Kiszka <jan.kiszka@siemens.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [PULL 2/4] net: L2TPv3 transport
Date: Tue, 1 Jul 2014 15:23:27 +0000	[thread overview]
Message-ID: <53B2D26D.6090108@cisco.com> (raw)
In-Reply-To: <53B2A440.6010706@siemens.com>

On 01/07/14 13:06, Jan Kiszka wrote:
> On 2014-06-27 16:24, Stefan Hajnoczi wrote:
>> From: Anton Ivanov <antivano@cisco.com>
>>
>> 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 <antivano@cisco.com>
>> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>> ---
>>  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	other threads:[~2014-07-01 15:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-27 14:24 [Qemu-devel] [PULL for-2.1 0/4] Net patches Stefan Hajnoczi
2014-06-27 14:24 ` [Qemu-devel] [PULL 1/4] qemu-bridge-helper: Fix fd leak in main() Stefan Hajnoczi
2014-06-27 14:24 ` [Qemu-devel] [PULL 2/4] net: L2TPv3 transport Stefan Hajnoczi
2014-07-01 12:06   ` Jan Kiszka
2014-07-01 15:23     ` Anton Ivanov (antivano) [this message]
2014-06-27 14:24 ` [Qemu-devel] [PULL 3/4] net: move queue number into NICPeers Stefan Hajnoczi
2014-06-27 14:24 ` [Qemu-devel] [PULL 4/4] hw/net/eepro100: Implement read-only bits in MDI registers Stefan Hajnoczi
2014-06-29 12:38 ` [Qemu-devel] [PULL for-2.1 0/4] Net patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53B2D26D.6090108@cisco.com \
    --to=antivano@cisco.com \
    --cc=jan.kiszka@siemens.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).