summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-04-04 10:16:37 -0700
committerBen Pfaff <blp@ovn.org>2018-04-04 21:13:43 -0700
commit1fe7363c03e096f9e6211698b2fc166c3e4bd531 (patch)
tree7aade3d6de258870332aac4a34b2a30a61ce4b03
parent75a4571ae02ead264bb9a5660da59195f56baee9 (diff)
downloadopenvswitch-1fe7363c03e096f9e6211698b2fc166c3e4bd531.tar.gz
ovn: Fix tunnel id overflow.
Reported-by: Wei Li <liwei@anbutu.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
-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 6000856f3..afa152d42 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -210,11 +210,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;