summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-08-03 18:50:08 +0200
committerThomas Haller <thaller@redhat.com>2022-08-09 08:02:37 +0200
commit13d334cdbbc0f8140051c964b4075370fcb31b85 (patch)
tree5c4debb740466e9465f84103bec2d58676365a5d
parent8f67a80537565b0d3103f1b1f18142ebcba72787 (diff)
downloadNetworkManager-13d334cdbbc0f8140051c964b4075370fcb31b85.tar.gz
glib-aux,platform: add comments to nm_platform_ip_address_get_scope()/nm_utils_ip_is_site_local()
About site-local IPv6 addresses (unique local addresses, ULA).
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.c3
-rw-r--r--src/libnm-platform/nm-platform.h12
2 files changed, 15 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c
index ddebcfa7a6..624f9a3e97 100644
--- a/src/libnm-glib-aux/nm-shared-utils.c
+++ b/src/libnm-glib-aux/nm-shared-utils.c
@@ -1015,6 +1015,9 @@ nm_utils_ip_is_site_local(int addr_family, const void *address)
return (addr4 & 0xff000000) == 0x0a000000 || (addr4 & 0xfff00000) == 0xac100000
|| (addr4 & 0xffff0000) == 0xc0a80000;
case AF_INET6:
+ /* IN6_IS_ADDR_SITELOCAL() is for deprecated fec0::/10 addresses (see rfc3879, 4.).
+ * Note that for unique local IPv6 addresses (ULA, fc00::/7) this returns false,
+ * which may or may not be a bug. */
return IN6_IS_ADDR_SITELOCAL(address);
default:
g_return_val_if_reached(FALSE);
diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h
index d93843a854..2f41b0c8bf 100644
--- a/src/libnm-platform/nm-platform.h
+++ b/src/libnm-platform/nm-platform.h
@@ -1617,6 +1617,18 @@ nm_platform_ip6_address_get_scope(const struct in6_addr *addr)
static inline guint8
nm_platform_ip_address_get_scope(int addr_family, gconstpointer addr)
{
+ /* Note that this function returns the scope as we configure
+ * it in kernel (for IPv4) or as kernel chooses it (for IPv6).
+ *
+ * That means, rfc1918 private addresses nm_utils_ip_is_site_local() are
+ * considered RT_SCOPE_UNIVERSE.
+ *
+ * Also, the deprecated IN6_IS_ADDR_SITELOCAL() addresses (fec0::/10)
+ * are considered RT_SCOPE_SITE, while unique local addresses (ULA, fc00::/7)
+ * are considered RT_SCOPE_UNIVERSE.
+ *
+ * You may not want to use this function when reasoning about
+ * site-local addresses (RFC1918, ULA). */
if (NM_IS_IPv4(addr_family))
return nm_platform_ip4_address_get_scope(*((in_addr_t *) addr));
return nm_platform_ip6_address_get_scope(addr);