GRUB's TCP stack assigns source ports for outgoing connections starting at 21550 and increments sequentially by 1 (e.g., 21550, 21551, ...). While this generally works, it can lead to failures if the system reboots rapidly and reuses the same source port too soon. This issue was observed on powerpc-ieee1275 platforms using CAS (Client Architecture Support) reboot. In such cases, loading the initrd over HTTP may fail with connection timeouts. Packet captures show the failed connections are flagged as "TCP Port Number Reused" by Wireshark. The root cause is that GRUB reuses the same port shortly after reboot, while the server may still be tracking the previous connection in TIME_WAIT. This can result in the server rejecting the connection attempt or responding with a stale ACK or RST, leading to handshake failure. This patch fixes the issue by introducing a time based source port selection strategy. Instead of always starting from port 21550, GRUB now computes an initial base port based on the current RTC time, divided into 5 minute windows. The purpose of this time based strategy is to ensure that GRUB avoids reusing the same source port within a 5 minute window, thereby preventing collisions with stale server side connection tracking that could interfere with a new TCP handshake. A step size of 8 ensures that the same port will not be reused across reboots unless GRUB opens more than 8 TCP connections per second on average, something that is highly unlikely. In typical usage, a GRUB boot cycle lasts about 15 seconds and may open fewer than 100 connections total, well below the reuse threshold. This makes the approach robust against short reboot intervals while keeping the logic simple and deterministic. Signed-off-by: Michael Chang <mchang@suse.com> Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This is GRUB 2, the second version of the GRand Unified Bootloader. GRUB 2 is rewritten from scratch to make GNU GRUB cleaner, safer, more robust, more powerful, and more portable. See the file NEWS for a description of recent changes to GRUB 2. See the file INSTALL for instructions on how to build and install the GRUB 2 data and program files. See the file MAINTAINERS for information about the GRUB maintainers, etc. If you found a security vulnerability in the GRUB please check the SECURITY file to get more information how to properly report this kind of bugs to the maintainers. Please visit the official web page of GRUB 2, for more information. The URL is <http://www.gnu.org/software/grub/grub.html>. More extensive documentation is available in the Info manual, accessible using 'info grub' after building and installing GRUB 2. There are a number of important user-visible differences from the first version of GRUB, now known as GRUB Legacy. For a summary, please see: info grub Introduction 'Changes from GRUB Legacy'
Description
Languages
C
82.5%
Assembly
13.6%
M4
1.4%
Shell
1.3%
Makefile
0.5%
Other
0.5%