From 72fae175990e9a4732ba4d368946f3854e994075 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 15 Nov 2010 11:04:40 -0800 Subject: [PATCH] ofp-util: Use a counter for transaction IDs instead of a random number. 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 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index d7bc0ee4..8a9a8ec8 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 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 -- 2.30.2