Re: [PATCH net-next V2 3/3] tun: add eBPF based queue selection method
From: Jason Wang
Date: Wed Nov 01 2017 - 09:02:15 EST
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().
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