27a4da
From d2a69d49f156c0bc3f3ba9f9cb14c21d817eadb3 Mon Sep 17 00:00:00 2001
27a4da
From: Andrei Borzenkov <arvidjaar@gmail.com>
27a4da
Date: Sun, 17 May 2015 22:38:30 +0300
27a4da
Subject: [PATCH 245/260] bootp: ignore gateway_ip (relay) field.
27a4da
27a4da
From RFC1542:
27a4da
27a4da
   The 'giaddr' field is rather poorly named.  It exists to facilitate
27a4da
   the transfer of BOOTREQUEST messages from a client, through BOOTP
27a4da
   relay agents, to servers on different networks than the client.
27a4da
   Similarly, it facilitates the delivery of BOOTREPLY messages from the
27a4da
   servers, through BOOTP relay agents, back to the client.  In no case
27a4da
   does it represent a general IP router to be used by the client.  A
27a4da
   BOOTP client MUST set the 'giaddr' field to zero (0.0.0.0) in all
27a4da
   BOOTREQUEST messages it generates.
27a4da
27a4da
   A BOOTP client MUST NOT interpret the 'giaddr' field of a BOOTREPLY
27a4da
   message to be the IP address of an IP router.  A BOOTP client SHOULD
27a4da
   completely ignore the contents of the 'giaddr' field in BOOTREPLY
27a4da
   messages.
27a4da
27a4da
Leave code ifdef'd out for the time being in case we see regression.
27a4da
27a4da
Suggested by: Rink Springer <rink@rink.nu>
27a4da
Closes: 43396
27a4da
---
27a4da
 docs/grub.texi        | 6 ++++--
27a4da
 grub-core/net/bootp.c | 7 +++++++
27a4da
 2 files changed, 11 insertions(+), 2 deletions(-)
27a4da
27a4da
diff --git a/docs/grub.texi b/docs/grub.texi
27a4da
index ef09c8324..98138e04d 100644
27a4da
--- a/docs/grub.texi
27a4da
+++ b/docs/grub.texi
27a4da
@@ -5211,8 +5211,10 @@ by @var{shortname} which can be used to remove it (@pxref{net_del_route}).
27a4da
 Perform configuration of @var{card} using DHCP protocol. If no card name
27a4da
 is specified, try to configure all existing cards. If configuration was
27a4da
 successful, interface with name @var{card}@samp{:dhcp} and configured
27a4da
-address is added to @var{card}. If server provided gateway information in
27a4da
-DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}. Additionally the following DHCP options are recognized and processed:
27a4da
+address is added to @var{card}.
27a4da
+@comment If server provided gateway information in
27a4da
+@comment DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}.
27a4da
+Additionally the following DHCP options are recognized and processed:
27a4da
 
27a4da
 @table @samp
27a4da
 @item 1 (Subnet Mask)
27a4da
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
27a4da
index b4b8159cd..62d602d96 100644
27a4da
--- a/grub-core/net/bootp.c
27a4da
+++ b/grub-core/net/bootp.c
27a4da
@@ -237,6 +237,12 @@ grub_net_configure_by_dhcp_ack (const char *name,
27a4da
   hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
27a4da
 
27a4da
   inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags);
27a4da
+#if 0
27a4da
+  /* This is likely based on misunderstanding. gateway_ip refers to
27a4da
+     address of BOOTP relay and should not be used after BOOTP transaction
27a4da
+     is complete.
27a4da
+     See RFC1542, 3.4 Interpretation of the 'giaddr' field
27a4da
+   */
27a4da
   if (bp->gateway_ip)
27a4da
     {
27a4da
       grub_net_network_level_netaddress_t target;
27a4da
@@ -258,6 +264,7 @@ grub_net_configure_by_dhcp_ack (const char *name,
27a4da
       target.ipv4.masksize = 32;
27a4da
       grub_net_add_route (name, target, inter);
27a4da
     }
27a4da
+#endif
27a4da
 
27a4da
   if (size > OFFSET_OF (boot_file, bp))
27a4da
     grub_env_set_net_property (name, "boot_file", bp->boot_file,
27a4da
-- 
27a4da
2.13.0
27a4da