Commit 0d151c32 authored by Ryan Jackson's avatar Ryan Jackson

Fixed a bug in handling the bootinfo response

parent 0c03ae5f
diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/com32/modules/bootinfo.c diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/com32/modules/bootinfo.c
--- syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c 1969-12-31 17:00:00.000000000 -0700 --- syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c 2008-12-18 16:00:21.502810222 -0700
+++ syslinux-3.71+dfsg/com32/modules/bootinfo.c 2008-09-24 15:51:47.000000000 -0600 +++ syslinux-3.71+dfsg/com32/modules/bootinfo.c 2008-12-19 16:59:48.000000000 -0700
@@ -0,0 +1,835 @@ @@ -0,0 +1,861 @@
+/* +/*
+ * EMULAB-COPYRIGHT + * EMULAB-COPYRIGHT
+ * Copyright (c) 2008 University of Utah and the Flux Group. + * Copyright (c) 2008 University of Utah and the Flux Group.
...@@ -422,6 +422,18 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -422,6 +422,18 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ return rc; + return rc;
+} +}
+ +
+void print_packet(char *buffer, int length)
+{
+ int i;
+
+ for (i = 0; i < length; i++) {
+ if (i % 8 == 0) {
+ printf("\n");
+ }
+ printf("%02x ", buffer[i]);
+ }
+}
+
+/* Try to get a bootinfo response +/* Try to get a bootinfo response
+ * + *
+ * my_ip: destination ip to accept packets for + * my_ip: destination ip to accept packets for
...@@ -453,8 +465,10 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -453,8 +465,10 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ } + }
+ rc = udp_read(my_ip, htons(BOOTWHAT_SRCPORT), + rc = udp_read(my_ip, htons(BOOTWHAT_SRCPORT),
+ buffer, (uint16_t *)length); + buffer, (uint16_t *)length);
+ if (rc == PXENV_STATUS_SUCCESS) + if (rc == PXENV_STATUS_SUCCESS) {
+ /* print_packet(buffer, *length); */
+ break; + break;
+ }
+ else if (rc == -1) { + else if (rc == -1) {
+ rc = PXENV_STATUS_FAILURE; + rc = PXENV_STATUS_FAILURE;
+ } + }
...@@ -581,34 +595,41 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -581,34 +595,41 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ used = strlen(new_initrd); + used = strlen(new_initrd);
+ +
+ p = new_initrd + used; + p = new_initrd + used;
+ file = strtok(p, ","); + file = strtok(initrd + used, ",");
+ while(file) { + if (!file) {
+ new_file = mangle_name(boss_name, file); + new_initrd = mangle_name(boss_name, initrd + used);
+ if ((used + strlen(new_file)) >= length) { + } else {
+ /* plus 1 for comma */ + while(file) {
+ length = used + strlen(new_file) + 1; + new_file = mangle_name(boss_name, file);
+ /* plus 1 for null */ + if ((used + strlen(new_file)) >= length) {
+ t = realloc(new_initrd, length + 1); + /* plus 1 for comma */
+ if (t == NULL) { + length = used + strlen(new_file) + 1;
+ if (new_initrd) + /* plus 1 for null */
+ free(new_initrd); + t = realloc(new_initrd, length + 1);
+ return NULL; + if (t == NULL) {
+ if (new_initrd)
+ free(new_initrd);
+ return NULL;
+ }
+ new_initrd = t;
+ p = new_initrd + used;
+ } + }
+ new_initrd = t;
+ p = new_initrd + used;
+ }
+ +
+ /*start after the "initrd=" */ + /*start after the "initrd=" */
+ sprintf(p, "%s%s", + if (new_initrd[7]) {
+ new_initrd[7] ? "," : "", + sprintf(p, ",%s", new_file);
+ new_file); + p += 1;
+ } else {
+ sprintf(p, "%s", new_file);
+ }
+ +
+ p += strlen(new_file); + p += strlen(new_file);
+ free(new_file); + free(new_file);
+ +
+ used = p - new_initrd; + used = p - new_initrd;
+ +
+ file = strtok(NULL, ","); + file = strtok(NULL, ",");
+ }
+ } + }
+ +
+ return new_initrd; + return new_initrd;
...@@ -681,9 +702,9 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -681,9 +702,9 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ +
+int main(int argc, char *argv[]) +int main(int argc, char *argv[])
+{ +{
+ boot_info_t boot_info; + boot_info_t *boot_info;
+ boot_what_t *boot_what_p; + boot_what_t *boot_what;
+ uint8_t buffer[sizeof(boot_what_t) + MAX_BOOT_CMDLINE]; + uint8_t buffer[sizeof(boot_info_t) + MAX_BOOT_CMDLINE];
+ size_t length; + size_t length;
+ in_addr_t my_ip; + in_addr_t my_ip;
+ in_addr_t boss_ip; + in_addr_t boss_ip;
...@@ -723,7 +744,7 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -723,7 +744,7 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ ntop(&boss_ip, foobar, sizeof(foobar)) : "failed!"); + ntop(&boss_ip, foobar, sizeof(foobar)) : "failed!");
+ } + }
+ +
+ boot_what_p = (boot_what_t *)buffer; + boot_info = (boot_info_t *)buffer;
+ +
+ /* Extract our IP address from the cached DHCP data */ + /* Extract our IP address from the cached DHCP data */
+ if (pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, + if (pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata,
...@@ -747,9 +768,9 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -747,9 +768,9 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ +
+ free(dhcpdata); + free(dhcpdata);
+ +
+ memset(&boot_info, 0, sizeof(boot_info_t)); + memset(buffer, 0, sizeof(buffer));
+ boot_info.version = BIVERSION_CURRENT; + boot_info->version = BIVERSION_CURRENT;
+ boot_info.opcode = BIOPCODE_BOOTWHAT_REQUEST; + boot_info->opcode = BIOPCODE_BOOTWHAT_REQUEST;
+ +
+ udp_close(); + udp_close();
+ rc = udp_open(my_ip); + rc = udp_open(my_ip);
...@@ -760,7 +781,7 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -760,7 +781,7 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ +
+ printf("Requesting bootinfo data from %s...", boss_name); + printf("Requesting bootinfo data from %s...", boss_name);
+ while(1) { + while(1) {
+ rc = send_request(boss_ip, &boot_info); + rc = send_request(boss_ip, boot_info);
+ if (rc != PXENV_STATUS_SUCCESS && rc != PXENV_STATUS_FAILURE) { + if (rc != PXENV_STATUS_SUCCESS && rc != PXENV_STATUS_FAILURE) {
+ printf("\n"); + printf("\n");
+ return rc; + return rc;
...@@ -768,12 +789,13 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -768,12 +789,13 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ +
+ printf("."); + printf(".");
+ +
+ boot_what_p->type = 0; + boot_what = (boot_what_t *)boot_info->data;
+ boot_what->type = 0;
+ +
+ length = sizeof(buffer); + length = sizeof(buffer);
+ +
+ /* Wait up to 10 seconds(-ish) for a response */ + /* Wait up to 10 seconds(-ish) for a response */
+ rc = get_response(my_ip, buffer, &length, 10 * CLK_TCK); + rc = get_response(my_ip, boot_info, &length, 10 * CLK_TCK);
+ if (rc != PXENV_STATUS_SUCCESS && rc != PXENV_STATUS_FAILURE) { + if (rc != PXENV_STATUS_SUCCESS && rc != PXENV_STATUS_FAILURE) {
+ printf("\n"); + printf("\n");
+ return rc; + return rc;
...@@ -782,7 +804,7 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -782,7 +804,7 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ if (rc == PXENV_STATUS_SUCCESS) + if (rc == PXENV_STATUS_SUCCESS)
+ printf(" ok\n"); + printf(" ok\n");
+ +
+ while (boot_what_p->type == BIBOOTWHAT_TYPE_WAIT) { + while (boot_what->type == BIBOOTWHAT_TYPE_WAIT) {
+ printf("Polling for bootinfo response... "); + printf("Polling for bootinfo response... ");
+ length = sizeof(buffer); + length = sizeof(buffer);
+ rc = get_response(my_ip, buffer, &length, 0); + rc = get_response(my_ip, buffer, &length, 0);
...@@ -793,21 +815,25 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co ...@@ -793,21 +815,25 @@ diff -Nru syslinux-3.71+dfsg.orig/com32/modules/bootinfo.c syslinux-3.71+dfsg/co
+ printf(" ok\n"); + printf(" ok\n");
+ } + }
+ +
+ switch (boot_what_p->type) { + switch (boot_what->type) {
+ case BIBOOTWHAT_TYPE_REBOOT: + case BIBOOTWHAT_TYPE_REBOOT:
+ printf("Rebooting...\n"); + printf("Rebooting...\n");
+ syslinux_reboot(0); + syslinux_reboot(0);
+ break; + break;
+ case BIBOOTWHAT_TYPE_PART: + case BIBOOTWHAT_TYPE_PART:
+ return chain_boot("hd0", boot_what_p->what.partition); + return chain_boot("hd0", boot_what->what.partition);
+ break; + break;
+ case BIBOOTWHAT_TYPE_MFS: + case BIBOOTWHAT_TYPE_MFS:
+ return kernel_boot(boss_name, boot_what_p->what.mfs, + return kernel_boot(boss_name, boot_what->what.mfs,
+ boot_what_p->cmdline); + boot_what->cmdline);
+ break; + break;
+ case BIBOOTWHAT_TYPE_AUTO: + case BIBOOTWHAT_TYPE_AUTO:
+ printf("query: will query again\n"); + printf("query: will query again\n");
+ break; + break;
+ case BIBOOTWHAT_TYPE_SYSID:
+ printf("request to boot partition type 0x%02x not supported\n",
+ boot_what->what.sysid);
+ break;
+ } + }
+ +
+ /* Only sleep if we got a bogus response or we are to + /* Only sleep if we got a bogus response or we are to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment