ofp-util: Use a counter for transaction IDs instead of a random number.
authorBen Pfaff <blp@nicira.com>
Mon, 15 Nov 2010 19:04:40 +0000 (11:04 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 17 Nov 2010 17:21:09 +0000 (09:21 -0800)
I don't know of any reason why the transaction id should be random.  Using
consecutive ids means that there is no chance that two messages sent around
the same time will have the same transaction ID, which is probabilitically
possible with random IDs.

lib/ofp-util.c

index d7bc0ee..8a9a8ec 100644 (file)
@@ -32,12 +32,12 @@ VLOG_DEFINE_THIS_MODULE(ofp_util);
  * in the peer and so there's not much point in showing a lot of them. */
 static struct vlog_rate_limit bad_ofmsg_rl = VLOG_RATE_LIMIT_INIT(1, 5);
 
-/* XXX we should really use consecutive xids to avoid probabilistic
- * failures. */
-static inline uint32_t
+/* Returns a transaction ID to use for an outgoing OpenFlow message. */
+static uint32_t
 alloc_xid(void)
 {
-    return random_uint32();
+    static uint32_t next_xid = 1;
+    return next_xid++;
 }
 
 /* Allocates and stores in '*bufferp' a new ofpbuf with a size of