Set TFTP blocksize to 1428 instead of 2048 to avoid IP fragmentation

Resolves: rhbz#1869335

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2020-08-21 15:00:31 +02:00
parent 03701dc758
commit f5482fc2cf
No known key found for this signature in database
GPG key ID: C751E590D63F3D69
3 changed files with 19 additions and 12 deletions

View file

@ -1,24 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com> From: Javier Martinez Canillas <javierm@redhat.com>
Date: Thu, 20 Aug 2020 13:19:00 +0200 Date: Thu, 20 Aug 2020 13:19:00 +0200
Subject: [PATCH] tftp: increase blocksize from 1024 to 2048 octets Subject: [PATCH] tftp: increase blocksize from 1024 to 1428 octets
The RFC2348 [0] defines how the TFTP Blocksize Option should be negotiated The RFC2348 [0] defines how the TFTP Blocksize Option should be negotiated
between the client and the server. GRUB just hardcodes this to 1024, which between the client and the server. GRUB just hardcodes this to 1024, which
limits the maximum file size to be fetched to 65535 KiB, since the block limits the maximum file size to be downloaded to 67107840 byes, since the
number is stored in a 16-bit field. block number is stored in a 16-bit field.
This limit is a problem when attempting to fetch large files (i.e: initrd This limit is a problem when attempting to fetch large files (i.e: initrd
images) because the block number will overflow, and GRUB will never ack a images) because the block number will overflow, and GRUB will never ack a
packet. This causes a timeout when trying to download the file over TFTP. packet. This causes a timeout when trying to download the file over TFTP.
Since the TFTP support in GRUB is used primarily to fetch the kernel and Since the TFTP support in GRUB is used primarily to fetch the kernel and
initrd images, let's bump the blocksize to 2048 which would allow to get initrd images, let's bump the blocksize to 1428 which would allow to get
files twice as large than the current limit. larger files.
The value of 1428 is chosen to increase the maximum file size limit, while
avoiding IP packet fragmentation which could be a problem in some networks.
The TFTP support should be improved to define the blocksize dynamically The TFTP support should be improved to define the blocksize dynamically
instead of hardcoding it, but until that happens is better to use a value instead of hardcoding it, but until that happens is better to use a value
that at least allows to fetch a kernel and initrd image with the size that that at least allows to fetch kernel and initrd images with the sizes that
are present in the install media that is used for network booting. are present in the install media that is used for network booting.
[0]: https://tools.ietf.org/html/rfc2348 [0]: https://tools.ietf.org/html/rfc2348
@ -29,7 +32,7 @@ Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
1 file changed, 3 insertions(+), 3 deletions(-) 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
index 22badd74316..816050bca43 100644 index 22badd74316..43920885411 100644
--- a/grub-core/net/tftp.c --- a/grub-core/net/tftp.c
+++ b/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c
@@ -322,9 +322,9 @@ tftp_open (struct grub_file *file, const char *filename) @@ -322,9 +322,9 @@ tftp_open (struct grub_file *file, const char *filename)
@ -39,9 +42,9 @@ index 22badd74316..816050bca43 100644
- grub_strcpy (rrq, "1024"); - grub_strcpy (rrq, "1024");
- rrqlen += grub_strlen ("1024") + 1; - rrqlen += grub_strlen ("1024") + 1;
- rrq += grub_strlen ("1024") + 1; - rrq += grub_strlen ("1024") + 1;
+ grub_strcpy (rrq, "2048"); + grub_strcpy (rrq, "1428");
+ rrqlen += grub_strlen ("2048") + 1; + rrqlen += grub_strlen ("1428") + 1;
+ rrq += grub_strlen ("2048") + 1; + rrq += grub_strlen ("1428") + 1;
grub_strcpy (rrq, "tsize"); grub_strcpy (rrq, "tsize");
rrqlen += grub_strlen ("tsize") + 1; rrqlen += grub_strlen ("tsize") + 1;

View file

@ -265,4 +265,4 @@ Patch0264: 0264-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch
Patch0265: 0265-Fix-const-char-pointers-in-grub-core-net-url.c.patch Patch0265: 0265-Fix-const-char-pointers-in-grub-core-net-url.c.patch
Patch0266: 0266-Add-systemd-integration-scripts-to-make-systemctl-re.patch Patch0266: 0266-Add-systemd-integration-scripts-to-make-systemctl-re.patch
Patch0267: 0267-systemd-integration.sh-Also-set-old-menu_show_once-g.patch Patch0267: 0267-systemd-integration.sh-Also-set-old-menu_show_once-g.patch
Patch0268: 0268-tftp-increase-blocksize-from-1024-to-2048-octets.patch Patch0268: 0268-tftp-increase-blocksize-from-1024-to-1428-octets.patch

View file

@ -14,7 +14,7 @@
Name: grub2 Name: grub2
Epoch: 1 Epoch: 1
Version: 2.04 Version: 2.04
Release: 29%{?dist} Release: 30%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+ License: GPLv3+
URL: http://www.gnu.org/software/grub/ URL: http://www.gnu.org/software/grub/
@ -516,6 +516,10 @@ rm -r /boot/grub2.tmp/ || :
%endif %endif
%changelog %changelog
* Fri Aug 21 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.04-30
- Set TFTP blocksize to 1428 instead of 2048 to avoid IP fragmentation
Resolves: rhbz#1869335
* Fri Aug 21 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.04-29 * Fri Aug 21 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.04-29
- Fix TFTP timeouts when trying to fetch files larger than 65535 KiB - Fix TFTP timeouts when trying to fetch files larger than 65535 KiB
Resolves: rhbz#1869335 Resolves: rhbz#1869335