[fib algo][dxr] Fix undefined behavior.

The result of shifting uint32_t by 32 (or more) is undefined: fix it.
This commit is contained in:
Marko Zec 2021-09-15 22:23:17 +02:00
parent 0cd6e85e24
commit 442c8a245e

View File

@ -1150,7 +1150,10 @@ dxr_change_rib_batch(struct rib_head *rnh, struct fib_change_queue *q,
#endif
plen = q->entries[ui].plen;
ip = ntohl(q->entries[ui].addr4.s_addr);
hmask = 0xffffffffU >> plen;
if (plen < 32)
hmask = 0xffffffffU >> plen;
else
hmask = 0;
start = (ip & ~hmask) >> DXR_RANGE_SHIFT;
end = (ip | hmask) >> DXR_RANGE_SHIFT;