Skip to content
  • Thomas Haller's avatar
    dhcp: reimplement node-specific DHCP client-id generation from systemd · a5579577
    Thomas Haller authored
    Our internal DHCP client (from systemd) defaults to a particular client ID.
    It is currently exposed as nm_sd_utils_generate_default_dhcp_client_id()
    and is based on the systemd implementation.
    
    One problem with that is, that it internally looks up the interface name
    with if_indextoname() and reads /etc/machine-id. Both makes it harder
    for testing.
    
    Another problem is, that this way of generating the client-id is
    currently limited to internal client. Why? If you use dhclient plugin,
    you may still want to use the same algorithm. Also, there is no explict
    "ipv4.dhcp-client-id" mode to select this client-id (so that it could
    be used in combination with "dhclient" plugin).
    As such, this code will be useful also aside systemd DHCP plugin.
    Hence, the function should not be obviously tied to systemd code.
    
    The implementation is simple enough, and since we already have a
    unit-test, refactor the code to our own implementation.
    a5579577