dhcp: improve log message for unknown DHCP plugin

If a DHCP plugin is unknown, the logs says "DHCP client 'x' not
available". This is the same message that is shown if, for example, it
is a valid DHCP plugin name, but the program is not installed in the
system.

For example, after 'dhclient' was deprecated, now NM is built without
support for it. Then, people with old configs `dhcp=dhclient` get the
message "DHCP client 'dhclient' not available". That seems to mean that
dhclient is not installed.

Show a message "unknown DHCP client" instead.

Fixes https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/work_items/1917
This commit is contained in:
Íñigo Huguet 2026-03-28 12:06:07 +01:00
parent 7f4efc484c
commit 24c50803a7

View file

@ -289,8 +289,10 @@ nm_dhcp_manager_init(NMDhcpManager *self)
NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
client = client_free;
if (client) {
client_factory = _client_factory_available(_client_factory_find_by_name(client));
client_factory = _client_factory_find_by_name(client);
if (!client_factory)
_LOGW(AF_UNSPEC, "init: unknown DHCP client '%s', ignoring", client);
else if (!(client_factory = _client_factory_available(client_factory)))
_LOGW(AF_UNSPEC, "init: DHCP client '%s' not available", client);
}
if (!client_factory) {