[ovs-dev] [PATCH] Annotate rcu dereferences
Pravin Shelar
pshelar at nicira.com
Wed Sep 7 02:02:51 UTC 2011
Following patch fixes rcu-dereferences-check warning msg by annotating rcu
dereferences for BH context.
----------------------8<----------------------------------
===================================================
[ INFO: suspicious rcu_dereference_check() usage. ]
---------------------------------------------------
/root/ovs-cl1/hash3/datapath/linux/datapath.c:298 invoked
rcu_dereference_check() without protection!
/root/ovs-cl1/hash3/datapath/linux/actions.c:360 invoked
rcu_dereference_check() without protection!
/root/ovs-cl1/hash3/datapath/linux/actions.c:210 invoked
rcu_dereference_check() without protection!
Signed-off-by: Pravin Shelar <pshelar at nicira.com>
---
datapath/actions.c | 6 ++++--
datapath/datapath.c | 2 +-
datapath/linux/compat/include/linux/rcupdate.h | 8 ++++++++
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/datapath/actions.c b/datapath/actions.c
index 8aec438..c3df04f 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -207,7 +207,7 @@ static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port)
if (!skb)
goto error;
- p = rcu_dereference(dp->ports[out_port]);
+ p = rcu_dereference_bh_check(dp->ports[out_port], rcu_read_lock_held());
if (!p)
goto error;
@@ -357,10 +357,12 @@ static void sflow_sample(struct datapath *dp, struct sk_buff *skb,
/* Execute a list of actions against 'skb'. */
int execute_actions(struct datapath *dp, struct sk_buff *skb)
{
- struct sw_flow_actions *acts = rcu_dereference(OVS_CB(skb)->flow->sf_acts);
+ struct sw_flow_actions *acts;
struct loop_counter *loop;
int error;
+ acts = rcu_dereference_bh_check(OVS_CB(skb)->flow->sf_acts,
+ rcu_read_lock_held());
/* Check whether we've looped too much. */
loop = loop_get_counter();
if (unlikely(++loop->count > MAX_LOOPS))
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 7c9ec3b..c2e274e 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -295,7 +295,7 @@ void dp_process_received_packet(struct vport *p, struct sk_buff *skb)
}
/* Look up flow. */
- flow_node = tbl_lookup(rcu_dereference(dp->table), &key, key_len,
+ flow_node = tbl_lookup(rcu_dereference_bh(dp->table), &key, key_len,
flow_hash(&key, key_len), flow_cmp);
if (unlikely(!flow_node)) {
struct dp_upcall_info upcall;
diff --git a/datapath/linux/compat/include/linux/rcupdate.h b/datapath/linux/compat/include/linux/rcupdate.h
index 99459ea..7be127b 100644
--- a/datapath/linux/compat/include/linux/rcupdate.h
+++ b/datapath/linux/compat/include/linux/rcupdate.h
@@ -7,6 +7,14 @@
#define rcu_dereference_check(p, c) rcu_dereference(p)
#endif
+#ifndef rcu_dereference_bh
+#define rcu_dereference_bh(p) rcu_dereference(p)
+#endif
+
+#ifndef rcu_dereference_bh_check
+#define rcu_dereference_bh_check(p, c) rcu_dereference(p)
+#endif
+
#ifndef rcu_dereference_protected
#define rcu_dereference_protected(p, c) (p)
#endif
--
1.7.1
More information about the dev
mailing list