about summary refs log tree commit diff
path: root/src/nm-core-utils.h
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2020-07-13 22:06:54 +0200
committerMichael Biebl <biebl@debian.org>2020-07-13 22:06:54 +0200
commitc954a7079d01d0e5fad9c8ad99d8891d9e6f5bed (patch)
tree3f24a6356fc531498ec6b091a67230eaf725145d /src/nm-core-utils.h
parent36f77b6d9a724e4bc8e219b15fe446cd3a5e0099 (diff)
parent136d191f1c96dbae1489fed7c2565f5e1b1f8d40 (diff)
Update upstream source from tag 'upstream/1.26.0'
Update to upstream version '1.26.0'
with Debian dir ac612e9c69962647563dd4d6aa7499aacaf8aa3c
Diffstat (limited to 'src/nm-core-utils.h')
-rw-r--r--src/nm-core-utils.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
index fae7adbf..55792d57 100644
--- a/src/nm-core-utils.h
+++ b/src/nm-core-utils.h
@@ -156,8 +156,13 @@ double nm_utils_exp10 (gint16 e);
  * nm_utils_ip6_route_metric_normalize:
  * @metric: the route metric
  *
- * For IPv6 route, kernel treats the value 0 as IP6_RT_PRIO_USER (1024).
- * Thus, when comparing metric (values), we want to treat zero as NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6.
+ * For IPv6 route, when adding a route via netlink, kernel treats the value 0 as IP6_RT_PRIO_USER (1024).
+ * So, user space cannot add routes with such a metric, and 0 gets "normalized"
+ * to NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6.
+ *
+ * Note that kernel itself can add IPv6 routes with metric zero. Also, you can delete
+ * them, but mostly because with `ip -6 route delete ... metric 0` the 0 acts as a wildcard
+ * and kills the first matching route.
  *
  * Returns: @metric, if @metric is not zero, otherwise 1024.
  */
@@ -174,9 +179,8 @@ nm_utils_ip_route_metric_normalize (int addr_family, guint32 metric)
 }
 
 static inline guint32
-nm_utils_ip_route_metric_penalize (int addr_family, guint32 metric, guint32 penalty)
+nm_utils_ip_route_metric_penalize (guint32 metric, guint32 penalty)
 {
-	metric = nm_utils_ip_route_metric_normalize (addr_family, metric);
 	if (metric < G_MAXUINT32 - penalty)
 		return metric + penalty;
 	return G_MAXUINT32;