Re: [PATCH net-net] tun: Assign missing bpf_net_context.
From: Breno Leitao
Date: Thu Sep 12 2024 - 10:20:16 EST
Hello Vadim,
On Thu, Sep 12, 2024 at 02:32:55PM +0100, Vadim Fedorenko wrote:
> On 12/09/2024 14:17, Breno Leitao wrote:
> > @@ -72,6 +73,7 @@ static netdev_tx_t netkit_xmit(struct sk_buff *skb, struct net_device *dev)
> > struct net_device *peer;
> > int len = skb->len;
> > + bpf_net_ctx = bpf_net_ctx_set(&__bpf_net_ctx);
> > rcu_read_lock();
>
> Hi Breno,
>
> looks like bpf_net_ctx should be set under rcu read lock...
Why exactly?
I saw in some examples where bpf_net_ctx_set() was set inside the
rcu_read_lock(), but, I was not able to come up with justification to do
the same. Would you mind elaborating why this might be needed inside the
lock?
Thanks for the review,
--breno