nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone
f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: Andrzej Kacprowski <andrzej.kacprowski@intel.com>
f725e3
Date: Fri, 21 Apr 2017 09:20:38 +0200
f725e3
Subject: [PATCH] Use xid to match DHCP replies
f725e3
f725e3
Transaction identifier (xid) from DHCP request
f725e3
packet is stored in network level interface and used
f725e3
to match request with the responses it generates.
f725e3
f725e3
Resolves: rhbz#1370642
f725e3
f725e3
Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@intel.com>
f725e3
---
f725e3
 grub-core/net/bootp.c | 3 ++-
f725e3
 grub-core/net/ip.c    | 1 +
f725e3
 include/grub/net.h    | 3 ++-
f725e3
 3 files changed, 5 insertions(+), 2 deletions(-)
f725e3
f725e3
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
f725e3
index 7df7f55110e..dfdf7e08d90 100644
f725e3
--- a/grub-core/net/bootp.c
f725e3
+++ b/grub-core/net/bootp.c
f725e3
@@ -769,7 +769,8 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
f725e3
 	      grub_errno = GRUB_ERR_NONE;
f725e3
 	      t = 0;
f725e3
 	    }
f725e3
-	  pack->ident = grub_cpu_to_be32 (t);
f725e3
+	  pack->xid = grub_cpu_to_be32 (t);
f725e3
+	  ifaces[j].dhcp_xid = pack->xid;
f725e3
 	  pack->seconds = grub_cpu_to_be16 (t);
f725e3
 
f725e3
 	  grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, 6); 
f725e3
diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c
f725e3
index 5a609544403..9e7930caa03 100644
f725e3
--- a/grub-core/net/ip.c
f725e3
+++ b/grub-core/net/ip.c
f725e3
@@ -271,6 +271,7 @@ handle_dgram (struct grub_net_buff *nb,
f725e3
 	FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
f725e3
 	  if (inf->card == card
f725e3
 	      && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV
f725e3
+	      && inf->dhcp_xid == bootp->xid
f725e3
 	      && inf->hwaddress.type == GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET
f725e3
 	      && grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr,
f725e3
 			      sizeof (inf->hwaddress.mac)) == 0)
f725e3
diff --git a/include/grub/net.h b/include/grub/net.h
f725e3
index bd930f4dd8c..b1bc23048f1 100644
f725e3
--- a/include/grub/net.h
f725e3
+++ b/include/grub/net.h
f725e3
@@ -279,6 +279,7 @@ struct grub_net_network_level_interface
f725e3
   grub_net_interface_flags_t flags;
f725e3
   struct grub_net_bootp_packet *dhcp_ack;
f725e3
   grub_size_t dhcp_acklen;
f725e3
+  grub_uint32_t dhcp_xid;
f725e3
   void *data;
f725e3
 };
f725e3
 
f725e3
@@ -405,7 +406,7 @@ struct grub_net_bootp_packet
f725e3
   grub_uint8_t hw_type;		/* hardware type.  */
f725e3
   grub_uint8_t hw_len;		/* hardware addr len.  */
f725e3
   grub_uint8_t gate_hops;	/* zero it.  */
f725e3
-  grub_uint32_t ident;		/* random number chosen by client.  */
f725e3
+  grub_uint32_t xid;		/* transaction id chosen by client.  */
f725e3
   grub_uint16_t seconds;	/* seconds since did initial bootstrap.  */
f725e3
   grub_uint16_t flags;
f725e3
   grub_uint32_t	client_ip;