From: John Lo Date: Wed, 4 Jul 2018 20:27:59 +0000 (-0400) Subject: Fix clib_bitmap_next_clear() function when no clear bits left X-Git-Tag: v18.07-rc1~51 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=ef8db3679746792403589fb54fa0bbb9e13245dd;p=vpp.git Fix clib_bitmap_next_clear() function when no clear bits left If the bitmap has no bit clear after the input bit position i, the function will return i even if its bit is set. Fix is to return the next bit just beyond the free bitmap. This can cause IP neighbor scan crash in ip_neighbor_scan() with a debug image. With production image, ip_neighbor_scan() may still function, AFAICT, with extra neighbor delete attempts for entries already deleted, until these entries are reused for new neighbors. Change-Id: If6422ef6f63908ea39651de4ccbd8cb0b294bd69 Signed-off-by: John Lo --- diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h index d6dfe86da0b..0e94d028ee3 100644 --- a/src/vppinfra/bitmap.h +++ b/src/vppinfra/bitmap.h @@ -728,6 +728,9 @@ clib_bitmap_next_clear (uword * ai, uword i) if (t) return log2_first_set (t) + i0 * BITS (ai[0]); } + + /* no clear bit left in bitmap, return bit just beyond bitmap */ + return (i0 + 1) * BITS (ai[0]); } return i; }