diff options
author | Ben Pfaff <blp@ovn.org> | 2018-04-04 10:16:37 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-04-04 21:12:02 -0700 |
commit | 68c5c245d8503e8883a0e84cdaf14f1a0cea13c0 (patch) | |
tree | 517f3706d5f829c91cc03f0de8b18191f6e1493e /ovn | |
parent | 1e8eeb66db2e72d14312fe33e9b7aa73e3355db3 (diff) | |
download | openvswitch-68c5c245d8503e8883a0e84cdaf14f1a0cea13c0.tar.gz |
ovn: Fix tunnel id overflow.
Reported-by: Wei Li <liwei@anbutu.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovn')
-rw-r--r-- | ovn/northd/ovn-northd.c | 10 |
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; |