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
This commit is contained in:
Thomas Haller
2022-07-22 18:34:33 +02:00
parent e25b7a579e
commit e466ad62e5

View File

@@ -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,