mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-07 15:40:31 +01:00
platform: fix comparing peer-address for IPv6 address in nm_platform_ip6_address_cmp()
This commit is contained in:
parent
cc654b9dd3
commit
eab5a462b4
1 changed files with 14 additions and 1 deletions
|
|
@ -2747,6 +2747,13 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route)
|
|||
return ((a) < (b)) ? -1 : 1; \
|
||||
} G_STMT_END
|
||||
|
||||
#define _CMP_DIRECT_MEMCMP(a, b, size) \
|
||||
G_STMT_START { \
|
||||
int c = memcmp ((a), (b), (size)); \
|
||||
if (c != 0) \
|
||||
return c < 0 ? -1 : 1; \
|
||||
} G_STMT_END
|
||||
|
||||
#define _CMP_FIELD(a, b, field) \
|
||||
G_STMT_START { \
|
||||
if (((a)->field) != ((b)->field)) \
|
||||
|
|
@ -2853,11 +2860,17 @@ nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4A
|
|||
int
|
||||
nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6Address *b)
|
||||
{
|
||||
const struct in6_addr *p_a, *p_b;
|
||||
|
||||
_CMP_SELF (a, b);
|
||||
_CMP_FIELD (a, b, ifindex);
|
||||
_CMP_FIELD (a, b, source);
|
||||
_CMP_FIELD_MEMCMP (a, b, address);
|
||||
_CMP_FIELD_MEMCMP (a, b, peer_address);
|
||||
|
||||
p_a = nm_platform_ip6_address_get_peer (a);
|
||||
p_b = nm_platform_ip6_address_get_peer (b);
|
||||
_CMP_DIRECT_MEMCMP (p_a, p_b, sizeof (*p_a));
|
||||
|
||||
_CMP_FIELD (a, b, plen);
|
||||
_CMP_FIELD (a, b, timestamp);
|
||||
_CMP_FIELD (a, b, lifetime);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue