ovn: Fix tunnel id overflow.
Reported-by: Wei Li
@@ -292,12 +292,18 @@ tnlid_in_use(const struct hmap *set, uint32_t tnlid)
return false;
}
+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;
