mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 00:10:15 +01:00
ip4-config: allow IPv4 addresses that only differ by prefix-length
Kernel treats IPv4 addresses with different netmask/prefix-length as different addresses. It is wrong to merge them together in nm_ip4_config_add_address(). For IPv6 addresses that is not the case and you cannot configure two IPv6 addresses that only differ by plen (on the same interface).
This commit is contained in:
parent
44c43b4f5c
commit
560de03bf3
1 changed files with 5 additions and 4 deletions
|
|
@ -176,9 +176,10 @@ nm_ip4_config_capture_resolv_conf (GArray *nameservers,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
addresses_are_duplicate (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b, gboolean consider_plen)
|
||||
addresses_are_duplicate (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b)
|
||||
{
|
||||
return a->address == b->address && (!consider_plen || a->plen == b->plen);
|
||||
return a->address == b->address
|
||||
&& a->plen == b->plen;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -994,7 +995,7 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
|
|||
if (nm_platform_ip4_address_cmp (src_addr = nm_ip4_config_get_address (src, i),
|
||||
dst_addr = nm_ip4_config_get_address (dst, i))) {
|
||||
are_equal = FALSE;
|
||||
if (!addresses_are_duplicate (src_addr, dst_addr, TRUE)) {
|
||||
if (!addresses_are_duplicate (src_addr, dst_addr)) {
|
||||
has_relevant_changes = TRUE;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1367,7 +1368,7 @@ nm_ip4_config_add_address (NMIP4Config *config, const NMPlatformIP4Address *new)
|
|||
for (i = 0; i < priv->addresses->len; i++ ) {
|
||||
NMPlatformIP4Address *item = &g_array_index (priv->addresses, NMPlatformIP4Address, i);
|
||||
|
||||
if (addresses_are_duplicate (item, new, FALSE)) {
|
||||
if (addresses_are_duplicate (item, new)) {
|
||||
if (nm_platform_ip4_address_cmp (item, new) == 0)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue