Commit 07c0f09e authored by Hadar Hen Zion's avatar Hadar Hen Zion Committed by David S. Miller

net/sched: act_tunnel_key: Remove rcu_read_lock protection

Remove rcu_read_lock protection from tunnel_key_dump and use
rtnl_dereference, dump operation is protected by  rtnl lock.

Also, remove rcu_read_lock from tunnel_key_release and use
rcu_dereference_protected.

Both operations are running exclusively and a writer couldn't modify
t->params while those functions are executed.

Fixes: 54d94fd89d90 ('net/sched: Introduce act_tunnel_key')
Signed-off-by: default avatarHadar Hen Zion <hadarh@mellanox.com>
Acked-by: default avatarJohn Fastabend <john.r.fastabend@intel.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c0ca3f5
...@@ -194,15 +194,12 @@ static void tunnel_key_release(struct tc_action *a, int bind) ...@@ -194,15 +194,12 @@ static void tunnel_key_release(struct tc_action *a, int bind)
struct tcf_tunnel_key *t = to_tunnel_key(a); struct tcf_tunnel_key *t = to_tunnel_key(a);
struct tcf_tunnel_key_params *params; struct tcf_tunnel_key_params *params;
rcu_read_lock(); params = rcu_dereference_protected(t->params, 1);
params = rcu_dereference(t->params);
if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET) if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET)
dst_release(&params->tcft_enc_metadata->dst); dst_release(&params->tcft_enc_metadata->dst);
kfree_rcu(params, rcu); kfree_rcu(params, rcu);
rcu_read_unlock();
} }
static int tunnel_key_dump_addresses(struct sk_buff *skb, static int tunnel_key_dump_addresses(struct sk_buff *skb,
...@@ -245,10 +242,8 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -245,10 +242,8 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
.bindcnt = t->tcf_bindcnt - bind, .bindcnt = t->tcf_bindcnt - bind,
}; };
struct tcf_t tm; struct tcf_t tm;
int ret = -1;
rcu_read_lock(); params = rtnl_dereference(t->params);
params = rcu_dereference(t->params);
opt.t_action = params->tcft_action; opt.t_action = params->tcft_action;
opt.action = params->action; opt.action = params->action;
...@@ -272,15 +267,11 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -272,15 +267,11 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
&tm, TCA_TUNNEL_KEY_PAD)) &tm, TCA_TUNNEL_KEY_PAD))
goto nla_put_failure; goto nla_put_failure;
ret = skb->len; return skb->len;
goto out;
nla_put_failure: nla_put_failure:
nlmsg_trim(skb, b); nlmsg_trim(skb, b);
out: return -1;
rcu_read_unlock();
return ret;
} }
static int tunnel_key_walker(struct net *net, struct sk_buff *skb, static int tunnel_key_walker(struct net *net, struct sk_buff *skb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment