[ovs-dev] [ofproto tests 03/29] ofp-util: Use a counter for transaction IDs instead of a random number.

Ben Pfaff blp at nicira.com
Tue Nov 16 19:20:53 UTC 2010

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 |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index d7bc0ee..8a9a8ec 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -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
-    return random_uint32();
+    static uint32_t next_xid = 1;
+    return next_xid++;
 /* Allocates and stores in '*bufferp' a new ofpbuf with a size of

More information about the dev mailing list