[packages/grub2] More TFTP fixes from upstream

jajcus jajcus at pld-linux.org
Sat Nov 30 12:03:49 CET 2013


commit 4d63dfb7a0fe73516f2ba60d5a3dec11f953152e
Author: Jacek Konieczny <jajcus at jajcus.net>
Date:   Sat Nov 30 12:03:00 2013 +0100

    More TFTP fixes from upstream
    
    Now GRUB2 will be able to handle TFTP files longer than 65536 blocks.

 grub2-tftp_fix.patch   |  36 -------------
 grub2-tftp_fixes.patch | 144 +++++++++++++++++++++++++++++++++++++++++++++++++
 grub2.spec             |   4 +-
 3 files changed, 146 insertions(+), 38 deletions(-)
---
diff --git a/grub2.spec b/grub2.spec
index fe41c70..d4d3d85 100644
--- a/grub2.spec
+++ b/grub2.spec
@@ -46,7 +46,7 @@ Summary(pl.UTF-8):	GRUB2 - bootloader dla x86 i ppc
 Summary(pt_BR.UTF-8):	Gerenciador de inicialização GRUB2
 Name:		grub2
 Version:	2.00
-Release:	5
+Release:	6
 License:	GPL v2
 Group:		Base
 Source0:	http://ftp.gnu.org/gnu/grub/grub-%{version}.tar.xz
@@ -65,7 +65,7 @@ Patch7:		%{name}-awk.patch
 Patch8:		posix.patch
 Patch9:		%{name}-gets.patch
 Patch10:	%{name}-fonts_path.patch
-Patch11:	%{name}-tftp_fix.patch
+Patch11:	%{name}-tftp_fixes.patch
 Patch12:	add-vlan-tag-support.patch
 Patch13:	just-say-linux.patch
 Patch14:	add-GRUB-DISABLE-SUBMENU-option.patch
