From 3ba72ff335eb25238bb4efb16435afe841724ef5 Mon Sep 17 00:00:00 2001
From: Matteo Croce <teknoraver@meta.com>
Date: Thu, 27 Feb 2025 20:10:20 +0100
Subject: [PATCH] add log messages when a route can't be updated
---
src/network/networkd-route.c | 46 ++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 9498fa4ccc8f2..91a3916c30a8d 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -1399,32 +1399,58 @@ bool route_can_update(const Route *existing, const Route *requesting) {
assert(existing);
assert(requesting);
- if (route_compare_func(existing, requesting) != 0)
+ if (route_compare_func(existing, requesting) != 0) {
+ log_route_debug(existing, "Cannot update route, as the existing route is different", existing->manager);
return false;
+ }
switch (existing->family) {
case AF_INET:
- if (existing->nexthop.weight != requesting->nexthop.weight)
+ if (existing->nexthop.weight != requesting->nexthop.weight) {
+ log_debug("existing weight: %u, requesting weight: %u",
+ existing->nexthop.weight, requesting->nexthop.weight);
return false;
+ }
return true;
case AF_INET6:
- if (existing->protocol != requesting->protocol)
+ if (existing->protocol != requesting->protocol) {
+ log_debug("existing protocol: %hhu, requesting protocol: %hhu",
+ existing->protocol, requesting->protocol);
return false;
- if (existing->type != requesting->type)
+ }
+ if (existing->type != requesting->type) {
+ log_debug("existing type: %hhu, requesting type: %hhu",
+ existing->type, requesting->type);
return false;
- if (existing->flags != requesting->flags)
+ }
+ if (existing->flags != requesting->flags) {
+ log_debug("existing flags: %x, requesting flags: %x",
+ existing->flags, requesting->flags);
return false;
- if (!in6_addr_equal(&existing->prefsrc.in6, &requesting->prefsrc.in6))
+ }
+ if (!in6_addr_equal(&existing->prefsrc.in6, &requesting->prefsrc.in6)) {
+ log_route_debug(existing, "Cannot update route, as the preferred source is different", existing->manager);
return false;
- if (existing->pref != requesting->pref)
+ }
+ if (existing->pref != requesting->pref) {
+ log_debug("existing preference: %hhu, requesting preference: %hhu",
+ existing->pref, requesting->pref);
return false;
- if (existing->expiration_managed_by_kernel && requesting->lifetime_usec == USEC_INFINITY)
+ }
+ if (existing->expiration_managed_by_kernel && requesting->lifetime_usec == USEC_INFINITY) {
+ log_route_debug(existing, "Cannot update route, as the expiration is managed by the kernel and lifetime is infinite", existing->manager);
return false; /* We cannot disable expiration timer in the kernel. */
- if (!route_metric_can_update(&existing->metric, &requesting->metric, existing->expiration_managed_by_kernel))
+ }
+ if (!route_metric_can_update(&existing->metric, &requesting->metric, existing->expiration_managed_by_kernel)) {
+ log_route_debug(existing, "Cannot update route, as the metrics are different", existing->manager);
return false;
- if (existing->nexthop.weight != requesting->nexthop.weight)
+ }
+ if (existing->nexthop.weight != requesting->nexthop.weight) {
+ log_debug("existing weight: %u, requesting weight: %u",
+ existing->nexthop.weight, requesting->nexthop.weight);
return false;
+ }
return true;
default: