On Thu, 2016-09-08 at 16:23 +0300, Hadar Hen Zion wrote:
> From: Amir Vadai <[email protected]>
>
> This action could be used before redirecting packets to a shared tunnel
> device, or when redirecting packets arriving from a such a device.
> +static void tunnel_key_release(struct tc_action *a, int bind)
> +{
> + struct tcf_tunnel_key *t = to_tunnel_key(a);
> + struct tcf_tunnel_key_params *params;
> +
> + rcu_read_lock();
> + params = rcu_dereference(t->params);
> +
> + if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET)
> + dst_release(¶ms->tcft_enc_metadata->dst);
> +
> + kfree_rcu(params, rcu);
> +
> + rcu_read_unlock();
> +}
Note that you own the action here, so technically speaking no writer
could possibly modify t->params while this function is running.
So you could use
params = rcu_dereference_protected(t->params, 1)
(I could not find a way to express the 'I own this action and am the
last user' for LOCKDEP sake so I used 1)
instead of
rcu_read_lock();
params = rcu_dereference(t->params);
rcu_read_unlock();
But this is a very minor detail, and this patch looks fine to me, thanks
a lot for your patience Hadar .
Acked-by: Eric Dumazet <[email protected]>