mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 07:56:29 +00:00
lib: fix type-punning in ip_masklen()
ip_masklen() was likely to return incorrect results after being compiled with -fstrict-aliasing (-O2, -O3, -Os)
This commit is contained in:
parent
d171bf58ef
commit
2654e43ca2
@ -2592,8 +2592,13 @@ masklen2ip (const int masklen, struct in_addr *netmask)
|
|||||||
u_char
|
u_char
|
||||||
ip_masklen (struct in_addr netmask)
|
ip_masklen (struct in_addr netmask)
|
||||||
{
|
{
|
||||||
u_int16_t * int16 = (u_int16_t *) &netmask.s_addr;
|
union
|
||||||
return map64kto17_nbo[int16[0]] + map64kto17_nbo[int16[1]];
|
{
|
||||||
|
u_int32_t int32;
|
||||||
|
u_int16_t int16[2];
|
||||||
|
} u;
|
||||||
|
u.int32 = netmask.s_addr;
|
||||||
|
return map64kto17_nbo[u.int16[0]] + map64kto17_nbo[u.int16[1]];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply mask to IPv4 prefix (network byte order). */
|
/* Apply mask to IPv4 prefix (network byte order). */
|
||||||
|
Loading…
Reference in New Issue
Block a user