diff mbox

[ovs-dev,v5,2/4] ofproto: Fix thread safety annotation.

Message ID 1487878077-37353-3-git-send-email-jarno@ovn.org
State Accepted
Headers show

Commit Message

Jarno Rajahalme Feb. 23, 2017, 7:27 p.m. UTC
ofproto_check_ofpacts() requires ofproto_mutex, but the header did not
tell that so the trace did not take the mutex.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
---
 ofproto/ofproto-dpif-trace.c | 2 ++
 ofproto/ofproto-provider.h   | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Andy Zhou March 8, 2017, 9:11 p.m. UTC | #1
On Thu, Feb 23, 2017 at 11:27 AM, Jarno Rajahalme <jarno@ovn.org> wrote:
> ofproto_check_ofpacts() requires ofproto_mutex, but the header did not
> tell that so the trace did not take the mutex.
>
> Signed-off-by: Jarno Rajahalme <jarno@ovn.org>

Pushed to master. Thanks for working on this!
diff mbox

Patch

diff --git a/ofproto/ofproto-dpif-trace.c b/ofproto/ofproto-dpif-trace.c
index b01a131..3c9e3d4 100644
--- a/ofproto/ofproto-dpif-trace.c
+++ b/ofproto/ofproto-dpif-trace.c
@@ -387,8 +387,10 @@  ofproto_unixctl_trace_actions(struct unixctl_conn *conn, int argc,
                                ofproto->up.n_tables, &usable_protocols);
     }
     if (!retval) {
+        ovs_mutex_lock(&ofproto_mutex);
         retval = ofproto_check_ofpacts(&ofproto->up, ofpacts.data,
                                        ofpacts.size);
+        ovs_mutex_unlock(&ofproto_mutex);
     }
 
     if (retval) {
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index e21cb26..1361436 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1949,7 +1949,8 @@  void ofproto_flush_flows(struct ofproto *);
 
 enum ofperr ofproto_check_ofpacts(struct ofproto *,
                                   const struct ofpact ofpacts[],
-                                  size_t ofpacts_len);
+                                  size_t ofpacts_len)
+    OVS_REQUIRES(ofproto_mutex);
 
 static inline const struct rule_actions *
 rule_get_actions(const struct rule *rule)