linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	willemdebruijn.kernel@gmail.com, tom@herbertland.com,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH net-next V2 3/3] tun: add eBPF based queue selection method
Date: Thu, 2 Nov 2017 11:24:16 +0800	[thread overview]
Message-ID: <673b759a-cc35-e5db-4dd4-9677ab40d2a0@redhat.com> (raw)
In-Reply-To: <20171101191213.2h5rlawpbnqtq662@ast-mbp>



On 2017年11月02日 03:12, Alexei Starovoitov wrote:
> On Wed, Nov 01, 2017 at 03:59:48PM +0200, Michael S. Tsirkin wrote:
>> On Wed, Nov 01, 2017 at 09:02:03PM +0800, Jason Wang wrote:
>>>
>>> On 2017年11月01日 00:45, Michael S. Tsirkin wrote:
>>>>> +static void __tun_set_steering_ebpf(struct tun_struct *tun,
>>>>> +				    struct bpf_prog *new)
>>>>> +{
>>>>> +	struct bpf_prog *old;
>>>>> +
>>>>> +	old = rtnl_dereference(tun->steering_prog);
>>>>> +	rcu_assign_pointer(tun->steering_prog, new);
>>>>> +
>>>>> +	if (old) {
>>>>> +		synchronize_net();
>>>>> +		bpf_prog_destroy(old);
>>>>> +	}
>>>>> +}
>>>>> +
>>>> Is this really called under rtnl?
>>> Yes it is __tun_chr_ioctl() will call rtnl_lock().
>> Is the call from tun_free_netdev under rtnl too?
>>
>>>> If no then rtnl_dereference
>>>> is wrong. If yes I'm not sure you can call synchronize_net
>>>> under rtnl.
>>>>
>>> Are you worrying about the long wait? Looking at synchronize_net(), it does:
>>>
>>> void synchronize_net(void)
>>> {
>>>      might_sleep();
>>>      if (rtnl_is_locked())
>>>          synchronize_rcu_expedited();
>>>      else
>>>          synchronize_rcu();
>>> }
>>> EXPORT_SYMBOL(synchronize_net);
>>>
>>> Thanks
>> Not the wait - expedited is not a good thing to allow unpriveledged
>> userspace to do, it interrupts all VMs running on the same box.
>>
>> We could use a callback though the docs warn userspace can use that
>> to cause a DOS and needs to be limited.
> the whole __tun_set_steering_ebpf() looks odd to me.
> There is tun_attach_filter/tun_detach_filter pattern
> that works for classic BPF. Why for eBPF this strange
> synchronize_net() is there?
>

I'm not sure I get the question. eBPF here is used to do queue 
selection, so we could not reuse socket filter (tun_detach_filter use 
call_rcu()). cBPF could be used here, but I'm not quite sure it's worth 
to support it. And I agree we should use call_rcu() here.

Hope this answer your question.

Thanks

  reply	other threads:[~2017-11-02  3:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 10:32 [PATCH net-next V2 0/3] support changing steering policies in tuntap Jason Wang
2017-10-31 10:32 ` [PATCH net-next V2 1/3] tun: abstract flow steering logic Jason Wang
2017-11-02  1:11   ` Willem de Bruijn
2017-11-02  3:43     ` Jason Wang
2017-11-02  3:45       ` Michael S. Tsirkin
2017-11-02  3:51         ` Jason Wang
2017-11-03  8:49           ` Willem de Bruijn
2017-10-31 10:32 ` [PATCH net-next V2 2/3] tun: introduce ioctls to set and get steering policies Jason Wang
2017-11-02  1:15   ` Willem de Bruijn
2017-10-31 10:32 ` [PATCH net-next V2 3/3] tun: add eBPF based queue selection method Jason Wang
2017-10-31 16:45   ` Michael S. Tsirkin
2017-11-01 13:02     ` Jason Wang
2017-11-01 13:59       ` Michael S. Tsirkin
2017-11-01 19:12         ` Alexei Starovoitov
2017-11-02  3:24           ` Jason Wang [this message]
2017-11-02  3:45         ` Jason Wang
2017-11-03  8:56   ` Willem de Bruijn
2017-11-03 23:56     ` Willem de Bruijn
2017-11-08  5:28       ` Jason Wang
2017-11-08  5:43         ` Michael S. Tsirkin
2017-11-08 11:13           ` Jason Wang

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=673b759a-cc35-e5db-4dd4-9677ab40d2a0@redhat.com \
    --to=jasowang@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=tom@herbertland.com \
    --cc=willemdebruijn.kernel@gmail.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).