summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Cardace <acardace@redhat.com>2020-08-24 18:15:01 +0200
committerAntonio Cardace <acardace@redhat.com>2020-08-26 09:44:11 +0200
commit5da0939a3f73aa002cb3d19e7d56087efec5d196 (patch)
tree815cccb814e24a034c825b2529f5327be147be48
parentf8a729015380b367bd2ecff66f31cb6253793e50 (diff)
downloadNetworkManager-5da0939a3f73aa002cb3d19e7d56087efec5d196.tar.gz
dhcp: implement dhcp-vendor-class-identifier option for systemd's DHCP
client https://bugzilla.redhat.com/show_bug.cgi?id=1871042 Signed-off-by: Antonio Cardace <acardace@redhat.com>
-rw-r--r--src/dhcp/nm-dhcp-systemd.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
index 737faad937..737ccacc48 100644
--- a/src/dhcp/nm-dhcp-systemd.c
+++ b/src/dhcp/nm-dhcp-systemd.c
@@ -569,6 +569,7 @@ ip4_start (NMDhcpClient *client,
int arp_type;
GBytes *client_id;
gs_unref_bytes GBytes *client_id_new = NULL;
+ GBytes *vendor_class_identifier;
const uint8_t *client_id_arr;
size_t client_id_len;
struct in_addr last_addr = { 0 };
@@ -698,6 +699,24 @@ ip4_start (NMDhcpClient *client,
}
}
+ vendor_class_identifier = nm_dhcp_client_get_vendor_class_identifier (client);
+ if (vendor_class_identifier) {
+ const char *option_data;
+ gsize len;
+
+ option_data = g_bytes_get_data (vendor_class_identifier, &len);
+ nm_assert (option_data);
+ nm_assert (len <= 255);
+
+ option_data = nm_strndup_a (300, option_data, len, NULL);
+
+ r = sd_dhcp_client_set_vendor_class_identifier (sd_client, option_data);
+ if (r < 0) {
+ nm_utils_error_set_errno (error, r, "failed to set DHCP vendor class identifier: %s");
+ return FALSE;
+ }
+ }
+
r = sd_dhcp_client_set_callback (sd_client, dhcp_event_cb, client);
if (r < 0) {
nm_utils_error_set_errno (error, r, "failed to set callback: %s");