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 637a45e25b)
This commit is contained in:
Beniamino Galvani 2021-06-17 11:35:54 +02:00
parent 229b9a979c
commit 21051dc6d8

View file

@ -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;
}