diff --git a/grub2-tftp_fix.patch b/grub2-tftp_fix.patch
deleted file mode 100644
index 397a0d7..0000000
--- a/grub2-tftp_fix.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4548
-
-diff -dur grub-2.00.orig/ChangeLog grub-2.00/ChangeLog
---- grub-2.00.orig/ChangeLog	2012-06-28 02:06:26.000000000 +0200
-+++ grub-2.00/ChangeLog	2012-10-28 10:52:48.619830487 +0100
-@@ -1,3 +1,9 @@
-+2012-07-02  Vladimir Serbinenko  <phcoder at gmail.com>
-+
-+	* grub-core/net/tftp.c (ack): Fix endianness problem.
-+	(tftp_receive): Likewise.
-+	Reported by: Michael Davidsaver.
-+
- 2012-06-27  Vladimir Serbinenko  <phcoder at gmail.com>
- 
- 	* configure.ac: Bump version to 2.00.
-diff -dur grub-2.00.orig/grub-core/net/tftp.c grub-2.00/grub-core/net/tftp.c
---- grub-2.00.orig/grub-core/net/tftp.c	2012-06-22 17:42:07.000000000 +0200
-+++ grub-2.00/grub-core/net/tftp.c	2012-10-28 10:52:11.463407895 +0100
-@@ -143,7 +143,7 @@
- 
-   tftph_ack = (struct tftphdr *) nb_ack.data;
-   tftph_ack->opcode = grub_cpu_to_be16 (TFTP_ACK);
--  tftph_ack->u.ack.block = block;
-+  tftph_ack->u.ack.block = grub_cpu_to_be16 (block);
- 
-   err = grub_net_send_udp_packet (data->sock, &nb_ack);
-   if (err)
-@@ -225,7 +225,7 @@
- 	    grub_priority_queue_pop (data->pq);
- 
- 	    if (file->device->net->packs.count < 50)
--	      err = ack (data, tftph->u.data.block);
-+	      err = ack (data, data->block + 1);
- 	    else
- 	      {
- 		file->device->net->stall = 1;
diff --git a/grub2-tftp_fixes.patch b/grub2-tftp_fixes.patch
new file mode 100644
index 0000000..3846463
--- /dev/null
+++ b/grub2-tftp_fixes.patch
@@ -0,0 +1,144 @@
+From 1ff55c8030ed529b17b02993877ac4803e7aa449 Mon Sep 17 00:00:00 2001
+From: Vladimir 'phcoder' Serbinenko <phcoder at gmail.com>
+Date: Mon, 2 Jul 2012 11:22:50 +0200
+Subject: [PATCH 1/3] 	* grub-core/net/tftp.c (ack): Fix endianness problem. 
+ (tftp_receive): Likewise. 	Reported by: Michael Davidsaver.
+
+(cherry picked from commit a706f4cc6bddd03e67a66620101209c471177b53)
+---
+ grub-core/net/tftp.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
+index 9c70efb..d0f39ea 100644
+--- a/grub-core/net/tftp.c
++++ b/grub-core/net/tftp.c
+@@ -143,7 +143,7 @@ ack (tftp_data_t data, grub_uint16_t block)
+ 
+   tftph_ack = (struct tftphdr *) nb_ack.data;
+   tftph_ack->opcode = grub_cpu_to_be16 (TFTP_ACK);
+-  tftph_ack->u.ack.block = block;
++  tftph_ack->u.ack.block = grub_cpu_to_be16 (block);
+ 
+   err = grub_net_send_udp_packet (data->sock, &nb_ack);
+   if (err)
+@@ -225,7 +225,7 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)),
+ 	    grub_priority_queue_pop (data->pq);
+ 
+ 	    if (file->device->net->packs.count < 50)
+-	      err = ack (data, tftph->u.data.block);
++	      err = ack (data, data->block + 1);
+ 	    else
+ 	      {
+ 		file->device->net->stall = 1;
+-- 
+1.8.2
+
+
+From 412928c729fff75cf53914cd4acac88c5e229397 Mon Sep 17 00:00:00 2001
+From: Avik Sil <aviksil at in.ibm.com>
+Date: Wed, 14 Aug 2013 20:32:42 -0300
+Subject: [PATCH 2/3] * grub-core/net/tftp.c: Send tftp ack packet before
+ closing the socket.
+
+(cherry picked from commit 369508b3cb0a84c0118ee32adef923109ad187dc)
+---
+ grub-core/net/tftp.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
+index d0f39ea..b9d9549 100644
+--- a/grub-core/net/tftp.c
++++ b/grub-core/net/tftp.c
+@@ -243,6 +243,8 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)),
+ 	    data->block++;
+ 	    if (size < data->block_size)
+ 	      {
++		if (data->ack_sent < data->block)
++		  ack (data, data->block);
+ 		file->device->net->eof = 1;
+ 		file->device->net->stall = 1;
+ 		grub_net_udp_close (data->sock);
+-- 
+1.8.2
+
+
+From e944f5bb19bb7f07ca065df75979ba3067306ae1 Mon Sep 17 00:00:00 2001
+From: Vladimir Serbinenko <phcoder at gmail.com>
+Date: Sat, 26 Oct 2013 12:48:49 +0200
+Subject: [PATCH 3/3] 	* grub-core/net/tftp.c: Retransmit ack when
+ rereceiving old packet. 	Try to handle more than 0xFFFF packets.
+
+(cherry picked from commit cf8d6bbd9eb2f5c6cbb0b6e437466c77fc7b6e9b)
+---
+ grub-core/net/tftp.c | 26 +++++++++++++++++---------
+ 1 file changed, 17 insertions(+), 9 deletions(-)
+
+diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
+index b9d9549..97217d2 100644
+--- a/grub-core/net/tftp.c
++++ b/grub-core/net/tftp.c
+@@ -102,7 +102,7 @@ typedef struct tftp_data
+   grub_uint64_t file_size;
+   grub_uint64_t block;
+   grub_uint32_t block_size;
+-  grub_uint32_t ack_sent;
++  grub_uint64_t ack_sent;
+   int have_oack;
+   struct grub_error_saved save_err;
+   grub_net_udp_socket_t sock;
+@@ -110,6 +110,17 @@ typedef struct tftp_data
+ } *tftp_data_t;
+ 
+ static int
++cmp_block (grub_uint16_t a, grub_uint16_t b)
++{
++  grub_int16_t i = (grub_int16_t) (a - b);
++  if (i > 0)
++    return +1;
++  if (i < 0)
++    return -1;
++  return 0;
++}
++
++static int
+ cmp (const void *a__, const void *b__)
+ {
+   struct grub_net_buff *a_ = *(struct grub_net_buff **) a__;
+@@ -117,15 +128,11 @@ cmp (const void *a__, const void *b__)
+   struct tftphdr *a = (struct tftphdr *) a_->data;
+   struct tftphdr *b = (struct tftphdr *) b_->data;
+   /* We want the first elements to be on top.  */
+-  if (grub_be_to_cpu16 (a->u.data.block) < grub_be_to_cpu16 (b->u.data.block))
+-    return +1;
+-  if (grub_be_to_cpu16 (a->u.data.block) > grub_be_to_cpu16 (b->u.data.block))
+-    return -1;
+-  return 0;
++  return -cmp_block (grub_be_to_cpu16 (a->u.data.block), grub_be_to_cpu16 (b->u.data.block));
+ }
+ 
+ static grub_err_t
+-ack (tftp_data_t data, grub_uint16_t block)
++ack (tftp_data_t data, grub_uint64_t block)
+ {
+   struct tftphdr *tftph_ack;
+   grub_uint8_t nbdata[512];
+@@ -213,12 +220,13 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)),
+ 	      return GRUB_ERR_NONE;
+ 	    nb_top = *nb_top_p;
+ 	    tftph = (struct tftphdr *) nb_top->data;
+-	    if (grub_be_to_cpu16 (tftph->u.data.block) >= data->block + 1)
++	    if (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) >= 0)
+ 	      break;
++	    ack (data, grub_be_to_cpu16 (tftph->u.data.block));
+ 	    grub_netbuff_free (nb_top);
+ 	    grub_priority_queue_pop (data->pq);
+ 	  }
+-	if (grub_be_to_cpu16 (tftph->u.data.block) == data->block + 1)
++	while (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) == 0)
+ 	  {
+ 	    unsigned size;
+ 
+-- 
+1.8.2
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/grub2.git/commitdiff/4d63dfb7a0fe73516f2ba60d5a3dec11f953152e



More information about the pld-cvs-commit mailing list