philipp / rpms / dhcp

Forked from rpms/dhcp 4 years ago
Clone

Blame SOURCES/dhcp-4.2.2-gpxe-cid.patch

45d60a
diff -up dhcp-4.2.2/client/dhclient.c.gpxe-cid dhcp-4.2.2/client/dhclient.c
45d60a
--- dhcp-4.2.2/client/dhclient.c.gpxe-cid	2011-09-16 18:23:20.190453902 +0200
45d60a
+++ dhcp-4.2.2/client/dhclient.c	2011-09-16 18:27:15.568463599 +0200
45d60a
@@ -58,6 +58,13 @@ const char *path_dhclient_pid = NULL;
45d60a
 static char path_dhclient_script_array[] = _PATH_DHCLIENT_SCRIPT;
45d60a
 char *path_dhclient_script = path_dhclient_script_array;
45d60a
 
45d60a
+/* Default Prefix */
45d60a
+static unsigned char default_prefix[12] = {
45d60a
+	0xff, 0x00, 0x00, 0x00,
45d60a
+	0x00, 0x00, 0x02, 0x00,
45d60a
+	0x00, 0x02, 0xc9, 0x00
45d60a
+};
45d60a
+
45d60a
 /* False (default) => we write and use a pid file */
45d60a
 isc_boolean_t no_pid_file = ISC_FALSE;
45d60a
 
45d60a
@@ -1250,6 +1257,12 @@ int find_subnet (struct subnet **sp,
45d60a
 static void setup_ib_interface(struct interface_info *ip)
45d60a
 {
45d60a
 	struct group *g;
45d60a
+	struct hardware *hw = &ip->hw_address;
45d60a
+	char client_id[64];
45d60a
+	char *arg_conf = NULL;
45d60a
+	int arg_conf_len = 0;
45d60a
+	isc_result_t status;
45d60a
+	struct parse *cfile = (struct parse *)0;
45d60a
 
45d60a
 	/* Set the broadcast flag */
45d60a
 	ip->client->config->bootp_broadcast_always = 1;
45d60a
@@ -1266,8 +1279,39 @@ static void setup_ib_interface(struct in
45d60a
 		}
45d60a
 	}
45d60a
 
45d60a
-	/* No client ID specified */
45d60a
-	log_fatal("dhcp-client-identifier must be specified for InfiniBand");
45d60a
+	/*
45d60a
+	 * No client ID specified, make up one based on a default
45d60a
+	 * "prefix" and the port GUID.
45d60a
+	 *
45d60a
+	 * NOTE: This is compatible with what gpxe does.
45d60a
+	 */
45d60a
+	sprintf(client_id, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
45d60a
+		default_prefix[0], default_prefix[1], default_prefix[2],
45d60a
+		default_prefix[3], default_prefix[4], default_prefix[5],
45d60a
+		default_prefix[6], default_prefix[7], default_prefix[8],
45d60a
+		default_prefix[9], default_prefix[10], default_prefix[11],
45d60a
+		hw->hbuf[1], hw->hbuf[2], hw->hbuf[3], hw->hbuf[4],
45d60a
+		hw->hbuf[5], hw->hbuf[6], hw->hbuf[7], hw->hbuf[8]);
45d60a
+
45d60a
+	arg_conf_len = asprintf(&arg_conf,
45d60a
+				"send dhcp-client-identifier %s;",
45d60a
+				client_id);
45d60a
+
45d60a
+	if ((arg_conf == 0) || (arg_conf_len <= 0))
45d60a
+		log_fatal("Unable to send option dhcp-client-identifier");
45d60a
+
45d60a
+	status = new_parse(&cfile, -1, arg_conf, arg_conf_len,
45d60a
+			   "Automatic Infiniband client identifier", 0);
45d60a
+
45d60a
+	if ((status != ISC_R_SUCCESS) || (cfile->warnings_occurred))
45d60a
+		log_fatal("Failed to parse Infiniband client identifier");
45d60a
+
45d60a
+	parse_client_statement(cfile, NULL, ip->client->config);
45d60a
+
45d60a
+	if (cfile->warnings_occurred)
45d60a
+		log_fatal("Failed to parse Infiniband client identifier");
45d60a
+
45d60a
+	end_parse(&cfile);
45d60a
 }
45d60a
 
45d60a
 /* Individual States: