summaryrefslogtreecommitdiff
path: root/src/nm-iface-helper.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-02-14 15:26:40 +0100
committerThomas Haller <thaller@redhat.com>2018-02-15 16:08:00 +0100
commit7de078a3940ec31bca553aced4e5d56bdc5c661c (patch)
treebc45bc5b5a6361e58ed4a518db71d2ba873ba665 /src/nm-iface-helper.c
parent578c4af907cd1f5a93aacb024f983b7eb5b40362 (diff)
downloadNetworkManager-7de078a3940ec31bca553aced4e5d56bdc5c661c.tar.gz
dhcp: inject client-id in GBytes format from NMDevice to nm_dhcp_manager_start_ip4()
Convert the string representation of ipv4.dhcp-client-id property already in NMDevice to a GBytes. Next, we will support more client ID modes, and we will need the NMDevice context to generate the client id.
Diffstat (limited to 'src/nm-iface-helper.c')
-rw-r--r--src/nm-iface-helper.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 996b060fd3..c270333894 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -341,6 +341,7 @@ main (int argc, char *argv[])
gs_unref_object NMDhcpClient *dhcp4_client = NULL;
gs_unref_object NMNDisc *ndisc = NULL;
gs_unref_bytes GBytes *hwaddr = NULL;
+ gs_unref_bytes GBytes *client_id = NULL;
gs_free NMUtilsIPv6IfaceId *iid = NULL;
guint sd_id;
char sysctl_path_buf[NM_UTILS_SYSCTL_IP_CONF_PATH_BUFSIZE];
@@ -441,6 +442,16 @@ main (int argc, char *argv[])
iid = g_bytes_unref_to_data (bytes, &ignored);
}
+ if (global_opt.dhcp4_clientid) {
+ /* this string is just a plain hex-string. Unlike ipv4.dhcp-client-id, which
+ * is parsed via nm_dhcp_utils_client_id_string_to_bytes(). */
+ client_id = nm_utils_hexstr2bin (global_opt.dhcp4_clientid);
+ if (!client_id || g_bytes_get_size (client_id) < 2) {
+ fprintf (stderr, _("(%s): Invalid DHCP client-id %s\n"), global_opt.ifname, global_opt.dhcp4_clientid);
+ return 1;
+ }
+ }
+
if (global_opt.dhcp4_address) {
nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_sysctl_ip_conf_path (AF_INET, sysctl_path_buf, global_opt.ifname, "promote_secondaries")), "1");
@@ -455,7 +466,7 @@ main (int argc, char *argv[])
!!global_opt.dhcp4_hostname,
global_opt.dhcp4_hostname,
global_opt.dhcp4_fqdn,
- global_opt.dhcp4_clientid,
+ client_id,
NM_DHCP_TIMEOUT_DEFAULT,
NULL,
global_opt.dhcp4_address);