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:the whole __tun_set_steering_ebpf() looks odd to me.
Is the call from tun_free_netdev under rtnl too?
On 2017å11æ01æ 00:45, Michael S. Tsirkin wrote:
Yes it is __tun_chr_ioctl() will call rtnl_lock().+static void __tun_set_steering_ebpf(struct tun_struct *tun,Is this really called under rtnl?
+ 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);
+ }
+}
+
Not the wait - expedited is not a good thing to allow unpriveledgedIf no then rtnl_dereferenceAre you worrying about the long wait? Looking at synchronize_net(), it does:
is wrong. If yes I'm not sure you can call synchronize_net
under rtnl.
void synchronize_net(void)
{
ÂÂÂ might_sleep();
ÂÂÂ if (rtnl_is_locked())
ÂÂÂ ÂÂÂ synchronize_rcu_expedited();
ÂÂÂ else
ÂÂÂ ÂÂÂ synchronize_rcu();
}
EXPORT_SYMBOL(synchronize_net);
Thanks
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.
There is tun_attach_filter/tun_detach_filter pattern
that works for classic BPF. Why for eBPF this strange
synchronize_net() is there?