qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Paul Moore <paul.moore@hp.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [Qemu-devel] [PATCH] tun: orphan an skb on tx
Date: Sun, 1 Feb 2015 14:26:11 +0200	[thread overview]
Message-ID: <20150201122611.GA8883@redhat.com> (raw)
In-Reply-To: <1422789633.11044.18.camel@infradead.org>

On Sun, Feb 01, 2015 at 11:20:33AM +0000, David Woodhouse wrote:
> On Wed, 2010-04-14 at 08:58 +0800, Herbert Xu wrote:
> > On Tue, Apr 13, 2010 at 08:31:03PM +0200, Eric Dumazet wrote:
> > >
> > > Herbert Acked your patch, so I guess its OK, but I think it can be
> > > dangerous.
> > 
> > The tun socket accounting was never designed to stop it from
> > flooding another tun interface.  It's there to stop it from
> > transmitting above a destination interface TX bandwidth and
> > cause unnecessary packet drops.  It also limits the total amount
> > of kernel memory that can be pinned down by a single tun interface.
> > 
> > In this case, all we're doing is shifting the accounting from the
> > "hardware" queue to the qdisc queue.
> > 
> > So your ability to flood a tun interface is essentially unchanged.
> 
> I've just been looking at VPN performance, using netperf to flood an
> openconnect/ocserv connection over GigE and profiling my VPN client.
> 
> If I run netperf over the *unencrypted* link, it only sends 1Gb/s of
> packets — because the packets are correctly accounted to netperf's UDP
> socket until the moment they're actually transmitted on the wire, and
> the backpressure works correctly.
> 
> When I run over the VPN, netperf thinks it sent 2½ times the amount of
> TX traffic.

At some level, it's expected: netperf's manual actually says:
	A UDP_STREAM test has no end-to-end flow control - UDP provides none and
	neither does netperf. However, if you wish, you can configure netperf
	with --enable-intervals=yes to enable the global command-line -b and -w
	options to pace bursts of traffic onto the network.

> Packets are being dropped by the tun device before even
> feeding them up to the VPN client to be sent — presumably because of
> this skb_orphan() call. (The client itself should do the right thing,
> and only suck packets out of the tun at the rate it can shove them out
> *its* UDP socket.)

A simple work-around is to limit the rate using a non work conservig qdisc.

> Did we ever look at the alternative solution of taking ownership only
> after a timeout, or on demand when we need to shut down the device?

I've been thinking about this on and off, but didn't find a good
safe solution yet.

For timeout, the difficulty is to find a good timer value,
low enough to avoid DOS attacks but high enough to avoid
spurious packet drops (and expensive timer interrupts).

-- 
MST

  reply	other threads:[~2015-02-01 12:27 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-13 14:59 [Qemu-devel] [PATCH] tun: orphan an skb on tx Michael S. Tsirkin
2010-04-13 15:12 ` [Qemu-devel] " Herbert Xu
2010-04-13 15:36 ` Jan Kiszka
2010-04-13 16:40   ` Eric Dumazet
2010-04-13 16:52     ` Jan Kiszka
2010-04-13 17:39     ` Michael S. Tsirkin
2010-04-13 18:31       ` Eric Dumazet
2010-04-13 20:25         ` Michael S. Tsirkin
2010-04-13 20:38           ` Eric Dumazet
2010-04-13 20:43             ` Michael S. Tsirkin
2010-04-14  0:58         ` Herbert Xu
2010-04-14 11:55           ` David Miller
2015-02-01 11:20           ` [Qemu-devel] " David Woodhouse
2015-02-01 12:26             ` Michael S. Tsirkin [this message]
2015-02-01 13:33               ` David Woodhouse
2015-02-01 20:19                 ` David Miller
2015-02-01 21:29                   ` David Woodhouse
2015-02-02  5:07                     ` David Miller
2015-02-02  7:27                       ` David Woodhouse
2015-02-02  8:24                         ` Steffen Klassert
2015-02-02 15:30                           ` David Woodhouse
2015-02-02 15:23                         ` Phil Sutter
2015-02-02 15:47                           ` David Woodhouse
2015-02-04  0:19                         ` David Miller
2015-02-04  6:35                           ` David Woodhouse
2010-04-21 11:35 ` [Qemu-devel] " Michael S. Tsirkin
2010-04-21 11:46   ` Jan Kiszka
2010-04-21 11:45     ` Michael S. Tsirkin
2010-04-21 19:16   ` [Qemu-devel] Re: [stable] " Greg KH

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=20150201122611.GA8883@redhat.com \
    --to=mst@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dwmw2@infradead.org \
    --cc=eric.dumazet@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paul.moore@hp.com \
    --cc=qemu-devel@nongnu.org \
    /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).