net: sched: refactor ct action helpers to require tcf_lock
authorVlad Buslov <vladbu@mellanox.com>
Mon, 17 Feb 2020 10:12:11 +0000 (12:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Feb 2020 22:17:02 +0000 (14:17 -0800)
In order to remove rtnl lock dependency from flow_action representation
translator, change rtnl_dereference() to rcu_dereference_protected() in ct
action helpers that provide external access to zone and action values. This
is safe to do because the functions are not called from anywhere else
outside flow_action infrastructure which was modified to obtain tcf_lock
when accessing action data in one of previous patches in the series.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tc_act/tc_ct.h

index bdc20ab3b88dde15bf78416a6ac151392966131e..a8b156402873eaae9f82fcdf6581a9e4b9f22d0f 100644 (file)
@@ -33,8 +33,10 @@ struct tcf_ct {
 };
 
 #define to_ct(a) ((struct tcf_ct *)a)
-#define to_ct_params(a) ((struct tcf_ct_params *) \
-                        rtnl_dereference((to_ct(a)->params)))
+#define to_ct_params(a)                                                        \
+       ((struct tcf_ct_params *)                                       \
+        rcu_dereference_protected(to_ct(a)->params,                    \
+                                  lockdep_is_held(&a->tcfa_lock)))
 
 static inline uint16_t tcf_ct_zone(const struct tc_action *a)
 {