summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ovn/northd/ovn-northd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 07896be84..9ca15bc2f 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -293,11 +293,17 @@ tnlid_in_use(const struct hmap *set, uint32_t tnlid)
}
static uint32_t
+next_tnlid(uint32_t tnlid, uint32_t max)
+{
+ return tnlid + 1 <= max ? tnlid + 1 : 1;
+}
+
+static uint32_t
allocate_tnlid(struct hmap *set, const char *name, uint32_t max,
uint32_t *hint)
{
- for (uint32_t tnlid = *hint + 1; tnlid != *hint;
- tnlid = tnlid + 1 <= max ? tnlid + 1 : 1) {
+ for (uint32_t tnlid = next_tnlid(*hint, max); tnlid != *hint;
+ tnlid = next_tnlid(tnlid, max)) {
if (!tnlid_in_use(set, tnlid)) {
add_tnlid(set, tnlid);
*hint = tnlid;