Fix for ZTO-33 (Jira), only assign routes if there is a viable source IP.

This commit is contained in:
Adam Ierymenko 2020-11-06 11:01:45 -05:00
parent 317263b31c
commit 90f18f7ee7
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
3 changed files with 73 additions and 11 deletions

View file

@ -94,6 +94,22 @@ public:
static const CPUIDRegisters CPUID;
#endif
/**
* Compute the log2 (most significant bit set) of a 32-bit integer
*
* @param v Integer to compute
* @return log2 or 0 if v is 0
*/
static inline unsigned int log2(uint32_t v)
{
uint32_t r = (v > 0xffff) << 4; v >>= r;
uint32_t shift = (v > 0xff) << 3; v >>= shift; r |= shift;
shift = (v > 0xf) << 2; v >>= shift; r |= shift;
shift = (v > 0x3) << 1; v >>= shift; r |= shift;
r |= (v >> 1);
return (unsigned int)r;
}
/**
* Perform a time-invariant binary comparison
*