* [PATCH net-next] net/sched: act_tunnel_key: Remove rcu_read_lock protection
@ 2016-09-12 12:19 Hadar Hen Zion
2016-09-12 14:09 ` John Fastabend
2016-09-15 23:18 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Hadar Hen Zion @ 2016-09-12 12:19 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, Jiri Pirko, Jiri Benc, Jamal Hadi Salim, Shmulik Ladkani,
Tom Herbert, Eric Dumazet, Cong Wang, Amir Vadai, Or Gerlitz,
Hadar Hen Zion
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: Hadar Hen Zion <hadarh@mellanox.com>
---
net/sched/act_tunnel_key.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
index dceff74..af47bdf 100644
--- a/net/sched/act_tunnel_key.c
+++ b/net/sched/act_tunnel_key.c
@@ -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_params *params;
- rcu_read_lock();
- params = rcu_dereference(t->params);
+ params = rcu_dereference_protected(t->params, 1);
if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET)
dst_release(¶ms->tcft_enc_metadata->dst);
kfree_rcu(params, rcu);
-
- rcu_read_unlock();
}
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,
.bindcnt = t->tcf_bindcnt - bind,
};
struct tcf_t tm;
- int ret = -1;
- rcu_read_lock();
- params = rcu_dereference(t->params);
+ params = rtnl_dereference(t->params);
opt.t_action = params->tcft_action;
opt.action = params->action;
@@ -272,15 +267,11 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
&tm, TCA_TUNNEL_KEY_PAD))
goto nla_put_failure;
- ret = skb->len;
- goto out;
+ return skb->len;
nla_put_failure:
nlmsg_trim(skb, b);
-out:
- rcu_read_unlock();
-
- return ret;
+ return -1;
}
static int tunnel_key_walker(struct net *net, struct sk_buff *skb,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net/sched: act_tunnel_key: Remove rcu_read_lock protection
2016-09-12 12:19 [PATCH net-next] net/sched: act_tunnel_key: Remove rcu_read_lock protection Hadar Hen Zion
@ 2016-09-12 14:09 ` John Fastabend
2016-09-12 14:17 ` Eric Dumazet
2016-09-15 23:18 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: John Fastabend @ 2016-09-12 14:09 UTC (permalink / raw)
To: Hadar Hen Zion, David S. Miller
Cc: netdev, Jiri Pirko, Jiri Benc, Jamal Hadi Salim, Shmulik Ladkani,
Tom Herbert, Eric Dumazet, Cong Wang, Amir Vadai, Or Gerlitz
On 16-09-12 05:19 AM, Hadar Hen Zion wrote:
> 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: Hadar Hen Zion <hadarh@mellanox.com>
> ---
Thanks for cleaning this up.
Acked-by: John Fastabend <john.r.fastabend@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net/sched: act_tunnel_key: Remove rcu_read_lock protection
2016-09-12 14:09 ` John Fastabend
@ 2016-09-12 14:17 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2016-09-12 14:17 UTC (permalink / raw)
To: John Fastabend
Cc: Hadar Hen Zion, David S. Miller, netdev, Jiri Pirko, Jiri Benc,
Jamal Hadi Salim, Shmulik Ladkani, Tom Herbert, Eric Dumazet,
Cong Wang, Amir Vadai, Or Gerlitz
On Mon, 2016-09-12 at 07:09 -0700, John Fastabend wrote:
> On 16-09-12 05:19 AM, Hadar Hen Zion wrote:
> > 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: Hadar Hen Zion <hadarh@mellanox.com>
> > ---
>
> Thanks for cleaning this up.
>
> Acked-by: John Fastabend <john.r.fastabend@intel.com>
Exactly, we now have a nice canonical net/sched/act_... component.
Acked-by: Eric Dumazet <edumazet@google.com>
Thanks guys.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net/sched: act_tunnel_key: Remove rcu_read_lock protection
2016-09-12 12:19 [PATCH net-next] net/sched: act_tunnel_key: Remove rcu_read_lock protection Hadar Hen Zion
2016-09-12 14:09 ` John Fastabend
@ 2016-09-15 23:18 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-09-15 23:18 UTC (permalink / raw)
To: hadarh
Cc: netdev, jiri, jbenc, jhs, shmulik.ladkani, tom, edumazet,
xiyou.wangcong, amirva, ogerlitz
From: Hadar Hen Zion <hadarh@mellanox.com>
Date: Mon, 12 Sep 2016 15:19:21 +0300
> 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: Hadar Hen Zion <hadarh@mellanox.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-15 23:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-12 12:19 [PATCH net-next] net/sched: act_tunnel_key: Remove rcu_read_lock protection Hadar Hen Zion
2016-09-12 14:09 ` John Fastabend
2016-09-12 14:17 ` Eric Dumazet
2016-09-15 23:18 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.