From 6428bdc4644f4f4956af9cee294ba7c961669d10 Mon Sep 17 00:00:00 2001 From: Vladislav Odintsov Date: Mon, 1 Apr 2024 13:40:28 +0300 Subject: [PATCH] tmp Signed-off-by: Vladislav Odintsov --- lib/ovn-util.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ovn-util.c b/lib/ovn-util.c index 327dd09943..a3ccfc80bd 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -699,13 +699,18 @@ uint32_t ovn_allocate_tnlid(struct hmap *set, const char *name, uint32_t min, uint32_t max, uint32_t *hint) { - for (uint32_t tnlid = *hint; tnlid != prev_tnlid(*hint, min, max); - tnlid = next_tnlid(tnlid, min, max)) { + /* Normalize hint, because it can be outside of [min, max]. */ + *hint = next_tnlid(*hint, min, max); + + uint32_t tnlid = *hint; + do { if (ovn_add_tnlid(set, tnlid)) { *hint = tnlid; return tnlid; } + tnlid = next_tnlid(tnlid, min, max); } + while (tnlid != *hint); static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); VLOG_WARN_RL(&rl, "all %s tunnel ids exhausted", name);