summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-11-02 17:48:26 +0100
committerThomas Haller <thaller@redhat.com>2018-11-13 19:09:34 +0100
commite9630e7d5795ff3171b04b817acc0c8d9eb97776 (patch)
treeb896054c6b87737a7a3066a48ba1ea99debd101c
parent8861ac2976795e05aa6a5f5e6c822977bf950ed3 (diff)
downloadNetworkManager-th/dhcp-client-id-mac-rh1640494.tar.gz
core/trivial: add code comment about DHCP client-id/DUIDth/dhcp-client-id-mac-rh1640494
-rw-r--r--src/dhcp/nm-dhcp-manager.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c
index 4bccee7534..878336178e 100644
--- a/src/dhcp/nm-dhcp-manager.c
+++ b/src/dhcp/nm-dhcp-manager.c
@@ -234,6 +234,32 @@ client_start (NMDhcpManager *self,
c_list_link_tail (&priv->dhcp_client_lst_head, &client->dhcp_client_lst);
g_signal_connect (client, NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, G_CALLBACK (client_state_changed), self);
+ /* unfortunately, our implementations work differently per address-family regarding client-id/DUID.
+ *
+ * - for IPv4, the calling code may determine a client-id (from NM's connection profile).
+ * If present, it is taken. If not present, the DHCP plugin uses a plugin specific default.
+ * - for "internal" plugin, the default is just "duid".
+ * - for "dhclient", we try to get the configuration from dhclient's /etc/dhcp or fallback
+ * to whatever dhclient uses by default.
+ * We do it this way, because for dhclient the user may configure a default
+ * outside of NM, and we want to honor that. Worse, dhclient could be a wapper
+ * script where the wrapper script overwrites the client-id. We need to distinguish
+ * between: force a particular client-id and leave it unspecified to whatever dhclient
+ * wants.
+ *
+ * - for IPv6, the calling code always determines a client-id. It also specifies @enforce_duid,
+ * to determine whether the given client-id must be used.
+ * - for "internal" plugin @enforce_duid doesn't matter and the given client-id is
+ * always used.
+ * - for "dhclient", @enforce_duid FALSE means to first try to load the DUID from the
+ * lease file, and only otherwise fallback to the given client-id.
+ * - other plugins don't support DHCPv6.
+ * It's done this way, so that existing dhclient setups don't change behavior on upgrade.
+ *
+ * This difference is cumbersome and only exists because of "dhclient" which supports hacking the
+ * default outside of NetworkManager API.
+ */
+
if (addr_family == AF_INET) {
success = nm_dhcp_client_start_ip4 (client,
dhcp_client_id,