NetworkManager/SOURCES/1012-prefer-IPv4-to-determi...

44 lines
1.6 KiB
Diff

From 65ea6e97238a76386d0477abc0d22b2227f38d60 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Thu, 17 Jun 2021 11:35:54 +0200
Subject: [PATCH] policy: prefer IPv4 to determine the hostname
When determining the hostname, it is preferable to evaluate devices in
a predictable order to avoid that the hostname changes between
different boots.
The current order is based first on hostname priority, then on the
presence of a best default route, and then on activation order.
The activation order is not a very strong condition, as it is
basically useless for devices that are autoactivated at boot.
As we already prefer IPv4 over IPv6 within the same connection, also
prefer it when 2 connections have the same priority and the same
default route status, to achieve better predictability.
https://bugzilla.redhat.com/show_bug.cgi?id=1970335
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/895
(cherry picked from commit 637a45e25b58afd1ac22af8657121e0956093b61)
(cherry picked from commit 21051dc6d8b87c48fafb44b5cde901633b0a7cd2)
(cherry picked from commit b793925889a3137b77fa2b8679144b1e4948d246)
---
src/core/nm-policy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c
index db4983f889..71aa1eceaf 100644
--- a/src/core/nm-policy.c
+++ b/src/core/nm-policy.c
@@ -652,6 +652,7 @@ device_hostname_info_compare(gconstpointer a, gconstpointer b)
NM_CMP_FIELD(info1, info2, priority);
NM_CMP_FIELD_UNSAFE(info2, info1, is_default);
+ NM_CMP_FIELD_UNSAFE(info2, info1, IS_IPv4);
return 0;
}
--
2.31.1