From e466ad62e5d77c5d02d0fa572583c8e93785022a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 22 Jul 2022 18:34:33 +0200 Subject: [PATCH] platform: set the scope for IPv4 loopback address to "host" For IPv6, kernel does not accept the ifa_scope parameter and always determines the scope based on the address itself. For IPv4, it honors whatever scope the user sets via netlink. NetworkManager does not allow to directly configure the address scope, but autodetects it. Use nm_platform_ip4_address_get_scope() for detecting the scopt. This also fixes the issue that to detect loopback addresses 127.0.0.0/8 and use scope "host". Try: $ nmcli device modify "$IFACE" +ipv4.addresses 127.0.0.5/8 --- src/libnm-platform/nm-linux-platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 7601db5cc..e445d0757 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -8964,8 +8964,7 @@ ip4_address_add(NMPlatform *platform, plen, &peer_addr, flags, - nm_utils_ip4_address_is_link_local(addr) ? RT_SCOPE_LINK - : RT_SCOPE_UNIVERSE, + nm_platform_ip4_address_get_scope(addr), lifetime, preferred, broadcast_address,