clang: Add annotations for thread safety check.
[sliver-openvswitch.git] / lib / ofp-parse.c
index 609166c..5cb39f5 100644 (file)
@@ -34,6 +34,7 @@
 #include "ofp-util.h"
 #include "ofpbuf.h"
 #include "openflow/openflow.h"
+#include "ovs-thread.h"
 #include "packets.h"
 #include "socket-util.h"
 #include "vconn.h"
@@ -1125,6 +1126,7 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string)
     } else{
         fm->new_cookie = htonll(0);
     }
+    fm->modify_cookie = false;
     fm->table_id = 0xff;
     fm->command = command;
     fm->idle_timeout = OFP_FLOW_PERMANENT;
@@ -1212,6 +1214,7 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string)
                         return xstrdup("cannot set cookie");
                     }
                     error = str_to_be64(value, &fm->new_cookie);
+                    fm->modify_cookie = true;
                 }
             } else if (mf_from_name(name)) {
                 error = parse_field(mf_from_name(name), value, &fm->match);
@@ -1517,12 +1520,12 @@ static char * WARN_UNUSED_RESULT
 parse_flow_monitor_request__(struct ofputil_flow_monitor_request *fmr,
                              const char *str_, char *string)
 {
-    static uint32_t id;
-
+    static atomic_uint32_t id = ATOMIC_VAR_INIT(0);
     char *save_ptr = NULL;
     char *name;
 
-    fmr->id = id++;
+    atomic_add(&id, 1, &fmr->id);
+
     fmr->flags = (NXFMF_INITIAL | NXFMF_ADD | NXFMF_DELETE | NXFMF_MODIFY
                   | NXFMF_OWN | NXFMF_ACTIONS);
     fmr->out_port = OFPP_NONE;