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

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